1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 16:49:18 -05:00

fix(ext,runtime): add missing custom inspections (#21219)

This commit is contained in:
Kenta Moriuchi 2023-11-19 17:13:38 +09:00 committed by GitHub
parent a7548afb58
commit c806fbdabe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 848 additions and 376 deletions

View file

@ -357,7 +357,7 @@ fn webstorage_location_shares_origin() {
.wait_with_output() .wait_with_output()
.unwrap(); .unwrap();
assert!(output.status.success()); assert!(output.status.success());
assert_eq!(output.stdout, b"Storage { length: 1, hello: \"deno\" }\n"); assert_eq!(output.stdout, b"Storage { hello: \"deno\", length: 1 }\n");
} }
// test to ensure that when a --config file is set, but no --location, that // test to ensure that when a --config file is set, but no --location, that
@ -384,7 +384,7 @@ fn webstorage_config_file() {
.new_command() .new_command()
.args("run --config run/webstorage/config_a.jsonc run/webstorage/logger.ts") .args("run --config run/webstorage/config_a.jsonc run/webstorage/logger.ts")
.run() .run()
.assert_matches_text("Storage { length: 1, hello: \"deno\" }\n"); .assert_matches_text("Storage { hello: \"deno\", length: 1 }\n");
} }
// tests to ensure `--config` does not effect persisted storage when a // tests to ensure `--config` does not effect persisted storage when a
@ -401,7 +401,7 @@ fn webstorage_location_precedes_config() {
context.new_command() context.new_command()
.args("run --location https://example.com/b.ts --config run/webstorage/config_b.jsonc run/webstorage/logger.ts") .args("run --location https://example.com/b.ts --config run/webstorage/config_b.jsonc run/webstorage/logger.ts")
.run() .run()
.assert_matches_text("Storage { length: 1, hello: \"deno\" }\n"); .assert_matches_text("Storage { hello: \"deno\", length: 1 }\n");
} }
// test to ensure that when there isn't a configuration or location, that the // test to ensure that when there isn't a configuration or location, that the
@ -426,7 +426,7 @@ fn webstorage_main_module() {
.new_command() .new_command()
.args("run run/webstorage/fixture.ts") .args("run run/webstorage/fixture.ts")
.run() .run()
.assert_matches_text("Storage { length: 1, hello: \"deno\" }\n"); .assert_matches_text("Storage { hello: \"deno\", length: 1 }\n");
} }
itest!(_075_import_local_query_hash { itest!(_075_import_local_query_hash {

View file

@ -1,5 +1,9 @@
[Object: null prototype] { [Object: null prototype] {
thrown: DOMException: foo, thrown: DOMException: foo
at new DOMException (ext:deno_web/01_dom_exception.js:[WILDCARD])
at [WILDCARD]
at Object.evalContext (ext:core/01_core.js:[WILDCARD])
at file:///[WILDCARD]/eval_context_throw_dom_exception.js:1:48,
isNativeError: true, isNativeError: true,
isCompileError: false isCompileError: false
} }

View file

@ -1,2 +1,2 @@
Storage {[WILDCARD] Storage {[WILDCARD]
Storage { length: 1, hello: "deno" } Storage { hello: "deno", length: 1 }

View file

@ -7,11 +7,8 @@ import {
} from "./test_util.ts"; } from "./test_util.ts";
Deno.test(function customInspectFunction() { Deno.test(function customInspectFunction() {
const blob = new DOMException("test"); const exception = new DOMException("test");
assertEquals( assertEquals(Deno.inspect(exception), exception.stack);
Deno.inspect(blob),
`DOMException: test`,
);
assertStringIncludes(Deno.inspect(DOMException.prototype), "DOMException"); assertStringIncludes(Deno.inspect(DOMException.prototype), "DOMException");
}); });

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { import {
defineEventHandler, defineEventHandler,
EventTarget, EventTarget,
@ -17,8 +18,10 @@ const {
ArrayPrototypeIndexOf, ArrayPrototypeIndexOf,
ArrayPrototypePush, ArrayPrototypePush,
ArrayPrototypeSplice, ArrayPrototypeSplice,
ObjectPrototypeIsPrototypeOf,
PromisePrototypeThen, PromisePrototypeThen,
Symbol, Symbol,
SymbolFor,
Uint8Array, Uint8Array,
} = primordials; } = primordials;
@ -141,6 +144,21 @@ class BroadcastChannel extends EventTarget {
ops.op_broadcast_unsubscribe(rid); ops.op_broadcast_unsubscribe(rid);
} }
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(BroadcastChannelPrototype, this),
keys: [
"name",
"onmessage",
"onmessageerror",
],
}),
inspectOptions,
);
}
} }
defineEventHandler(BroadcastChannel.prototype, "message"); defineEventHandler(BroadcastChannel.prototype, "message");

View file

