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,8 +483,9 @@ class Request {
); );
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this), evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this),
keys: [ keys: [
@ -494,7 +495,9 @@ class Request {
"redirect", "redirect",
"url", "url",
], ],
})); }),
inspectOptions,
);
} }
} }

View file

@ -408,8 +408,9 @@ class Response {
return second; return second;
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this), evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this),
keys: [ keys: [
@ -422,7 +423,9 @@ class Response {
"statusText", "statusText",
"url", "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,11 +131,12 @@ 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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: false, evaluate: false,
keys: [ keys: [
@ -143,7 +144,9 @@ class DOMException {
"name", "name",
"code", "code",
], ],
})); }),
inspectOptions,
);
} }
} }
} }

View file

@ -158,12 +158,15 @@ class Event {
}; };
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(Event.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(EventPrototype, this),
keys: EVENT_PROPS, 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,10 +1111,11 @@ class ErrorEvent extends Event {
this.#error = error; this.#error = error;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(ErrorEventPrototype, this),
keys: [ keys: [
...new SafeArrayIterator(EVENT_PROPS), ...new SafeArrayIterator(EVENT_PROPS),
"message", "message",
@ -1114,13 +1124,17 @@ class ErrorEvent extends Event {
"colno", "colno",
"error", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CloseEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(CloseEventPrototype, this),
keys: [ keys: [
...new SafeArrayIterator(EVENT_PROPS), ...new SafeArrayIterator(EVENT_PROPS),
"wasClean", "wasClean",
"code", "code",
"reason", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(MessageEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(MessageEventPrototype, this),
keys: [ keys: [
...new SafeArrayIterator(EVENT_PROPS), ...new SafeArrayIterator(EVENT_PROPS),
"data", "data",
"origin", "origin",
"lastEventId", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CustomEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(CustomEventPrototype, this),
keys: [ keys: [
...new SafeArrayIterator(EVENT_PROPS), ...new SafeArrayIterator(EVENT_PROPS),
"detail", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ProgressEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(ProgressEventPrototype, this),
keys: [ keys: [
...new SafeArrayIterator(EVENT_PROPS), ...new SafeArrayIterator(EVENT_PROPS),
"lengthComputable", "lengthComputable",
"loaded", "loaded",
"total", "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,11 +1342,12 @@ class PromiseRejectionEvent extends Event {
this.#reason = reason; this.#reason = reason;
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
PromiseRejectionEvent.prototype, PromiseRejectionEventPrototype,
this, this,
), ),
keys: [ keys: [
@ -1320,13 +1355,17 @@ class PromiseRejectionEvent extends Event {
"promise", "promise",
"reason", "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,8 +4977,9 @@ 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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
ByteLengthQueuingStrategyPrototype, ByteLengthQueuingStrategyPrototype,
@ -4988,7 +4989,9 @@ class ByteLengthQueuingStrategy {
"highWaterMark", "highWaterMark",
"size", "size",
], ],
})); }),
inspectOptions,
);
} }
} }
@ -5031,8 +5034,9 @@ 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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
CountQueuingStrategyPrototype, CountQueuingStrategyPrototype,
@ -5042,7 +5046,9 @@ class CountQueuingStrategy {
"highWaterMark", "highWaterMark",
"size", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
ReadableByteStreamControllerPrototype, ReadableByteStreamControllerPrototype,
this, 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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamDefaultController.prototype, ReadableStreamDefaultControllerPrototype,
this, 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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
TransformStreamDefaultController.prototype, TransformStreamDefaultControllerPrototype,
this, 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,11 +6561,12 @@ class WritableStreamDefaultWriter {
return writableStreamDefaultWriterWrite(this, chunk); return writableStreamDefaultWriterWrite(this, chunk);
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamDefaultWriter.prototype, WritableStreamDefaultWriterPrototype,
this, this,
), ),
keys: [ keys: [
@ -6510,7 +6574,9 @@ class WritableStreamDefaultWriter {
"desiredSize", "desiredSize",
"ready", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamDefaultController.prototype, WritableStreamDefaultControllerPrototype,
this, 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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this), evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this),
keys: [ keys: [
"size", "size",
"type", "type",
], ],
})); }),
inspectOptions,
);
} }
} }
@ -536,8 +539,9 @@ class File extends Blob {
return this[_LastModified]; return this[_LastModified];
} }
[SymbolFor("Deno.customInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this), evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this),
keys: [ keys: [
@ -545,7 +549,9 @@ class File extends Blob {
"size", "size",
"type", "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,8 +180,9 @@ 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} ${
inspect({
hash: this.hash, hash: this.hash,
host: this.host, host: this.host,
hostname: this.hostname, hostname: this.hostname,
@ -191,8 +192,8 @@ class Location {
port: this.port, port: this.port,
protocol: this.protocol, protocol: this.protocol,
search: this.search, search: this.search,
}; }, inspectOptions)
return `${this.constructor.name} ${inspect(object)}`; }`;
}, },
}, },
}); });
@ -337,8 +338,9 @@ 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} ${
inspect({
hash: this.hash, hash: this.hash,
host: this.host, host: this.host,
hostname: this.hostname, hostname: this.hostname,
@ -348,8 +350,8 @@ ObjectDefineProperties(WorkerLocation.prototype, {
port: this.port, port: this.port,
protocol: this.protocol, protocol: this.protocol,
search: this.search, search: this.search,
}; }, inspectOptions)
return `${this.constructor.name} ${inspect(object)}`; }`;
}, },
}, },
}); });

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,8 +195,9 @@ class PerformanceEntry {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceEntryPrototype, PerformanceEntryPrototype,
@ -209,7 +209,9 @@ class PerformanceEntry {
"startTime", "startTime",
"duration", "duration",
], ],
})); }),
inspectOptions,
);
} }
} }
webidl.configureInterface(PerformanceEntry); webidl.configureInterface(PerformanceEntry);
@ -265,8 +267,9 @@ class PerformanceMark extends PerformanceEntry {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this), evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this),
keys: [ keys: [
@ -276,7 +279,9 @@ class PerformanceMark extends PerformanceEntry {
"duration", "duration",
"detail", "detail",
], ],
})); }),
inspectOptions,
);
} }
} }
webidl.configureInterface(PerformanceMark); webidl.configureInterface(PerformanceMark);
@ -321,8 +326,9 @@ class PerformanceMeasure extends PerformanceEntry {
}; };
} }
[customInspect](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(createFilteredInspectProxy({ return inspect(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf( evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceMeasurePrototype, PerformanceMeasurePrototype,
@ -335,7 +341,9 @@ class PerformanceMeasure extends PerformanceEntry {
"duration", "duration",
"detail", "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(
createFilteredInspectProxy({
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this), evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this),
keys: [], 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,
);
} }
} }