1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(runtime): use more null proto objects again (#25040)

proceed with #23921

This PR is a preparation for
https://github.com/denoland/deno_lint/pull/1307

---------

Signed-off-by: Kenta Moriuchi <moriken@kimamass.com>
Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Kenta Moriuchi 2024-09-06 19:52:59 +09:00 committed by GitHub
parent 8ef08f1d29
commit f0a3d20642
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 144 additions and 20 deletions

View file

@ -260,6 +260,7 @@ const colors = {
function defineColorAlias(target, alias) { function defineColorAlias(target, alias) {
ObjectDefineProperty(colors, alias, { ObjectDefineProperty(colors, alias, {
__proto__: null,
get() { get() {
return this[target]; return this[target];
}, },
@ -3447,7 +3448,10 @@ function inspect(
function createFilteredInspectProxy({ object, keys, evaluate }) { function createFilteredInspectProxy({ object, keys, evaluate }) {
const obj = class {}; const obj = class {};
if (object.constructor?.name) { if (object.constructor?.name) {
ObjectDefineProperty(obj, "name", { value: object.constructor.name }); ObjectDefineProperty(obj, "name", {
__proto__: null,
value: object.constructor.name,
});
} }
return new Proxy(new obj(), { return new Proxy(new obj(), {

View file

@ -263,6 +263,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
/** @type {PropertyDescriptorMap} */ /** @type {PropertyDescriptorMap} */
const mixin = { const mixin = {
body: { body: {
__proto__: null,
/** /**
* @returns {ReadableStream<Uint8Array> | null} * @returns {ReadableStream<Uint8Array> | null}
*/ */
@ -278,6 +279,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
bodyUsed: { bodyUsed: {
__proto__: null,
/** /**
* @returns {boolean} * @returns {boolean}
*/ */
@ -292,6 +294,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
arrayBuffer: { arrayBuffer: {
__proto__: null,
/** @returns {Promise<ArrayBuffer>} */ /** @returns {Promise<ArrayBuffer>} */
value: function arrayBuffer() { value: function arrayBuffer() {
return consumeBody(this, "ArrayBuffer"); return consumeBody(this, "ArrayBuffer");
@ -301,6 +304,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
blob: { blob: {
__proto__: null,
/** @returns {Promise<Blob>} */ /** @returns {Promise<Blob>} */
value: function blob() { value: function blob() {
return consumeBody(this, "Blob"); return consumeBody(this, "Blob");
@ -310,6 +314,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
bytes: { bytes: {
__proto__: null,
/** @returns {Promise<Uint8Array>} */ /** @returns {Promise<Uint8Array>} */
value: function bytes() { value: function bytes() {
return consumeBody(this, "bytes"); return consumeBody(this, "bytes");
@ -319,6 +324,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
formData: { formData: {
__proto__: null,
/** @returns {Promise<FormData>} */ /** @returns {Promise<FormData>} */
value: function formData() { value: function formData() {
return consumeBody(this, "FormData"); return consumeBody(this, "FormData");
@ -328,6 +334,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
json: { json: {
__proto__: null,
/** @returns {Promise<any>} */ /** @returns {Promise<any>} */
value: function json() { value: function json() {
return consumeBody(this, "JSON"); return consumeBody(this, "JSON");
@ -337,6 +344,7 @@ function mixinBody(prototype, bodySymbol, mimeTypeSymbol) {
enumerable: true, enumerable: true,
}, },
text: { text: {
__proto__: null,
/** @returns {Promise<string>} */ /** @returns {Promise<string>} */
value: function text() { value: function text() {
return consumeBody(this, "text"); return consumeBody(this, "text");

View file

@ -42,6 +42,7 @@ class HttpClient {
*/ */
constructor(rid) { constructor(rid) {
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });

View file

@ -432,9 +432,9 @@ class Response {
webidl.configureInterface(Response); webidl.configureInterface(Response);
ObjectDefineProperties(Response, { ObjectDefineProperties(Response, {
json: { enumerable: true }, json: { __proto__: null, enumerable: true },
redirect: { enumerable: true }, redirect: { __proto__: null, enumerable: true },
error: { enumerable: true }, error: { __proto__: null, enumerable: true },
}); });
const ResponsePrototype = Response.prototype; const ResponsePrototype = Response.prototype;
mixinBody(ResponsePrototype, _body, _mimeType); mixinBody(ResponsePrototype, _body, _mimeType);

View file

@ -355,12 +355,15 @@ const EventSourcePrototype = EventSource.prototype;
ObjectDefineProperties(EventSource, { ObjectDefineProperties(EventSource, {
CONNECTING: { CONNECTING: {
__proto__: null,
value: 0, value: 0,
}, },
OPEN: { OPEN: {
__proto__: null,
value: 1, value: 1,
}, },
CLOSED: { CLOSED: {
__proto__: null,
value: 2, value: 2,
}, },
}); });

View file

@ -484,10 +484,11 @@ class DynamicLibrary {
this.symbols, this.symbols,
symbol, symbol,
{ {
__proto__: null,
configurable: false, configurable: false,
enumerable: true, enumerable: true,
value,
writable: false, writable: false,
value,
}, },
); );
continue; continue;
@ -504,8 +505,10 @@ class DynamicLibrary {
this.symbols, this.symbols,
symbol, symbol,
{ {
__proto__: null,
configurable: false, configurable: false,
enumerable: true, enumerable: true,
writable: false,
value: (...parameters) => { value: (...parameters) => {
if (isStructResult) { if (isStructResult) {
const buffer = new Uint8Array(structSize); const buffer = new Uint8Array(structSize);
@ -527,7 +530,6 @@ class DynamicLibrary {
); );
} }
}, },
writable: false,
}, },
); );
} }

View file

@ -585,6 +585,7 @@ class FsFile {
constructor(rid, symbol) { constructor(rid, symbol) {
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });

View file

@ -103,11 +103,13 @@ class Conn {
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
if (internals.future) { if (internals.future) {
ObjectDefineProperty(this, "rid", { ObjectDefineProperty(this, "rid", {
__proto__: null,
enumerable: false, enumerable: false,
value: undefined, value: undefined,
}); });
} }
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });
@ -214,6 +216,7 @@ class TcpConn extends Conn {
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
super(rid, remoteAddr, localAddr); super(rid, remoteAddr, localAddr);
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });
@ -244,6 +247,7 @@ class UnixConn extends Conn {
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
super(rid, remoteAddr, localAddr); super(rid, remoteAddr, localAddr);
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });
@ -269,11 +273,13 @@ class Listener {
constructor(rid, addr) { constructor(rid, addr) {
if (internals.future) { if (internals.future) {
ObjectDefineProperty(this, "rid", { ObjectDefineProperty(this, "rid", {
__proto__: null,
enumerable: false, enumerable: false,
value: undefined, value: undefined,
}); });
} }
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });

View file

@ -30,6 +30,7 @@ class TlsConn extends Conn {
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
super(rid, remoteAddr, localAddr); super(rid, remoteAddr, localAddr);
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });
@ -110,6 +111,7 @@ class TlsListener extends Listener {
constructor(rid, addr) { constructor(rid, addr) {
super(rid, addr); super(rid, addr);
ObjectDefineProperty(this, internalRidSymbol, { ObjectDefineProperty(this, internalRidSymbol, {
__proto__: null,
enumerable: false, enumerable: false,
value: rid, value: rid,
}); });

View file

@ -29,6 +29,7 @@ if (process.env.CHILD) {
const start = performance.now(); const start = performance.now();
const options = { const options = {
__proto__: null,
"stdio": ["inherit", "inherit", "inherit", "ipc"], "stdio": ["inherit", "inherit", "inherit", "ipc"],
"env": { "CHILD": len.toString() }, "env": { "CHILD": len.toString() },
}; };

View file

@ -60,7 +60,7 @@ export class BrotliDecompress extends Transform {
#context; #context;
// TODO(littledivy): use `options` argument // TODO(littledivy): use `options` argument
constructor(_options = {}) { constructor(_options = { __proto__: null }) {
super({ super({
// TODO(littledivy): use `encoding` argument // TODO(littledivy): use `encoding` argument
transform(chunk, _encoding, callback) { transform(chunk, _encoding, callback) {
@ -91,7 +91,7 @@ export class BrotliDecompress extends Transform {
export class BrotliCompress extends Transform { export class BrotliCompress extends Transform {
#context; #context;
constructor(options = {}) { constructor(options = { __proto__: null }) {
super({ super({
// TODO(littledivy): use `encoding` argument // TODO(littledivy): use `encoding` argument
transform(chunk, _encoding, callback) { transform(chunk, _encoding, callback) {

View file

@ -65,22 +65,26 @@ export function createWritableStdioStream(writer, name, warmup = false) {
stream.once("close", () => writer?.close()); stream.once("close", () => writer?.close());
ObjectDefineProperties(stream, { ObjectDefineProperties(stream, {
columns: { columns: {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get: () => get: () =>
writer?.isTerminal() ? Deno.consoleSize?.().columns : undefined, writer?.isTerminal() ? Deno.consoleSize?.().columns : undefined,
}, },
rows: { rows: {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get: () => writer?.isTerminal() ? Deno.consoleSize?.().rows : undefined, get: () => writer?.isTerminal() ? Deno.consoleSize?.().rows : undefined,
}, },
isTTY: { isTTY: {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get: () => writer?.isTerminal(), get: () => writer?.isTerminal(),
}, },
getWindowSize: { getWindowSize: {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
value: () => value: () =>
@ -203,6 +207,7 @@ export const initStdin = (warmup = false) => {
stdin.on("close", () => io.stdin?.close()); stdin.on("close", () => io.stdin?.close());
stdin.fd = io.stdin ? io.STDIN_RID : -1; stdin.fd = io.stdin ? io.STDIN_RID : -1;
ObjectDefineProperty(stdin, "isTTY", { ObjectDefineProperty(stdin, "isTTY", {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get() { get() {
@ -216,6 +221,7 @@ export const initStdin = (warmup = false) => {
return stdin; return stdin;
}; };
ObjectDefineProperty(stdin, "isRaw", { ObjectDefineProperty(stdin, "isRaw", {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get() { get() {

View file

@ -13,7 +13,7 @@ import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js";
/** Resolve a Promise after a given amount of milliseconds. */ /** Resolve a Promise after a given amount of milliseconds. */
export function delay( export function delay(
ms: number, ms: number,
options: { signal?: AbortSignal } = {}, options: { signal?: AbortSignal } = { __proto__: null },
): Promise<void> { ): Promise<void> {
const { signal } = options; const { signal } = options;
if (signal?.aborted) { if (signal?.aborted) {

View file

@ -325,7 +325,10 @@ export function diffstr(A: string, B: string) {
); );
} }
function tokenize(string: string, { wordDiff = false } = {}): string[] { function tokenize(
string: string,
{ wordDiff = false } = { __proto__: null },
): string[] {
if (wordDiff) { if (wordDiff) {
// Split string on whitespace symbols // Split string on whitespace symbols
const tokens = StringPrototypeSplit(string, WHITESPACE_SYMBOL_PATTERN); const tokens = StringPrototypeSplit(string, WHITESPACE_SYMBOL_PATTERN);
@ -450,7 +453,7 @@ export function diffstr(A: string, B: string) {
*/ */
function createColor( function createColor(
diffType: DiffType, diffType: DiffType,
{ background = false } = {}, { background = false } = { __proto__: null },
): (s: string) => string { ): (s: string) => string {
// TODO(@littledivy): Remove this when we can detect // TODO(@littledivy): Remove this when we can detect
// true color terminals. // true color terminals.
@ -484,7 +487,7 @@ function createSign(diffType: DiffType): string {
export function buildMessage( export function buildMessage(
diffResult: ReadonlyArray<DiffResult<string>>, diffResult: ReadonlyArray<DiffResult<string>>,
{ stringDiff = false } = {}, { stringDiff = false } = { __proto__: null },
): string[] { ): string[] {
const messages: string[] = [], diffMessages: string[] = []; const messages: string[] = [], diffMessages: string[] = [];
ArrayPrototypePush(messages, ""); ArrayPrototypePush(messages, "");

View file

@ -403,6 +403,7 @@ StringDecoder.prototype.text = function text(
ObjectDefineProperties(StringDecoder.prototype, { ObjectDefineProperties(StringDecoder.prototype, {
lastNeed: { lastNeed: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get(this: StringDecoder): number { get(this: StringDecoder): number {
@ -410,6 +411,7 @@ ObjectDefineProperties(StringDecoder.prototype, {
}, },
}, },
lastTotal: { lastTotal: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get(this: StringDecoder): number { get(this: StringDecoder): number {

View file

@ -33,6 +33,7 @@ export function setTimeout(
} }
ObjectDefineProperty(setTimeout, promisify.custom, { ObjectDefineProperty(setTimeout, promisify.custom, {
__proto__: null,
value: (timeout: number, ...args: unknown[]) => { value: (timeout: number, ...args: unknown[]) => {
return new Promise((cb) => return new Promise((cb) =>
setTimeout(cb, timeout, ...new SafeArrayIterator(args)) setTimeout(cb, timeout, ...new SafeArrayIterator(args))

View file

@ -177,6 +177,7 @@ export function inherits<T, U>(
); );
} }
ObjectDefineProperty(ctor, "super_", { ObjectDefineProperty(ctor, "super_", {
__proto__: null,
value: superCtor, value: superCtor,
writable: true, writable: true,
configurable: true, configurable: true,

View file

@ -34,7 +34,7 @@ const kParsingContext = Symbol("script parsing context");
export class Script { export class Script {
#inner; #inner;
constructor(code, options = {}) { constructor(code, options = { __proto__: null }) {
code = `${code}`; code = `${code}`;
if (typeof options === "string") { if (typeof options === "string") {
options = { filename: options }; options = { filename: options };
@ -80,7 +80,7 @@ export class Script {
: undefined; : undefined;
} }
#runInContext(contextifiedObject, options = {}) { #runInContext(contextifiedObject, options = { __proto__: null }) {
validateObject(options, "options"); validateObject(options, "options");
let timeout = options.timeout; let timeout = options.timeout;
@ -181,7 +181,10 @@ function getContextOptions(options) {
} }
let defaultContextNameIndex = 1; let defaultContextNameIndex = 1;
export function createContext(contextObject = {}, options = {}) { export function createContext(
contextObject = {},
options = { __proto__: null },
) {
if (isContext(contextObject)) { if (isContext(contextObject)) {
return contextObject; return contextObject;
} }
@ -276,7 +279,7 @@ export function isContext(object) {
return op_vm_is_context(object); return op_vm_is_context(object);
} }
export function compileFunction(code, params, options = {}) { export function compileFunction(code, params, options = { __proto__: null }) {
validateString(code, "code"); validateString(code, "code");
if (params !== undefined) { if (params !== undefined) {
validateStringArray(params, "params"); validateStringArray(params, "params");

View file

@ -267,7 +267,7 @@ class NodeWorker extends EventEmitter {
} }
}; };
postMessage(message, transferOrOptions = {}) { postMessage(message, transferOrOptions = { __proto__: null }) {
const prefix = "Failed to execute 'postMessage' on 'MessagePort'"; const prefix = "Failed to execute 'postMessage' on 'MessagePort'";
webidl.requiredArguments(arguments.length, 1, prefix); webidl.requiredArguments(arguments.length, 1, prefix);
message = webidl.converters.any(message); message = webidl.converters.any(message);

View file

@ -186,7 +186,7 @@ const entries = ObjectEntries({
}); });
for (let i = 0; i < entries.length; ++i) { for (let i = 0; i < entries.length; ++i) {
const { 0: key, 1: value } = entries[i]; const { 0: key, 1: value } = entries[i];
const desc = { value, enumerable: true }; const desc = { __proto__: null, value, enumerable: true };
ObjectDefineProperty(DOMException, key, desc); ObjectDefineProperty(DOMException, key, desc);
ObjectDefineProperty(DOMException.prototype, key, desc); ObjectDefineProperty(DOMException.prototype, key, desc);
} }

View file

@ -392,6 +392,7 @@ const EventPrototype = Event.prototype;
// Not spec compliant. The spec defines it as [LegacyUnforgeable] // Not spec compliant. The spec defines it as [LegacyUnforgeable]
// but doing so has a big performance hit // but doing so has a big performance hit
ReflectDefineProperty(Event.prototype, "isTrusted", { ReflectDefineProperty(Event.prototype, "isTrusted", {
__proto__: null,
enumerable: true, enumerable: true,
get: isTrusted, get: isTrusted,
}); });
@ -402,7 +403,10 @@ function defineEnumerableProps(
) { ) {
for (let i = 0; i < props.length; ++i) { for (let i = 0; i < props.length; ++i) {
const prop = props[i]; const prop = props[i];
ReflectDefineProperty(Ctor.prototype, prop, { enumerable: true }); ReflectDefineProperty(Ctor.prototype, prop, {
__proto__: null,
enumerable: true,
});
} }
} }
@ -1274,6 +1278,7 @@ class CustomEvent extends Event {
const CustomEventPrototype = CustomEvent.prototype; const CustomEventPrototype = CustomEvent.prototype;
ReflectDefineProperty(CustomEvent.prototype, "detail", { ReflectDefineProperty(CustomEvent.prototype, "detail", {
__proto__: null,
enumerable: true, enumerable: true,
}); });
@ -1417,6 +1422,7 @@ function defineEventHandler(
) { ) {
// HTML specification section 8.1.7.1 // HTML specification section 8.1.7.1
ObjectDefineProperty(emitter, `on${name}`, { ObjectDefineProperty(emitter, `on${name}`, {
__proto__: null,
get() { get() {
if (!this[_eventHandlers]) { if (!this[_eventHandlers]) {
return null; return null;

View file

@ -5420,6 +5420,7 @@ class ReadableStream {
// TODO(lucacasonato): should be moved to webidl crate // TODO(lucacasonato): should be moved to webidl crate
ReadableStream.prototype[SymbolAsyncIterator] = ReadableStream.prototype.values; ReadableStream.prototype[SymbolAsyncIterator] = ReadableStream.prototype.values;
ObjectDefineProperty(ReadableStream.prototype, SymbolAsyncIterator, { ObjectDefineProperty(ReadableStream.prototype, SymbolAsyncIterator, {
__proto__: null,
writable: true, writable: true,
enumerable: false, enumerable: false,
configurable: true, configurable: true,

View file

@ -454,36 +454,42 @@ webidl.configureInterface(FileReader);
const FileReaderPrototype = FileReader.prototype; const FileReaderPrototype = FileReader.prototype;
ObjectDefineProperty(FileReader, "EMPTY", { ObjectDefineProperty(FileReader, "EMPTY", {
__proto__: null,
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: false, configurable: false,
value: 0, value: 0,
}); });
ObjectDefineProperty(FileReader, "LOADING", { ObjectDefineProperty(FileReader, "LOADING", {
__proto__: null,
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: false, configurable: false,
value: 1, value: 1,
}); });
ObjectDefineProperty(FileReader, "DONE", { ObjectDefineProperty(FileReader, "DONE", {
__proto__: null,
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: false, configurable: false,
value: 2, value: 2,
}); });
ObjectDefineProperty(FileReader.prototype, "EMPTY", { ObjectDefineProperty(FileReader.prototype, "EMPTY", {
__proto__: null,
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: false, configurable: false,
value: 0, value: 0,
}); });
ObjectDefineProperty(FileReader.prototype, "LOADING", { ObjectDefineProperty(FileReader.prototype, "LOADING", {
__proto__: null,
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: false, configurable: false,
value: 1, value: 1,
}); });
ObjectDefineProperty(FileReader.prototype, "DONE", { ObjectDefineProperty(FileReader.prototype, "DONE", {
__proto__: null,
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: false, configurable: false,

View file

@ -35,6 +35,7 @@ class Location {
url.password = ""; url.password = "";
ObjectDefineProperties(this, { ObjectDefineProperties(this, {
hash: { hash: {
__proto__: null,
get() { get() {
return url.hash; return url.hash;
}, },
@ -47,6 +48,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
host: { host: {
__proto__: null,
get() { get() {
return url.host; return url.host;
}, },
@ -59,6 +61,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
hostname: { hostname: {
__proto__: null,
get() { get() {
return url.hostname; return url.hostname;
}, },
@ -71,6 +74,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
href: { href: {
__proto__: null,
get() { get() {
return url.href; return url.href;
}, },
@ -83,12 +87,14 @@ class Location {
enumerable: true, enumerable: true,
}, },
origin: { origin: {
__proto__: null,
get() { get() {
return url.origin; return url.origin;
}, },
enumerable: true, enumerable: true,
}, },
pathname: { pathname: {
__proto__: null,
get() { get() {
return url.pathname; return url.pathname;
}, },
@ -101,6 +107,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
port: { port: {
__proto__: null,
get() { get() {
return url.port; return url.port;
}, },
@ -113,6 +120,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
protocol: { protocol: {
__proto__: null,
get() { get() {
return url.protocol; return url.protocol;
}, },
@ -125,6 +133,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
search: { search: {
__proto__: null,
get() { get() {
return url.search; return url.search;
}, },
@ -137,6 +146,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
ancestorOrigins: { ancestorOrigins: {
__proto__: null,
get() { get() {
// TODO(nayeemrmn): Replace with a `DOMStringList` instance. // TODO(nayeemrmn): Replace with a `DOMStringList` instance.
return { return {
@ -148,6 +158,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
assign: { assign: {
__proto__: null,
value: function assign() { value: function assign() {
throw new DOMException( throw new DOMException(
`Cannot call "location.assign()".`, `Cannot call "location.assign()".`,
@ -157,6 +168,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
reload: { reload: {
__proto__: null,
value: function reload() { value: function reload() {
throw new DOMException( throw new DOMException(
`Cannot call "location.reload()".`, `Cannot call "location.reload()".`,
@ -166,6 +178,7 @@ class Location {
enumerable: true, enumerable: true,
}, },
replace: { replace: {
__proto__: null,
value: function replace() { value: function replace() {
throw new DOMException( throw new DOMException(
`Cannot call "location.replace()".`, `Cannot call "location.replace()".`,
@ -175,12 +188,14 @@ class Location {
enumerable: true, enumerable: true,
}, },
toString: { toString: {
__proto__: null,
value: function toString() { value: function toString() {
return url.href; return url.href;
}, },
enumerable: true, enumerable: true,
}, },
[SymbolFor("Deno.privateCustomInspect")]: { [SymbolFor("Deno.privateCustomInspect")]: {
__proto__: null,
value: function (inspect, inspectOptions) { value: function (inspect, inspectOptions) {
return `${this.constructor.name} ${ return `${this.constructor.name} ${
inspect({ inspect({
@ -203,6 +218,7 @@ class Location {
ObjectDefineProperties(Location.prototype, { ObjectDefineProperties(Location.prototype, {
[SymbolToStringTag]: { [SymbolToStringTag]: {
__proto__: null,
value: "Location", value: "Location",
configurable: true, configurable: true,
}, },
@ -224,6 +240,7 @@ class WorkerLocation {
ObjectDefineProperties(WorkerLocation.prototype, { ObjectDefineProperties(WorkerLocation.prototype, {
hash: { hash: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -235,6 +252,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
host: { host: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -246,6 +264,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
hostname: { hostname: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -257,6 +276,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
href: { href: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -268,6 +288,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
origin: { origin: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -279,6 +300,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
pathname: { pathname: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -290,6 +312,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
port: { port: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -301,6 +324,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
protocol: { protocol: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -312,6 +336,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
search: { search: {
__proto__: null,
get() { get() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -323,6 +348,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
enumerable: true, enumerable: true,
}, },
toString: { toString: {
__proto__: null,
value: function toString() { value: function toString() {
const url = WeakMapPrototypeGet(workerLocationUrls, this); const url = WeakMapPrototypeGet(workerLocationUrls, this);
if (url == null) { if (url == null) {
@ -335,10 +361,12 @@ ObjectDefineProperties(WorkerLocation.prototype, {
writable: true, writable: true,
}, },
[SymbolToStringTag]: { [SymbolToStringTag]: {
__proto__: null,
value: "WorkerLocation", value: "WorkerLocation",
configurable: true, configurable: true,
}, },
[SymbolFor("Deno.privateCustomInspect")]: { [SymbolFor("Deno.privateCustomInspect")]: {
__proto__: null,
value: function (inspect, inspectOptions) { value: function (inspect, inspectOptions) {
return `${this.constructor.name} ${ return `${this.constructor.name} ${
inspect({ inspect({

View file

@ -132,14 +132,17 @@ class MessagePort extends EventTarget {
constructor() { constructor() {
super(); super();
ObjectDefineProperty(this, MessagePortReceiveMessageOnPortSymbol, { ObjectDefineProperty(this, MessagePortReceiveMessageOnPortSymbol, {
__proto__: null,
value: false, value: false,
enumerable: false, enumerable: false,
}); });
ObjectDefineProperty(this, nodeWorkerThreadCloseCb, { ObjectDefineProperty(this, nodeWorkerThreadCloseCb, {
__proto__: null,
value: null, value: null,
enumerable: false, enumerable: false,
}); });
ObjectDefineProperty(this, nodeWorkerThreadCloseCbInvoked, { ObjectDefineProperty(this, nodeWorkerThreadCloseCbInvoked, {
__proto__: null,
value: false, value: false,
enumerable: false, enumerable: false,
}); });

View file

@ -907,6 +907,7 @@ const GPUDeviceLostInfoPrototype = GPUDeviceLostInfo.prototype;
function GPUObjectBaseMixin(name, type) { function GPUObjectBaseMixin(name, type) {
type.prototype[_label] = null; type.prototype[_label] = null;
ObjectDefineProperty(type.prototype, "label", { ObjectDefineProperty(type.prototype, "label", {
__proto__: null,
/** /**
* @return {string | null} * @return {string | null}
*/ */

View file

@ -753,6 +753,7 @@ function createDictionaryConverter(name, ...dictionaries) {
defaultValues[member.key] = member.converter(idlMemberValue, {}); defaultValues[member.key] = member.converter(idlMemberValue, {});
} else { } else {
ObjectDefineProperty(defaultValues, member.key, { ObjectDefineProperty(defaultValues, member.key, {
__proto__: null,
get() { get() {
return member.converter(idlMemberValue, member.defaultValue); return member.converter(idlMemberValue, member.defaultValue);
}, },
@ -1076,6 +1077,7 @@ function mixinPairIterable(name, prototype, dataSymbol, keyKey, valueKey) {
function createDefaultIterator(target, kind) { function createDefaultIterator(target, kind) {
const iterator = ObjectCreate(iteratorPrototype); const iterator = ObjectCreate(iteratorPrototype);
ObjectDefineProperty(iterator, _iteratorInternal, { ObjectDefineProperty(iterator, _iteratorInternal, {
__proto__: null,
value: { target, kind, index: 0 }, value: { target, kind, index: 0 },
configurable: true, configurable: true,
}); });
@ -1149,6 +1151,7 @@ function configureInterface(interface_) {
configureProperties(interface_); configureProperties(interface_);
configureProperties(interface_.prototype); configureProperties(interface_.prototype);
ObjectDefineProperty(interface_.prototype, SymbolToStringTag, { ObjectDefineProperty(interface_.prototype, SymbolToStringTag, {
__proto__: null,
value: interface_.name, value: interface_.name,
enumerable: false, enumerable: false,
configurable: true, configurable: true,
@ -1170,12 +1173,14 @@ function configureProperties(obj) {
typeof descriptor.value === "function" typeof descriptor.value === "function"
) { ) {
ObjectDefineProperty(obj, key, { ObjectDefineProperty(obj, key, {
__proto__: null,
enumerable: true, enumerable: true,
writable: true, writable: true,
configurable: true, configurable: true,
}); });
} else if (ReflectHas(descriptor, "get")) { } else if (ReflectHas(descriptor, "get")) {
ObjectDefineProperty(obj, key, { ObjectDefineProperty(obj, key, {
__proto__: null,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
}); });
@ -1189,6 +1194,7 @@ const setlikeInner = Symbol("[[set]]");
function setlike(obj, objPrototype, readonly) { function setlike(obj, objPrototype, readonly) {
ObjectDefineProperties(obj, { ObjectDefineProperties(obj, {
size: { size: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -1197,6 +1203,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
[SymbolIterator]: { [SymbolIterator]: {
__proto__: null,
configurable: true, configurable: true,
enumerable: false, enumerable: false,
writable: true, writable: true,
@ -1206,6 +1213,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
entries: { entries: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1215,6 +1223,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
keys: { keys: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1224,6 +1233,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
values: { values: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1233,6 +1243,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
forEach: { forEach: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1242,6 +1253,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
has: { has: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1255,6 +1267,7 @@ function setlike(obj, objPrototype, readonly) {
if (!readonly) { if (!readonly) {
ObjectDefineProperties(obj, { ObjectDefineProperties(obj, {
add: { add: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1264,6 +1277,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
delete: { delete: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,
@ -1273,6 +1287,7 @@ function setlike(obj, objPrototype, readonly) {
}, },
}, },
clear: { clear: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,

View file

@ -627,15 +627,19 @@ class WebSocket extends EventTarget {
ObjectDefineProperties(WebSocket, { ObjectDefineProperties(WebSocket, {
CONNECTING: { CONNECTING: {
__proto__: null,
value: 0, value: 0,
}, },
OPEN: { OPEN: {
__proto__: null,
value: 1, value: 1,
}, },
CLOSING: { CLOSING: {
__proto__: null,
value: 2, value: 2,
}, },
CLOSED: { CLOSED: {
__proto__: null,
value: 3, value: 3,
}, },
}); });

View file

@ -119,6 +119,7 @@ function createStorage(persistent) {
set(target, key, value) { set(target, key, value) {
if (typeof key === "symbol") { if (typeof key === "symbol") {
return ReflectDefineProperty(target, key, { return ReflectDefineProperty(target, key, {
__proto__: null,
value, value,
configurable: true, configurable: true,
}); });

View file

@ -23,6 +23,7 @@ class FsWatcher {
constructor(paths, options) { constructor(paths, options) {
if (internals.future) { if (internals.future) {
ObjectDefineProperty(this, "rid", { ObjectDefineProperty(this, "rid", {
__proto__: null,
enumerable: false, enumerable: false,
value: undefined, value: undefined,
}); });
@ -79,7 +80,7 @@ class FsWatcher {
function watchFs( function watchFs(
paths, paths,
options = { recursive: true }, options = { __proto__: null, recursive: true },
) { ) {
return new FsWatcher(ArrayIsArray(paths) ? paths : [paths], options); return new FsWatcher(ArrayIsArray(paths) ? paths : [paths], options);
} }

View file

@ -463,6 +463,7 @@ class Command {
spawn() { spawn() {
const options = { const options = {
__proto__: null,
...(this.#options ?? {}), ...(this.#options ?? {}),
stdout: this.#options?.stdout ?? "inherit", stdout: this.#options?.stdout ?? "inherit",
stderr: this.#options?.stderr ?? "inherit", stderr: this.#options?.stderr ?? "inherit",

View file

@ -60,6 +60,7 @@ const language = memoizeLazy(() => op_bootstrap_language());
ObjectDefineProperties(Navigator.prototype, { ObjectDefineProperties(Navigator.prototype, {
gpu: { gpu: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -69,6 +70,7 @@ ObjectDefineProperties(Navigator.prototype, {
}, },
}, },
hardwareConcurrency: { hardwareConcurrency: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -77,6 +79,7 @@ ObjectDefineProperties(Navigator.prototype, {
}, },
}, },
userAgent: { userAgent: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -85,6 +88,7 @@ ObjectDefineProperties(Navigator.prototype, {
}, },
}, },
language: { language: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -93,6 +97,7 @@ ObjectDefineProperties(Navigator.prototype, {
}, },
}, },
languages: { languages: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {

View file

@ -58,6 +58,7 @@ const workerNavigator = webidl.createBranded(WorkerNavigator);
ObjectDefineProperties(WorkerNavigator.prototype, { ObjectDefineProperties(WorkerNavigator.prototype, {
gpu: { gpu: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -67,6 +68,7 @@ ObjectDefineProperties(WorkerNavigator.prototype, {
}, },
}, },
hardwareConcurrency: { hardwareConcurrency: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -75,6 +77,7 @@ ObjectDefineProperties(WorkerNavigator.prototype, {
}, },
}, },
userAgent: { userAgent: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -83,6 +86,7 @@ ObjectDefineProperties(WorkerNavigator.prototype, {
}, },
}, },
language: { language: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {
@ -91,6 +95,7 @@ ObjectDefineProperties(WorkerNavigator.prototype, {
}, },
}, },
languages: { languages: {
__proto__: null,
configurable: true, configurable: true,
enumerable: true, enumerable: true,
get() { get() {

View file

@ -92,12 +92,14 @@ if (Symbol.metadata) {
} }
ObjectDefineProperties(Symbol, { ObjectDefineProperties(Symbol, {
dispose: { dispose: {
__proto__: null,
value: SymbolDispose, value: SymbolDispose,
enumerable: false, enumerable: false,
writable: false, writable: false,
configurable: false, configurable: false,
}, },
metadata: { metadata: {
__proto__: null,
value: SymbolMetadata, value: SymbolMetadata,
enumerable: false, enumerable: false,
writable: false, writable: false,
@ -533,6 +535,7 @@ ObjectDefineProperties(finalDenoNs, {
args: core.propGetterOnly(opArgs), args: core.propGetterOnly(opArgs),
mainModule: core.propGetterOnly(() => op_main_module()), mainModule: core.propGetterOnly(() => op_main_module()),
exitCode: { exitCode: {
__proto__: null,
get() { get() {
return os.getExitCode(); return os.getExitCode();
}, },