@ -8,6 +8,7 @@ const {
StringPrototypeSplit, StringPrototypeSplit,
StringPrototypeTrim, StringPrototypeTrim,
Symbol, Symbol,
SymbolFor,
TypeError, TypeError,
} = primordials; } = primordials;
import { import {
@ -59,6 +60,10 @@ class CacheStorage {
cacheName = webidl.converters["DOMString"](cacheName, prefix, "Argument 1"); cacheName = webidl.converters["DOMString"](cacheName, prefix, "Argument 1");
return await op_cache_storage_delete(cacheName); return await op_cache_storage_delete(cacheName);
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
}
} }
const _matchAll = Symbol("[[matchAll]]"); const _matchAll = Symbol("[[matchAll]]");
@ -275,6 +280,10 @@ class Cache {
return responses; return responses;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
}
} }
webidl.configureInterface(CacheStorage); webidl.configureInterface(CacheStorage);

View file

@ -10,6 +10,7 @@ const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
const primordials = globalThis.__bootstrap.primordials; const primordials = globalThis.__bootstrap.primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import DOMException from "ext:deno_web/01_dom_exception.js"; import DOMException from "ext:deno_web/01_dom_exception.js";
const { const {
ArrayBufferIsView, ArrayBufferIsView,
@ -349,15 +350,20 @@ class CryptoKey {
return this[_algorithm]; return this[_algorithm];
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${ return inspect(
inspect({ createFilteredInspectProxy({
type: this.type, object: this,
extractable: this.extractable, evaluate: ObjectPrototypeIsPrototypeOf(CryptoKeyPrototype, this),
algorithm: this.algorithm, keys: [
usages: this.usages, "type",
}) "extractable",
}`; "algorithm",
"usages",
],
}),
inspectOptions,
);
} }
} }
@ -1710,6 +1716,10 @@ class SubtleCrypto {
return result; return result;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
}
} }
const SubtleCryptoPrototype = SubtleCrypto.prototype; const SubtleCryptoPrototype = SubtleCrypto.prototype;
@ -4730,8 +4740,15 @@ class Crypto {
return subtle; return subtle;
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({})}`; return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CryptoPrototype, this),
keys: ["subtle"],
}),
inspectOptions,
);
} }
} }

View file

