diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-11-19 17:13:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 09:13:38 +0100 |
commit | c806fbdabe144c865612bbbc9ef596c9611c8310 (patch) | |
tree | edb38d58720377580677ccbeffb693ffa1225cc4 /ext/web | |
parent | a7548afb58b9848e501a085455446f5de897ffaa (diff) |
fix(ext,runtime): add missing custom inspections (#21219)
Diffstat (limited to 'ext/web')
-rw-r--r-- | ext/web/01_dom_exception.js | 25 | ||||
-rw-r--r-- | ext/web/02_event.js | 189 | ||||
-rw-r--r-- | ext/web/03_abort_signal.js | 31 | ||||
-rw-r--r-- | ext/web/06_streams.js | 239 | ||||
-rw-r--r-- | ext/web/08_text_encoding.js | 66 | ||||
-rw-r--r-- | ext/web/09_file.js | 44 | ||||
-rw-r--r-- | ext/web/10_filereader.js | 18 | ||||
-rw-r--r-- | ext/web/12_location.js | 54 | ||||
-rw-r--r-- | ext/web/13_message_port.js | 31 | ||||
-rw-r--r-- | ext/web/14_compression.js | 37 | ||||
-rw-r--r-- | ext/web/15_performance.js | 107 |
11 files changed, 573 insertions, 268 deletions
diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js index d876d90a6..941b057e4 100644 --- a/ext/web/01_dom_exception.js +++ b/ext/web/01_dom_exception.js @@ -131,19 +131,22 @@ class DOMException { return this[_code]; } - [SymbolFor("Deno.customInspect")](inspect) { + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { if (ObjectPrototypeIsPrototypeOf(DOMExceptionPrototype, this)) { - return `DOMException: ${this[_message]}`; + return this[_error].stack; } else { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: false, - keys: [ - "message", - "name", - "code", - ], - })); + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: false, + keys: [ + "message", + "name", + "code", + ], + }), + inspectOptions, + ); } } } diff --git a/ext/web/02_event.js b/ext/web/02_event.js index 8831d37fb..3690f62b7 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -158,12 +158,15 @@ class Event { }; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(Event.prototype, this), - keys: EVENT_PROPS, - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(EventPrototype, this), + keys: EVENT_PROPS, + }), + inspectOptions, + ); } get type() { @@ -385,6 +388,8 @@ class Event { } } +const EventPrototype = Event.prototype; + // Not spec compliant. The spec defines it as [LegacyUnforgeable] // but doing so has a big performance hit ReflectDefineProperty(Event.prototype, "isTrusted", { @@ -1042,6 +1047,10 @@ class EventTarget { getParent(_event) { return null; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return `${this.constructor.name} ${inspect({}, inspectOptions)}`; + } } webidl.configureInterface(EventTarget); @@ -1102,25 +1111,30 @@ class ErrorEvent extends Event { this.#error = error; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, this), - keys: [ - ...new SafeArrayIterator(EVENT_PROPS), - "message", - "filename", - "lineno", - "colno", - "error", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(ErrorEventPrototype, this), + keys: [ + ...new SafeArrayIterator(EVENT_PROPS), + "message", + "filename", + "lineno", + "colno", + "error", + ], + }), + inspectOptions, + ); } // TODO(lucacasonato): remove when this interface is spec aligned [SymbolToStringTag] = "ErrorEvent"; } +const ErrorEventPrototype = ErrorEvent.prototype; + defineEnumerableProps(ErrorEvent, [ "message", "filename", @@ -1163,20 +1177,25 @@ class CloseEvent extends Event { this.#reason = reason; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(CloseEvent.prototype, this), - keys: [ - ...new SafeArrayIterator(EVENT_PROPS), - "wasClean", - "code", - "reason", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(CloseEventPrototype, this), + keys: [ + ...new SafeArrayIterator(EVENT_PROPS), + "wasClean", + "code", + "reason", + ], + }), + inspectOptions, + ); } } +const CloseEventPrototype = CloseEvent.prototype; + class MessageEvent extends Event { get source() { return null; @@ -1195,23 +1214,28 @@ class MessageEvent extends Event { this.lastEventId = eventInitDict?.lastEventId ?? ""; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(MessageEvent.prototype, this), - keys: [ - ...new SafeArrayIterator(EVENT_PROPS), - "data", - "origin", - "lastEventId", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(MessageEventPrototype, this), + keys: [ + ...new SafeArrayIterator(EVENT_PROPS), + "data", + "origin", + "lastEventId", + ], + }), + inspectOptions, + ); } // TODO(lucacasonato): remove when this interface is spec aligned [SymbolToStringTag] = "CloseEvent"; } +const MessageEventPrototype = MessageEvent.prototype; + class CustomEvent extends Event { #detail = null; @@ -1230,21 +1254,26 @@ class CustomEvent extends Event { return this.#detail; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(CustomEvent.prototype, this), - keys: [ - ...new SafeArrayIterator(EVENT_PROPS), - "detail", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(CustomEventPrototype, this), + keys: [ + ...new SafeArrayIterator(EVENT_PROPS), + "detail", + ], + }), + inspectOptions, + ); } // TODO(lucacasonato): remove when this interface is spec aligned [SymbolToStringTag] = "CustomEvent"; } +const CustomEventPrototype = CustomEvent.prototype; + ReflectDefineProperty(CustomEvent.prototype, "detail", { enumerable: true, }); @@ -1260,23 +1289,28 @@ class ProgressEvent extends Event { this.total = eventInitDict?.total ?? 0; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(ProgressEvent.prototype, this), - keys: [ - ...new SafeArrayIterator(EVENT_PROPS), - "lengthComputable", - "loaded", - "total", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(ProgressEventPrototype, this), + keys: [ + ...new SafeArrayIterator(EVENT_PROPS), + "lengthComputable", + "loaded", + "total", + ], + }), + inspectOptions, + ); } // TODO(lucacasonato): remove when this interface is spec aligned [SymbolToStringTag] = "ProgressEvent"; } +const ProgressEventPrototype = ProgressEvent.prototype; + class PromiseRejectionEvent extends Event { #promise = null; #reason = null; @@ -1308,25 +1342,30 @@ class PromiseRejectionEvent extends Event { this.#reason = reason; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - PromiseRejectionEvent.prototype, - this, - ), - keys: [ - ...new SafeArrayIterator(EVENT_PROPS), - "promise", - "reason", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + PromiseRejectionEventPrototype, + this, + ), + keys: [ + ...new SafeArrayIterator(EVENT_PROPS), + "promise", + "reason", + ], + }), + inspectOptions, + ); } // TODO(lucacasonato): remove when this interface is spec aligned [SymbolToStringTag] = "PromiseRejectionEvent"; } +const PromiseRejectionEventPrototype = PromiseRejectionEvent.prototype; + defineEnumerableProps(PromiseRejectionEvent, [ "promise", "reason", @@ -1342,7 +1381,7 @@ function makeWrappedHandler(handler, isSpecialErrorEventHandler) { if ( isSpecialErrorEventHandler && - ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, evt) && + ObjectPrototypeIsPrototypeOf(ErrorEventPrototype, evt) && evt.type === "error" ) { const ret = FunctionPrototypeCall( diff --git a/ext/web/03_abort_signal.js b/ext/web/03_abort_signal.js index a237b273c..f534ec04f 100644 --- a/ext/web/03_abort_signal.js +++ b/ext/web/03_abort_signal.js @@ -5,6 +5,7 @@ import * as webidl from "ext:deno_webidl/00_webidl.js"; import { assert } from "ext:deno_web/00_infra.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { defineEventHandler, Event, @@ -16,6 +17,7 @@ const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeEvery, ArrayPrototypePush, + ObjectPrototypeIsPrototypeOf, SafeArrayIterator, SafeSet, SafeSetIterator, @@ -24,6 +26,7 @@ const { SetPrototypeAdd, SetPrototypeDelete, Symbol, + SymbolFor, TypeError, WeakRefPrototypeDeref, WeakSetPrototypeAdd, @@ -238,6 +241,21 @@ class AbortSignal extends EventTarget { } } } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(AbortSignalPrototype, this), + keys: [ + "aborted", + "reason", + "onabort", + ], + }), + inspectOptions, + ); + } } defineEventHandler(AbortSignal.prototype, "abort"); @@ -260,6 +278,19 @@ class AbortController { webidl.assertBranded(this, AbortControllerPrototype); this[signal][signalAbort](reason); } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(AbortControllerPrototype, this), + keys: [ + "signal", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(AbortController); diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 7ce045e68..b0fa4393f 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -4977,18 +4977,21 @@ class ByteLengthQueuingStrategy { return WeakMapPrototypeGet(byteSizeFunctionWeakMap, this[_globalObject]); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - ByteLengthQueuingStrategyPrototype, - this, - ), - keys: [ - "highWaterMark", - "size", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + ByteLengthQueuingStrategyPrototype, + this, + ), + keys: [ + "highWaterMark", + "size", + ], + }), + inspectOptions, + ); } } @@ -5031,18 +5034,21 @@ class CountQueuingStrategy { return WeakMapPrototypeGet(countSizeFunctionWeakMap, this[_globalObject]); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - CountQueuingStrategyPrototype, - this, - ), - keys: [ - "highWaterMark", - "size", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + CountQueuingStrategyPrototype, + this, + ), + keys: [ + "highWaterMark", + "size", + ], + }), + inspectOptions, + ); } } @@ -5372,8 +5378,18 @@ class ReadableStream { return iterator; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return `${this.constructor.name} ${inspect({ locked: this.locked })}`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + ReadableStreamPrototype, + this, + ), + keys: ["locked"], + }), + inspectOptions, + ); } } @@ -5484,8 +5500,18 @@ class ReadableStreamDefaultReader { return readableStreamReaderGenericCancel(this, reason); } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return `${this.constructor.name} ${inspect({ closed: this.closed })}`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + ReadableStreamDefaultReaderPrototype, + this, + ), + keys: ["closed"], + }), + inspectOptions, + ); } } @@ -5621,8 +5647,18 @@ class ReadableStreamBYOBReader { return readableStreamReaderGenericCancel(this, reason); } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return `${this.constructor.name} ${inspect({ closed: this.closed })}`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + ReadableStreamBYOBReaderPrototype, + this, + ), + keys: ["closed"], + }), + inspectOptions, + ); } } @@ -5837,15 +5873,18 @@ class ReadableByteStreamController { readableByteStreamControllerError(this, e); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - ReadableByteStreamControllerPrototype, - this, - ), - keys: ["desiredSize"], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + ReadableByteStreamControllerPrototype, + this, + ), + keys: ["desiredSize"], + }), + inspectOptions, + ); } /** @@ -5987,15 +6026,18 @@ class ReadableStreamDefaultController { readableStreamDefaultControllerError(this, e); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - ReadableStreamDefaultController.prototype, - this, - ), - keys: ["desiredSize"], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + ReadableStreamDefaultControllerPrototype, + this, + ), + keys: ["desiredSize"], + }), + inspectOptions, + ); } /** @@ -6146,10 +6188,18 @@ class TransformStream { return this[_writable]; } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ readable: this.readable, writable: this.writable }) - }`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + TransformStreamPrototype, + this, + ), + keys: ["readable", "writable"], + }), + inspectOptions, + ); } } @@ -6215,15 +6265,18 @@ class TransformStreamDefaultController { transformStreamDefaultControllerTerminate(this); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - TransformStreamDefaultController.prototype, - this, - ), - keys: ["desiredSize"], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + TransformStreamDefaultControllerPrototype, + this, + ), + keys: ["desiredSize"], + }), + inspectOptions, + ); } } @@ -6363,8 +6416,18 @@ class WritableStream { return acquireWritableStreamDefaultWriter(this); } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - return `${this.constructor.name} ${inspect({ locked: this.locked })}`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + WritableStreamPrototype, + this, + ), + keys: ["locked"], + }), + inspectOptions, + ); } } @@ -6498,19 +6561,22 @@ class WritableStreamDefaultWriter { return writableStreamDefaultWriterWrite(this, chunk); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - WritableStreamDefaultWriter.prototype, - this, - ), - keys: [ - "closed", - "desiredSize", - "ready", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + WritableStreamDefaultWriterPrototype, + this, + ), + keys: [ + "closed", + "desiredSize", + "ready", + ], + }), + inspectOptions, + ); } } @@ -6569,15 +6635,18 @@ class WritableStreamDefaultController { writableStreamDefaultControllerError(this, e); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - WritableStreamDefaultController.prototype, - this, - ), - keys: [], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + WritableStreamDefaultControllerPrototype, + this, + ), + keys: ["signal"], + }), + inspectOptions, + ); } /** diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index 5f8391e12..81a3425ed 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -12,6 +12,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; const primordials = globalThis.__bootstrap.primordials; const { DataViewPrototypeGetBuffer, @@ -23,6 +24,7 @@ const { // SharedArrayBufferPrototype StringPrototypeCharCodeAt, StringPrototypeSlice, + SymbolFor, TypedArrayPrototypeSubarray, TypedArrayPrototypeGetBuffer, TypedArrayPrototypeGetByteLength, @@ -190,6 +192,21 @@ class TextDecoder { } } } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(TextDecoderPrototype, this), + keys: [ + "encoding", + "fatal", + "ignoreBOM", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(TextDecoder); @@ -247,6 +264,17 @@ class TextEncoder { written: encodeIntoBuf[1], }; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(TextEncoderPrototype, this), + keys: ["encoding"], + }), + inspectOptions, + ); + } } const encodeIntoBuf = new Uint32Array(2); @@ -342,6 +370,26 @@ class TextDecoderStream { webidl.assertBranded(this, TextDecoderStreamPrototype); return this.#transform.writable; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + TextDecoderStreamPrototype, + this, + ), + keys: [ + "encoding", + "fatal", + "ignoreBOM", + "readable", + "writable", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(TextDecoderStream); @@ -415,6 +463,24 @@ class TextEncoderStream { webidl.assertBranded(this, TextEncoderStreamPrototype); return this.#transform.writable; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + TextEncoderStreamPrototype, + this, + ), + keys: [ + "encoding", + "readable", + "writable", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(TextEncoderStream); diff --git a/ext/web/09_file.js b/ext/web/09_file.js index 30b91c053..7ee029d8a 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -416,15 +416,18 @@ class Blob { return TypedArrayPrototypeGetBuffer(buf); } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this), - keys: [ - "size", - "type", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this), + keys: [ + "size", + "type", + ], + }), + inspectOptions, + ); } } @@ -536,16 +539,19 @@ class File extends Blob { return this[_LastModified]; } - [SymbolFor("Deno.customInspect")](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this), - keys: [ - "name", - "size", - "type", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this), + keys: [ + "name", + "size", + "type", + ], + }), + inspectOptions, + ); } } diff --git a/ext/web/10_filereader.js b/ext/web/10_filereader.js index f7b88669b..07a5a38ec 100644 --- a/ext/web/10_filereader.js +++ b/ext/web/10_filereader.js @@ -13,6 +13,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; const primordials = globalThis.__bootstrap.primordials; import { forgivingBase64Encode } from "ext:deno_web/00_infra.js"; import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js"; @@ -26,10 +27,12 @@ const { MapPrototypeGet, MapPrototypeSet, ObjectDefineProperty, + ObjectPrototypeIsPrototypeOf, queueMicrotask, SafeArrayIterator, SafeMap, Symbol, + SymbolFor, TypedArrayPrototypeSet, TypedArrayPrototypeGetBuffer, TypedArrayPrototypeGetByteLength, @@ -430,6 +433,21 @@ class FileReader extends EventTarget { set onabort(value) { this.#setEventHandlerFor("abort", value); } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(FileReaderPrototype, this), + keys: [ + "error", + "readyState", + "result", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(FileReader); diff --git a/ext/web/12_location.js b/ext/web/12_location.js index c612ca743..f469e9093 100644 --- a/ext/web/12_location.js +++ b/ext/web/12_location.js @@ -180,19 +180,20 @@ class Location { enumerable: true, }, [SymbolFor("Deno.privateCustomInspect")]: { - value: function (inspect) { - const object = { - hash: this.hash, - host: this.host, - hostname: this.hostname, - href: this.href, - origin: this.origin, - pathname: this.pathname, - port: this.port, - protocol: this.protocol, - search: this.search, - }; - return `${this.constructor.name} ${inspect(object)}`; + value: function (inspect, inspectOptions) { + return `${this.constructor.name} ${ + inspect({ + hash: this.hash, + host: this.host, + hostname: this.hostname, + href: this.href, + origin: this.origin, + pathname: this.pathname, + port: this.port, + protocol: this.protocol, + search: this.search, + }, inspectOptions) + }`; }, }, }); @@ -337,19 +338,20 @@ ObjectDefineProperties(WorkerLocation.prototype, { configurable: true, }, [SymbolFor("Deno.privateCustomInspect")]: { - value: function (inspect) { - const object = { - hash: this.hash, - host: this.host, - hostname: this.hostname, - href: this.href, - origin: this.origin, - pathname: this.pathname, - port: this.port, - protocol: this.protocol, - search: this.search, - }; - return `${this.constructor.name} ${inspect(object)}`; + value: function (inspect, inspectOptions) { + return `${this.constructor.name} ${ + inspect({ + hash: this.hash, + host: this.host, + hostname: this.hostname, + href: this.href, + origin: this.origin, + pathname: this.pathname, + port: this.port, + protocol: this.protocol, + search: this.search, + }, inspectOptions) + }`; }, }, }); diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index 4b0404ab6..34f86f80c 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -9,6 +9,7 @@ const core = globalThis.Deno.core; const { InterruptedPrototype, ops } = core; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { defineEventHandler, EventTarget, @@ -57,10 +58,18 @@ class MessageChannel { return this.#port2; } - [SymbolFor("Deno.inspect")](inspect) { - return `MessageChannel ${ - inspect({ port1: this.port1, port2: this.port2 }) - }`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(MessageChannelPrototype, this), + keys: [ + "port1", + "port2", + ], + }), + inspectOptions, + ); } } @@ -181,6 +190,20 @@ class MessagePort extends EventTarget { this[_id] = null; } } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(MessagePortPrototype, this), + keys: [ + "onmessage", + "onmessageerror", + ], + }), + inspectOptions, + ); + } } defineEventHandler(MessagePort.prototype, "message", function (self) { diff --git a/ext/web/14_compression.js b/ext/web/14_compression.js index 1b6dd4964..0563861c2 100644 --- a/ext/web/14_compression.js +++ b/ext/web/14_compression.js @@ -9,9 +9,12 @@ const core = globalThis.Deno.core; const ops = core.ops; const primordials = globalThis.__bootstrap.primordials; const { + SymbolFor, + ObjectPrototypeIsPrototypeOf, TypedArrayPrototypeGetByteLength, } = primordials; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { TransformStream } from "ext:deno_web/06_streams.js"; webidl.converters.CompressionFormat = webidl.createEnumConverter( @@ -60,6 +63,23 @@ class CompressionStream { webidl.assertBranded(this, CompressionStreamPrototype); return this.#transform.writable; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + CompressionStreamPrototype, + this, + ), + keys: [ + "readable", + "writable", + ], + }), + inspectOptions, + ); + } } webidl.configureInterface(CompressionStream); @@ -102,6 +122,23 @@ class DecompressionStream { webidl.assertBranded(this, DecompressionStreamPrototype); return this.#transform.writable; } + + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + DecompressionStreamPrototype, + this, + ), + keys: [ + "readable", + "writable", + ], + }), + inspectOptions, + ); + } } function maybeEnqueue(controller, output) { diff --git a/ext/web/15_performance.js b/ext/web/15_performance.js index 9ec2cd376..4527ff00c 100644 --- a/ext/web/15_performance.js +++ b/ext/web/15_performance.js @@ -22,7 +22,6 @@ import { opNow } from "ext:deno_web/02_timers.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; const illegalConstructorKey = Symbol("illegalConstructorKey"); -const customInspect = SymbolFor("Deno.customInspect"); let performanceEntries = []; let timeOrigin; @@ -196,20 +195,23 @@ class PerformanceEntry { }; } - [customInspect](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - PerformanceEntryPrototype, - this, - ), - keys: [ - "name", - "entryType", - "startTime", - "duration", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + PerformanceEntryPrototype, + this, + ), + keys: [ + "name", + "entryType", + "startTime", + "duration", + ], + }), + inspectOptions, + ); } } webidl.configureInterface(PerformanceEntry); @@ -265,18 +267,21 @@ class PerformanceMark extends PerformanceEntry { }; } - [customInspect](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this), - keys: [ - "name", - "entryType", - "startTime", - "duration", - "detail", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this), + keys: [ + "name", + "entryType", + "startTime", + "duration", + "detail", + ], + }), + inspectOptions, + ); } } webidl.configureInterface(PerformanceMark); @@ -321,21 +326,24 @@ class PerformanceMeasure extends PerformanceEntry { }; } - [customInspect](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf( - PerformanceMeasurePrototype, - this, - ), - keys: [ - "name", - "entryType", - "startTime", - "duration", - "detail", - ], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf( + PerformanceMeasurePrototype, + this, + ), + keys: [ + "name", + "entryType", + "startTime", + "duration", + "detail", + ], + }), + inspectOptions, + ); } } webidl.configureInterface(PerformanceMeasure); @@ -569,12 +577,15 @@ class Performance extends EventTarget { }; } - [customInspect](inspect) { - return inspect(createFilteredInspectProxy({ - object: this, - evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this), - keys: [], - })); + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this), + keys: ["timeOrigin"], + }), + inspectOptions, + ); } } webidl.configureInterface(Performance); |