@ -26,7 +26,9 @@ const {
ArrayPrototypeSort, ArrayPrototypeSort,
ArrayPrototypeJoin, ArrayPrototypeJoin,
ArrayPrototypeSplice, ArrayPrototypeSplice,
ObjectFromEntries,
ObjectHasOwn, ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest, RegExpPrototypeTest,
Symbol, Symbol,
SymbolFor, SymbolFor,
@ -441,13 +443,14 @@ class Headers {
} }
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
const headers = {}; if (ObjectPrototypeIsPrototypeOf(HeadersPrototype, this)) {
// deno-lint-ignore prefer-primordials return `${this.constructor.name} ${
for (const header of this) { inspect(ObjectFromEntries(this), inspectOptions)
headers[header[0]] = header[1]; }`;
} else {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
} }
return `Headers ${inspect(headers)}`;
} }
} }

View file

@ -26,10 +26,12 @@ const {
MapPrototypeSet, MapPrototypeSet,
MathRandom, MathRandom,
ObjectFreeze, ObjectFreeze,
ObjectFromEntries,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
SafeMap, SafeMap,
SafeRegExp, SafeRegExp,
Symbol, Symbol,
SymbolFor,
StringFromCharCode, StringFromCharCode,
StringPrototypeCharCodeAt, StringPrototypeCharCodeAt,
StringPrototypeTrim, StringPrototypeTrim,
@ -262,6 +264,16 @@ class FormData {
ArrayPrototypePush(list, entry); ArrayPrototypePush(list, entry);
} }
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
if (ObjectPrototypeIsPrototypeOf(FormDataPrototype, this)) {
return `${this.constructor.name} ${
inspect(ObjectFromEntries(this), inspectOptions)
}`;
} else {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
}
}
} }
webidl.mixinPairIterable("FormData", FormData, entryList, "name", "value"); webidl.mixinPairIterable("FormData", FormData, entryList, "name", "value");

View file

@ -483,18 +483,21 @@ class Request {
); );
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this),
"bodyUsed", keys: [
"headers", "bodyUsed",
"method", "headers",
"redirect", "method",
"url", "redirect",
], "url",
})); ],
}),
inspectOptions,
);
} }
} }

View file

@ -408,21 +408,24 @@ class Response {
return second; return second;
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this),
"body", keys: [
"bodyUsed", "body",
"headers", "bodyUsed",
"ok", "headers",
"redirected", "ok",
"status", "redirected",
"statusText", "status",
"url", "statusText",
], "url",
})); ],
}),
inspectOptions,
);
} }
} }

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { URL } from "ext:deno_url/00_url.js"; import { URL } from "ext:deno_url/00_url.js";
import DOMException from "ext:deno_web/01_dom_exception.js"; import DOMException from "ext:deno_web/01_dom_exception.js";
import { import {
@ -25,6 +26,7 @@ const {
NumberIsFinite, NumberIsFinite,
NumberIsNaN, NumberIsNaN,
ObjectDefineProperties, ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
Promise, Promise,
StringPrototypeEndsWith, StringPrototypeEndsWith,
StringPrototypeIncludes, StringPrototypeIncludes,
@ -34,6 +36,7 @@ const {
StringPrototypeStartsWith, StringPrototypeStartsWith,
StringPrototypeToLowerCase, StringPrototypeToLowerCase,
Symbol, Symbol,
SymbolFor,
} = primordials; } = primordials;
// Copied from https://github.com/denoland/deno_std/blob/e0753abe0c8602552862a568348c046996709521/streams/text_line_stream.ts#L20-L74 // Copied from https://github.com/denoland/deno_std/blob/e0753abe0c8602552862a568348c046996709521/streams/text_line_stream.ts#L20-L74
@ -345,6 +348,24 @@ class EventSource extends EventTarget {
} }
} }
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(EventSourcePrototype, this),
keys: [
"readyState",
"url",
"withCredentials",
"onopen",
"onmessage",
"onerror",
],
}),
inspectOptions,
);
}
} }
const EventSourcePrototype = EventSource.prototype; const EventSourcePrototype = EventSource.prototype;

View file

@ -8,6 +8,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js"; 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 primordials = globalThis.__bootstrap.primordials;
const { const {
ArrayIsArray, ArrayIsArray,
@ -17,6 +18,7 @@ const {
ArrayPrototypeSort, ArrayPrototypeSort,
ArrayPrototypeSplice, ArrayPrototypeSplice,
ObjectKeys, ObjectKeys,
ObjectPrototypeIsPrototypeOf,
SafeArrayIterator, SafeArrayIterator,
StringPrototypeSlice, StringPrototypeSlice,
StringPrototypeStartsWith, StringPrototypeStartsWith,
@ -410,20 +412,26 @@ class URL {
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
const object = { return inspect(
href: this.href, createFilteredInspectProxy({
origin: this.origin, object: this,
protocol: this.protocol, evaluate: ObjectPrototypeIsPrototypeOf(URLPrototype, this),
username: this.username, keys: [
password: this.password, "href",
host: this.host, "origin",
hostname: this.hostname, "protocol",
port: this.port, "username",
pathname: this.pathname, "password",
hash: this.hash, "host",
search: this.search, "hostname",
}; "port",
return `${this.constructor.name} ${inspect(object, inspectOptions)}`; "pathname",
"hash",
"search",
],
}),
inspectOptions,
);
} }
#updateSearchParams() { #updateSearchParams() {

View file

@ -10,11 +10,13 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js"; 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 primordials = globalThis.__bootstrap.primordials;
const { const {
ArrayPrototypePop, ArrayPrototypePop,
RegExpPrototypeExec, RegExpPrototypeExec,
RegExpPrototypeTest, RegExpPrototypeTest,
ObjectPrototypeIsPrototypeOf,
SafeRegExp, SafeRegExp,
Symbol, Symbol,
SymbolFor, SymbolFor,
@ -222,19 +224,24 @@ class URLPattern {
return result; return result;
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `URLPattern ${ return inspect(
inspect({ createFilteredInspectProxy({
protocol: this.protocol, object: this,
username: this.username, evaluate: ObjectPrototypeIsPrototypeOf(URLPatternPrototype, this),
password: this.password, keys: [
hostname: this.hostname, "protocol",
port: this.port, "username",
pathname: this.pathname, "password",
search: this.search, "hostname",
hash: this.hash, "port",
}) "pathname",
}`; "search",
"hash",
],
}),
inspectOptions,
);
} }
} }

View file

@ -131,19 +131,22 @@ class DOMException {
return this[_code]; return this[_code];
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
if (ObjectPrototypeIsPrototypeOf(DOMExceptionPrototype, this)) { if (ObjectPrototypeIsPrototypeOf(DOMExceptionPrototype, this)) {
return `DOMException: ${this[_message]}`; return this[_error].stack;
} else { } else {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: false, object: this,
keys: [ evaluate: false,
"message", keys: [
"name", "message",
"code", "name",
], "code",
})); ],
}),
inspectOptions,
);
} }
} }
} }

View file

@ -158,12 +158,15 @@ class Event {
}; };
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(Event.prototype, this), object: this,
keys: EVENT_PROPS, evaluate: ObjectPrototypeIsPrototypeOf(EventPrototype, this),
})); keys: EVENT_PROPS,
}),
inspectOptions,
);
} }
get type() { get type() {
@ -385,6 +388,8 @@ class Event {
} }
} }
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", {
@ -1042,6 +1047,10 @@ class EventTarget {
getParent(_event) { getParent(_event) {
return null; return null;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
}
} }
webidl.configureInterface(EventTarget); webidl.configureInterface(EventTarget);
@ -1102,25 +1111,30 @@ class ErrorEvent extends Event {
this.#error = error; this.#error = error;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(ErrorEventPrototype, this),
...new SafeArrayIterator(EVENT_PROPS), keys: [
"message", ...new SafeArrayIterator(EVENT_PROPS),
"filename", "message",
"lineno", "filename",
"colno", "lineno",
"error", "colno",
], "error",
})); ],
}),
inspectOptions,
);
} }
// TODO(lucacasonato): remove when this interface is spec aligned // TODO(lucacasonato): remove when this interface is spec aligned
[SymbolToStringTag] = "ErrorEvent"; [SymbolToStringTag] = "ErrorEvent";
} }
const ErrorEventPrototype = ErrorEvent.prototype;
defineEnumerableProps(ErrorEvent, [ defineEnumerableProps(ErrorEvent, [
"message", "message",
"filename", "filename",
@ -1163,20 +1177,25 @@ class CloseEvent extends Event {
this.#reason = reason; this.#reason = reason;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(CloseEvent.prototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(CloseEventPrototype, this),
...new SafeArrayIterator(EVENT_PROPS), keys: [
"wasClean", ...new SafeArrayIterator(EVENT_PROPS),
"code", "wasClean",
"reason", "code",
], "reason",
})); ],
}),
inspectOptions,
);
} }
} }
const CloseEventPrototype = CloseEvent.prototype;
class MessageEvent extends Event { class MessageEvent extends Event {
get source() { get source() {
return null; return null;
@ -1195,23 +1214,28 @@ class MessageEvent extends Event {
this.lastEventId = eventInitDict?.lastEventId ?? ""; this.lastEventId = eventInitDict?.lastEventId ?? "";
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(MessageEvent.prototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(MessageEventPrototype, this),
...new SafeArrayIterator(EVENT_PROPS), keys: [
"data", ...new SafeArrayIterator(EVENT_PROPS),
"origin", "data",
"lastEventId", "origin",
], "lastEventId",
})); ],
}),
inspectOptions,
);
} }
// TODO(lucacasonato): remove when this interface is spec aligned // TODO(lucacasonato): remove when this interface is spec aligned
[SymbolToStringTag] = "CloseEvent"; [SymbolToStringTag] = "CloseEvent";
} }
const MessageEventPrototype = MessageEvent.prototype;
class CustomEvent extends Event { class CustomEvent extends Event {
#detail = null; #detail = null;
@ -1230,21 +1254,26 @@ class CustomEvent extends Event {
return this.#detail; return this.#detail;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(CustomEvent.prototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(CustomEventPrototype, this),
...new SafeArrayIterator(EVENT_PROPS), keys: [
"detail", ...new SafeArrayIterator(EVENT_PROPS),
], "detail",
})); ],
}),
inspectOptions,
);
} }
// TODO(lucacasonato): remove when this interface is spec aligned // TODO(lucacasonato): remove when this interface is spec aligned
[SymbolToStringTag] = "CustomEvent"; [SymbolToStringTag] = "CustomEvent";
} }
const CustomEventPrototype = CustomEvent.prototype;
ReflectDefineProperty(CustomEvent.prototype, "detail", { ReflectDefineProperty(CustomEvent.prototype, "detail", {
enumerable: true, enumerable: true,
}); });
@ -1260,23 +1289,28 @@ class ProgressEvent extends Event {
this.total = eventInitDict?.total ?? 0; this.total = eventInitDict?.total ?? 0;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(ProgressEvent.prototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(ProgressEventPrototype, this),
...new SafeArrayIterator(EVENT_PROPS), keys: [
"lengthComputable", ...new SafeArrayIterator(EVENT_PROPS),
"loaded", "lengthComputable",
"total", "loaded",
], "total",
})); ],
}),
inspectOptions,
);
} }
// TODO(lucacasonato): remove when this interface is spec aligned // TODO(lucacasonato): remove when this interface is spec aligned
[SymbolToStringTag] = "ProgressEvent"; [SymbolToStringTag] = "ProgressEvent";
} }
const ProgressEventPrototype = ProgressEvent.prototype;
class PromiseRejectionEvent extends Event { class PromiseRejectionEvent extends Event {
#promise = null; #promise = null;
#reason = null; #reason = null;
@ -1308,25 +1342,30 @@ class PromiseRejectionEvent extends Event {
this.#reason = reason; this.#reason = reason;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
PromiseRejectionEvent.prototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, PromiseRejectionEventPrototype,
), this,
keys: [ ),
...new SafeArrayIterator(EVENT_PROPS), keys: [
"promise", ...new SafeArrayIterator(EVENT_PROPS),
"reason", "promise",
], "reason",
})); ],
}),
inspectOptions,
);
} }
// TODO(lucacasonato): remove when this interface is spec aligned // TODO(lucacasonato): remove when this interface is spec aligned
[SymbolToStringTag] = "PromiseRejectionEvent"; [SymbolToStringTag] = "PromiseRejectionEvent";
} }
const PromiseRejectionEventPrototype = PromiseRejectionEvent.prototype;
defineEnumerableProps(PromiseRejectionEvent, [ defineEnumerableProps(PromiseRejectionEvent, [
"promise", "promise",
"reason", "reason",
@ -1342,7 +1381,7 @@ function makeWrappedHandler(handler, isSpecialErrorEventHandler) {
if ( if (
isSpecialErrorEventHandler && isSpecialErrorEventHandler &&
ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, evt) && ObjectPrototypeIsPrototypeOf(ErrorEventPrototype, evt) &&
evt.type === "error" evt.type === "error"
) { ) {
const ret = FunctionPrototypeCall( const ret = FunctionPrototypeCall(

View file

@ -5,6 +5,7 @@
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { assert } from "ext:deno_web/00_infra.js"; import { assert } from "ext:deno_web/00_infra.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { import {
defineEventHandler, defineEventHandler,
Event, Event,
@ -16,6 +17,7 @@ const primordials = globalThis.__bootstrap.primordials;
const { const {
ArrayPrototypeEvery, ArrayPrototypeEvery,
ArrayPrototypePush, ArrayPrototypePush,
ObjectPrototypeIsPrototypeOf,
SafeArrayIterator, SafeArrayIterator,
SafeSet, SafeSet,
SafeSetIterator, SafeSetIterator,
@ -24,6 +26,7 @@ const {
SetPrototypeAdd, SetPrototypeAdd,
SetPrototypeDelete, SetPrototypeDelete,
Symbol, Symbol,
SymbolFor,
TypeError, TypeError,
WeakRefPrototypeDeref, WeakRefPrototypeDeref,
WeakSetPrototypeAdd, 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"); defineEventHandler(AbortSignal.prototype, "abort");
@ -260,6 +278,19 @@ class AbortController {
webidl.assertBranded(this, AbortControllerPrototype); webidl.assertBranded(this, AbortControllerPrototype);
this[signal][signalAbort](reason); this[signal][signalAbort](reason);
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(AbortControllerPrototype, this),
keys: [
"signal",
],
}),
inspectOptions,
);
}
} }
webidl.configureInterface(AbortController); webidl.configureInterface(AbortController);

View file

@ -4977,18 +4977,21 @@ class ByteLengthQueuingStrategy {
return WeakMapPrototypeGet(byteSizeFunctionWeakMap, this[_globalObject]); return WeakMapPrototypeGet(byteSizeFunctionWeakMap, this[_globalObject]);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
ByteLengthQueuingStrategyPrototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, ByteLengthQueuingStrategyPrototype,
), this,
keys: [ ),
"highWaterMark", keys: [
"size", "highWaterMark",
], "size",
})); ],
}),
inspectOptions,
);
} }
} }
@ -5031,18 +5034,21 @@ class CountQueuingStrategy {
return WeakMapPrototypeGet(countSizeFunctionWeakMap, this[_globalObject]); return WeakMapPrototypeGet(countSizeFunctionWeakMap, this[_globalObject]);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
CountQueuingStrategyPrototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, CountQueuingStrategyPrototype,
), this,
keys: [ ),
"highWaterMark", keys: [
"size", "highWaterMark",
], "size",
})); ],
}),
inspectOptions,
);
} }
} }
@ -5372,8 +5378,18 @@ class ReadableStream {
return iterator; return iterator;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({ locked: this.locked })}`; return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamPrototype,
this,
),
keys: ["locked"],
}),
inspectOptions,
);
} }
} }
@ -5484,8 +5500,18 @@ class ReadableStreamDefaultReader {
return readableStreamReaderGenericCancel(this, reason); return readableStreamReaderGenericCancel(this, reason);
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({ closed: this.closed })}`; return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamDefaultReaderPrototype,
this,
),
keys: ["closed"],
}),
inspectOptions,
);
} }
} }
@ -5621,8 +5647,18 @@ class ReadableStreamBYOBReader {
return readableStreamReaderGenericCancel(this, reason); return readableStreamReaderGenericCancel(this, reason);
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({ closed: this.closed })}`; return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamBYOBReaderPrototype,
this,
),
keys: ["closed"],
}),
inspectOptions,
);
} }
} }
@ -5837,15 +5873,18 @@ class ReadableByteStreamController {
readableByteStreamControllerError(this, e); readableByteStreamControllerError(this, e);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
ReadableByteStreamControllerPrototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, ReadableByteStreamControllerPrototype,
), this,
keys: ["desiredSize"], ),
})); keys: ["desiredSize"],
}),
inspectOptions,
);
} }
/** /**
@ -5987,15 +6026,18 @@ class ReadableStreamDefaultController {
readableStreamDefaultControllerError(this, e); readableStreamDefaultControllerError(this, e);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
ReadableStreamDefaultController.prototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, ReadableStreamDefaultControllerPrototype,
), this,
keys: ["desiredSize"], ),
})); keys: ["desiredSize"],
}),
inspectOptions,
);
} }
/** /**
@ -6146,10 +6188,18 @@ class TransformStream {
return this[_writable]; return this[_writable];
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${ return inspect(
inspect({ readable: this.readable, writable: this.writable }) createFilteredInspectProxy({
}`; object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TransformStreamPrototype,
this,
),
keys: ["readable", "writable"],
}),
inspectOptions,
);
} }
} }
@ -6215,15 +6265,18 @@ class TransformStreamDefaultController {
transformStreamDefaultControllerTerminate(this); transformStreamDefaultControllerTerminate(this);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
TransformStreamDefaultController.prototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, TransformStreamDefaultControllerPrototype,
), this,
keys: ["desiredSize"], ),
})); keys: ["desiredSize"],
}),
inspectOptions,
);
} }
} }
@ -6363,8 +6416,18 @@ class WritableStream {
return acquireWritableStreamDefaultWriter(this); return acquireWritableStreamDefaultWriter(this);
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({ locked: this.locked })}`; return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamPrototype,
this,
),
keys: ["locked"],
}),
inspectOptions,
);
} }
} }
@ -6498,19 +6561,22 @@ class WritableStreamDefaultWriter {
return writableStreamDefaultWriterWrite(this, chunk); return writableStreamDefaultWriterWrite(this, chunk);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
WritableStreamDefaultWriter.prototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, WritableStreamDefaultWriterPrototype,
), this,
keys: [ ),
"closed", keys: [
"desiredSize", "closed",
"ready", "desiredSize",
], "ready",
})); ],
}),
inspectOptions,
);
} }
} }
@ -6569,15 +6635,18 @@ class WritableStreamDefaultController {
writableStreamDefaultControllerError(this, e); writableStreamDefaultControllerError(this, e);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
WritableStreamDefaultController.prototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, WritableStreamDefaultControllerPrototype,
), this,
keys: [], ),
})); keys: ["signal"],
}),
inspectOptions,
);
} }
/** /**

View file

@ -12,6 +12,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js"; 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 primordials = globalThis.__bootstrap.primordials;
const { const {
DataViewPrototypeGetBuffer, DataViewPrototypeGetBuffer,
@ -23,6 +24,7 @@ const {
// SharedArrayBufferPrototype // SharedArrayBufferPrototype
StringPrototypeCharCodeAt, StringPrototypeCharCodeAt,
StringPrototypeSlice, StringPrototypeSlice,
SymbolFor,
TypedArrayPrototypeSubarray, TypedArrayPrototypeSubarray,
TypedArrayPrototypeGetBuffer, TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength, 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); webidl.configureInterface(TextDecoder);
@ -247,6 +264,17 @@ class TextEncoder {
written: encodeIntoBuf[1], 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); const encodeIntoBuf = new Uint32Array(2);
@ -342,6 +370,26 @@ class TextDecoderStream {
webidl.assertBranded(this, TextDecoderStreamPrototype); webidl.assertBranded(this, TextDecoderStreamPrototype);
return this.#transform.writable; 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); webidl.configureInterface(TextDecoderStream);
@ -415,6 +463,24 @@ class TextEncoderStream {
webidl.assertBranded(this, TextEncoderStreamPrototype); webidl.assertBranded(this, TextEncoderStreamPrototype);
return this.#transform.writable; 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); webidl.configureInterface(TextEncoderStream);

View file

@ -416,15 +416,18 @@ class Blob {
return TypedArrayPrototypeGetBuffer(buf); return TypedArrayPrototypeGetBuffer(buf);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this),
"size", keys: [
"type", "size",
], "type",
})); ],
}),
inspectOptions,
);
} }
} }
@ -536,16 +539,19 @@ class File extends Blob {
return this[_LastModified]; return this[_LastModified];
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this),
"name", keys: [
"size", "name",
"type", "size",
], "type",
})); ],
}),
inspectOptions,
);
} }
} }

View file

@ -13,6 +13,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js"; 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 primordials = globalThis.__bootstrap.primordials;
import { forgivingBase64Encode } from "ext:deno_web/00_infra.js"; import { forgivingBase64Encode } from "ext:deno_web/00_infra.js";
import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js"; import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js";
@ -26,10 +27,12 @@ const {
MapPrototypeGet, MapPrototypeGet,
MapPrototypeSet, MapPrototypeSet,
ObjectDefineProperty, ObjectDefineProperty,
ObjectPrototypeIsPrototypeOf,
queueMicrotask, queueMicrotask,
SafeArrayIterator, SafeArrayIterator,
SafeMap, SafeMap,
Symbol, Symbol,
SymbolFor,
TypedArrayPrototypeSet, TypedArrayPrototypeSet,
TypedArrayPrototypeGetBuffer, TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength, TypedArrayPrototypeGetByteLength,
@ -430,6 +433,21 @@ class FileReader extends EventTarget {
set onabort(value) { set onabort(value) {
this.#setEventHandlerFor("abort", 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); webidl.configureInterface(FileReader);

View file

@ -180,19 +180,20 @@ class Location {
enumerable: true, enumerable: true,
}, },
[SymbolFor("Deno.privateCustomInspect")]: { [SymbolFor("Deno.privateCustomInspect")]: {
value: function (inspect) { value: function (inspect, inspectOptions) {
const object = { return `${this.constructor.name} ${
hash: this.hash, inspect({
host: this.host, hash: this.hash,
hostname: this.hostname, host: this.host,
href: this.href, hostname: this.hostname,
origin: this.origin, href: this.href,
pathname: this.pathname, origin: this.origin,
port: this.port, pathname: this.pathname,
protocol: this.protocol, port: this.port,
search: this.search, protocol: this.protocol,
}; search: this.search,
return `${this.constructor.name} ${inspect(object)}`; }, inspectOptions)
}`;
}, },
}, },
}); });
@ -337,19 +338,20 @@ ObjectDefineProperties(WorkerLocation.prototype, {
configurable: true, configurable: true,
}, },
[SymbolFor("Deno.privateCustomInspect")]: { [SymbolFor("Deno.privateCustomInspect")]: {
value: function (inspect) { value: function (inspect, inspectOptions) {
const object = { return `${this.constructor.name} ${
hash: this.hash, inspect({
host: this.host, hash: this.hash,
hostname: this.hostname, host: this.host,
href: this.href, hostname: this.hostname,
origin: this.origin, href: this.href,
pathname: this.pathname, origin: this.origin,
port: this.port, pathname: this.pathname,
protocol: this.protocol, port: this.port,
search: this.search, protocol: this.protocol,
}; search: this.search,
return `${this.constructor.name} ${inspect(object)}`; }, inspectOptions)
}`;
}, },
}, },
}); });

View file

@ -9,6 +9,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const { InterruptedPrototype, ops } = core; const { InterruptedPrototype, ops } = core;
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { import {
defineEventHandler, defineEventHandler,
EventTarget, EventTarget,
@ -57,10 +58,18 @@ class MessageChannel {
return this.#port2; return this.#port2;
} }
[SymbolFor("Deno.inspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `MessageChannel ${ return inspect(
inspect({ port1: this.port1, port2: this.port2 }) createFilteredInspectProxy({
}`; object: this,
evaluate: ObjectPrototypeIsPrototypeOf(MessageChannelPrototype, this),
keys: [
"port1",
"port2",
],
}),
inspectOptions,
);
} }
} }
@ -181,6 +190,20 @@ class MessagePort extends EventTarget {
this[_id] = null; 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) { defineEventHandler(MessagePort.prototype, "message", function (self) {

View file

@ -9,9 +9,12 @@ const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
const primordials = globalThis.__bootstrap.primordials; const primordials = globalThis.__bootstrap.primordials;
const { const {
SymbolFor,
ObjectPrototypeIsPrototypeOf,
TypedArrayPrototypeGetByteLength, TypedArrayPrototypeGetByteLength,
} = primordials; } = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js"; 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"; import { TransformStream } from "ext:deno_web/06_streams.js";
webidl.converters.CompressionFormat = webidl.createEnumConverter( webidl.converters.CompressionFormat = webidl.createEnumConverter(
@ -60,6 +63,23 @@ class CompressionStream {
webidl.assertBranded(this, CompressionStreamPrototype); webidl.assertBranded(this, CompressionStreamPrototype);
return this.#transform.writable; 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); webidl.configureInterface(CompressionStream);
@ -102,6 +122,23 @@ class DecompressionStream {
webidl.assertBranded(this, DecompressionStreamPrototype); webidl.assertBranded(this, DecompressionStreamPrototype);
return this.#transform.writable; 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) { function maybeEnqueue(controller, output) {

View file

@ -22,7 +22,6 @@ import { opNow } from "ext:deno_web/02_timers.js";
import DOMException from "ext:deno_web/01_dom_exception.js"; import DOMException from "ext:deno_web/01_dom_exception.js";
const illegalConstructorKey = Symbol("illegalConstructorKey"); const illegalConstructorKey = Symbol("illegalConstructorKey");
const customInspect = SymbolFor("Deno.customInspect");
let performanceEntries = []; let performanceEntries = [];
let timeOrigin; let timeOrigin;
@ -196,20 +195,23 @@ class PerformanceEntry {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
PerformanceEntryPrototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, PerformanceEntryPrototype,
), this,
keys: [ ),
"name", keys: [
"entryType", "name",
"startTime", "entryType",
"duration", "startTime",
], "duration",
})); ],
}),
inspectOptions,
);
} }
} }
webidl.configureInterface(PerformanceEntry); webidl.configureInterface(PerformanceEntry);
@ -265,18 +267,21 @@ class PerformanceMark extends PerformanceEntry {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this), object: this,
keys: [ evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this),
"name", keys: [
"entryType", "name",
"startTime", "entryType",
"duration", "startTime",
"detail", "duration",
], "detail",
})); ],
}),
inspectOptions,
);
} }
} }
webidl.configureInterface(PerformanceMark); webidl.configureInterface(PerformanceMark);
@ -321,21 +326,24 @@ class PerformanceMeasure extends PerformanceEntry {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf( object: this,
PerformanceMeasurePrototype, evaluate: ObjectPrototypeIsPrototypeOf(
this, PerformanceMeasurePrototype,
), this,
keys: [ ),
"name", keys: [
"entryType", "name",
"startTime", "entryType",
"duration", "startTime",
"detail", "duration",
], "detail",
})); ],
}),
inspectOptions,
);
} }
} }
webidl.configureInterface(PerformanceMeasure); webidl.configureInterface(PerformanceMeasure);
@ -569,12 +577,15 @@ class Performance extends EventTarget {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
object: this, createFilteredInspectProxy({
evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this), object: this,
keys: [], evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this),
})); keys: ["timeOrigin"],
}),
inspectOptions,
);
} }
} }
webidl.configureInterface(Performance); webidl.configureInterface(Performance);

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
import { URL } from "ext:deno_url/00_url.js"; import { URL } from "ext:deno_url/00_url.js";
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js"; import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js";
import DOMException from "ext:deno_web/01_dom_exception.js"; import DOMException from "ext:deno_web/01_dom_exception.js";
import { import {
@ -536,17 +537,26 @@ class WebSocket extends EventTarget {
} }
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${ return inspect(
inspect({ createFilteredInspectProxy({
url: this.url, object: this,
readyState: this.readyState, evaluate: ObjectPrototypeIsPrototypeOf(WebSocketPrototype, this),
extensions: this.extensions, keys: [
protocol: this.protocol, "url",
binaryType: this.binaryType, "readyState",
bufferedAmount: this.bufferedAmount, "extensions",
}) "protocol",
}`; "binaryType",
"bufferedAmount",
"onmessage",
"onerror",
"onclose",
"onopen",
],
}),
inspectOptions,
);
} }
} }

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core; const core = globalThis.Deno.core;
const ops = core.ops; const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js"; import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js";
import DOMException from "ext:deno_web/01_dom_exception.js"; import DOMException from "ext:deno_web/01_dom_exception.js";
import { add, remove } from "ext:deno_web/03_abort_signal.js"; import { add, remove } from "ext:deno_web/03_abort_signal.js";
@ -423,12 +424,19 @@ class WebSocketStream {
} }
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${ return inspect(
inspect({ createFilteredInspectProxy({
url: this.url, object: this,
}) evaluate: ObjectPrototypeIsPrototypeOf(WebSocketStreamPrototype, this),
}`; keys: [
"closed",
"opened",
"url",
],
}),
inspectOptions,
);
} }
} }

View file

@ -147,12 +147,15 @@ function createStorage(persistent) {
}, },
}); });
proxy[SymbolFor("Deno.customInspect")] = function (inspect) { storage[SymbolFor("Deno.privateCustomInspect")] = function (
inspect,
inspectOptions,
) {
return `${this.constructor.name} ${ return `${this.constructor.name} ${
inspect({ inspect({
length: this.length,
...ObjectFromEntries(ObjectEntries(proxy)), ...ObjectFromEntries(ObjectEntries(proxy)),
}) length: this.length,
}, inspectOptions)
}`; }`;
}; };

View file

@ -112,10 +112,10 @@ class PermissionStatus extends EventTarget {
return dispatched; return dispatched;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
const object = { state: this.state, onchange: this.onchange }; const object = { state: this.state, onchange: this.onchange };
if (this.partial) object.partial = this.partial; if (this.partial) object.partial = this.partial;
return `${this.constructor.name} ${inspect(object)}`; return `${this.constructor.name} ${inspect(object, inspectOptions)}`;
} }
} }

View file

@ -9,10 +9,12 @@ const {
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
String, String,
StringPrototypeStartsWith, StringPrototypeStartsWith,
SymbolFor,
SymbolIterator, SymbolIterator,
SymbolToStringTag, SymbolToStringTag,
} = primordials; } = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js"; import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { URL } from "ext:deno_url/00_url.js"; import { URL } from "ext:deno_url/00_url.js";
import { getLocationHref } from "ext:deno_web/12_location.js"; import { getLocationHref } from "ext:deno_web/12_location.js";
import { serializePermissions } from "ext:runtime/10_permissions.js"; import { serializePermissions } from "ext:runtime/10_permissions.js";
@ -242,9 +244,26 @@ class Worker extends EventTarget {
} }
} }
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WorkerPrototype, this),
keys: [
"onerror",
"onmessage",
"onmessageerror",
],
}),
inspectOptions,
);
}
[SymbolToStringTag] = "Worker"; [SymbolToStringTag] = "Worker";
} }
const WorkerPrototype = Worker.prototype;
defineEventHandler(Worker.prototype, "error"); defineEventHandler(Worker.prototype, "error");
defineEventHandler(Worker.prototype, "message"); defineEventHandler(Worker.prototype, "message");
defineEventHandler(Worker.prototype, "messageerror"); defineEventHandler(Worker.prototype, "messageerror");

View file

@ -5,6 +5,7 @@ const ops = core.ops;
const primordials = globalThis.__bootstrap.primordials; const primordials = globalThis.__bootstrap.primordials;
const { const {
ObjectDefineProperties, ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
SymbolFor, SymbolFor,
} = primordials; } = primordials;
@ -151,8 +152,20 @@ class Navigator {
webidl.illegalConstructor(); webidl.illegalConstructor();
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({})}`; return inspect(
console.createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(NavigatorPrototype, this),
keys: [
"hardwareConcurrency",
"userAgent",
"language",
"languages",
],
}),
inspectOptions,
);
} }
} }
@ -213,8 +226,20 @@ class WorkerNavigator {
webidl.illegalConstructor(); webidl.illegalConstructor();
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({})}`; return inspect(
console.createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WorkerNavigatorPrototype, this),
keys: [
"hardwareConcurrency",
"userAgent",
"language",
"languages",
],
}),
inspectOptions,
);
} }
} }