1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -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 Bartek Iwańczuk
parent d36c7a2486
commit 5a9833c760
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
31 changed files with 848 additions and 376 deletions

View file

@ -357,7 +357,7 @@ fn webstorage_location_shares_origin() {
.wait_with_output()
.unwrap();
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
@ -384,7 +384,7 @@ fn webstorage_config_file() {
.new_command()
.args("run --config run/webstorage/config_a.jsonc run/webstorage/logger.ts")
.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
@ -401,7 +401,7 @@ fn webstorage_location_precedes_config() {
context.new_command()
.args("run --location https://example.com/b.ts --config run/webstorage/config_b.jsonc run/webstorage/logger.ts")
.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
@ -426,7 +426,7 @@ fn webstorage_main_module() {
.new_command()
.args("run run/webstorage/fixture.ts")
.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 {

View file

@ -1,5 +1,9 @@
[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,
isCompileError: false
}

View file

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

View file

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

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core;
const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import {
defineEventHandler,
EventTarget,
@ -17,8 +18,10 @@ const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
ArrayPrototypeSplice,
ObjectPrototypeIsPrototypeOf,
PromisePrototypeThen,
Symbol,
SymbolFor,
Uint8Array,
} = primordials;
@ -141,6 +144,21 @@ class BroadcastChannel extends EventTarget {
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");

View file

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

View file

@ -10,6 +10,7 @@ const core = globalThis.Deno.core;
const ops = core.ops;
const primordials = globalThis.__bootstrap.primordials;
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";
const {
ArrayBufferIsView,
@ -349,15 +350,20 @@ class CryptoKey {
return this[_algorithm];
}
[SymbolFor("Deno.customInspect")](inspect) {
return `${this.constructor.name} ${
inspect({
type: this.type,
extractable: this.extractable,
algorithm: this.algorithm,
usages: this.usages,
})
}`;
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CryptoKeyPrototype, this),
keys: [
"type",
"extractable",
"algorithm",
"usages",
],
}),
inspectOptions,
);
}
}
@ -1710,6 +1716,10 @@ class SubtleCrypto {
return result;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
}
}
const SubtleCryptoPrototype = SubtleCrypto.prototype;
@ -4730,8 +4740,15 @@ class Crypto {
return subtle;
}
[SymbolFor("Deno.customInspect")](inspect) {
return `${this.constructor.name} ${inspect({})}`;
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CryptoPrototype, this),
keys: ["subtle"],
}),
inspectOptions,
);
}
}

View file

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

View file

@ -26,10 +26,12 @@ const {
MapPrototypeSet,
MathRandom,
ObjectFreeze,
ObjectFromEntries,
ObjectPrototypeIsPrototypeOf,
SafeMap,
SafeRegExp,
Symbol,
SymbolFor,
StringFromCharCode,
StringPrototypeCharCodeAt,
StringPrototypeTrim,
@ -262,6 +264,16 @@ class FormData {
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");

View file

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

View file

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

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core;
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 DOMException from "ext:deno_web/01_dom_exception.js";
import {
@ -25,6 +26,7 @@ const {
NumberIsFinite,
NumberIsNaN,
ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
Promise,
StringPrototypeEndsWith,
StringPrototypeIncludes,
@ -34,6 +36,7 @@ const {
StringPrototypeStartsWith,
StringPrototypeToLowerCase,
Symbol,
SymbolFor,
} = primordials;
// 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;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -12,6 +12,7 @@
const core = globalThis.Deno.core;
const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
const primordials = globalThis.__bootstrap.primordials;
const {
DataViewPrototypeGetBuffer,
@ -23,6 +24,7 @@ const {
// SharedArrayBufferPrototype
StringPrototypeCharCodeAt,
StringPrototypeSlice,
SymbolFor,
TypedArrayPrototypeSubarray,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength,
@ -190,6 +192,21 @@ class TextDecoder {
}
}
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(TextDecoderPrototype, this),
keys: [
"encoding",
"fatal",
"ignoreBOM",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(TextDecoder);
@ -247,6 +264,17 @@ class TextEncoder {
written: encodeIntoBuf[1],
};
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(TextEncoderPrototype, this),
keys: ["encoding"],
}),
inspectOptions,
);
}
}
const encodeIntoBuf = new Uint32Array(2);
@ -342,6 +370,26 @@ class TextDecoderStream {
webidl.assertBranded(this, TextDecoderStreamPrototype);
return this.#transform.writable;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TextDecoderStreamPrototype,
this,
),
keys: [
"encoding",
"fatal",
"ignoreBOM",
"readable",
"writable",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(TextDecoderStream);
@ -415,6 +463,24 @@ class TextEncoderStream {
webidl.assertBranded(this, TextEncoderStreamPrototype);
return this.#transform.writable;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TextEncoderStreamPrototype,
this,
),
keys: [
"encoding",
"readable",
"writable",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(TextEncoderStream);

View file

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

View file

@ -13,6 +13,7 @@
const core = globalThis.Deno.core;
const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
const primordials = globalThis.__bootstrap.primordials;
import { forgivingBase64Encode } from "ext:deno_web/00_infra.js";
import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js";
@ -26,10 +27,12 @@ const {
MapPrototypeGet,
MapPrototypeSet,
ObjectDefineProperty,
ObjectPrototypeIsPrototypeOf,
queueMicrotask,
SafeArrayIterator,
SafeMap,
Symbol,
SymbolFor,
TypedArrayPrototypeSet,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength,
@ -430,6 +433,21 @@ class FileReader extends EventTarget {
set onabort(value) {
this.#setEventHandlerFor("abort", value);
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(FileReaderPrototype, this),
keys: [
"error",
"readyState",
"result",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(FileReader);

View file

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

View file

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

View file

@ -9,9 +9,12 @@ const core = globalThis.Deno.core;
const ops = core.ops;
const primordials = globalThis.__bootstrap.primordials;
const {
SymbolFor,
ObjectPrototypeIsPrototypeOf,
TypedArrayPrototypeGetByteLength,
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { TransformStream } from "ext:deno_web/06_streams.js";
webidl.converters.CompressionFormat = webidl.createEnumConverter(
@ -60,6 +63,23 @@ class CompressionStream {
webidl.assertBranded(this, CompressionStreamPrototype);
return this.#transform.writable;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
CompressionStreamPrototype,
this,
),
keys: [
"readable",
"writable",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(CompressionStream);
@ -102,6 +122,23 @@ class DecompressionStream {
webidl.assertBranded(this, DecompressionStreamPrototype);
return this.#transform.writable;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
DecompressionStreamPrototype,
this,
),
keys: [
"readable",
"writable",
],
}),
inspectOptions,
);
}
}
function maybeEnqueue(controller, output) {

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";
const illegalConstructorKey = Symbol("illegalConstructorKey");
const customInspect = SymbolFor("Deno.customInspect");
let performanceEntries = [];
let timeOrigin;
@ -196,20 +195,23 @@ class PerformanceEntry {
};
}
[customInspect](inspect) {
return inspect(createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceEntryPrototype,
this,
),
keys: [
"name",
"entryType",
"startTime",
"duration",
],
}));
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceEntryPrototype,
this,
),
keys: [
"name",
"entryType",
"startTime",
"duration",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(PerformanceEntry);
@ -265,18 +267,21 @@ class PerformanceMark extends PerformanceEntry {
};
}
[customInspect](inspect) {
return inspect(createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this),
keys: [
"name",
"entryType",
"startTime",
"duration",
"detail",
],
}));
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this),
keys: [
"name",
"entryType",
"startTime",
"duration",
"detail",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(PerformanceMark);
@ -321,21 +326,24 @@ class PerformanceMeasure extends PerformanceEntry {
};
}
[customInspect](inspect) {
return inspect(createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceMeasurePrototype,
this,
),
keys: [
"name",
"entryType",
"startTime",
"duration",
"detail",
],
}));
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceMeasurePrototype,
this,
),
keys: [
"name",
"entryType",
"startTime",
"duration",
"detail",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(PerformanceMeasure);
@ -569,12 +577,15 @@ class Performance extends EventTarget {
};
}
[customInspect](inspect) {
return inspect(createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this),
keys: [],
}));
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this),
keys: ["timeOrigin"],
}),
inspectOptions,
);
}
}
webidl.configureInterface(Performance);

View file

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

View file

@ -5,6 +5,7 @@
const core = globalThis.Deno.core;
const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js";
import DOMException from "ext:deno_web/01_dom_exception.js";
import { add, remove } from "ext:deno_web/03_abort_signal.js";
@ -423,12 +424,19 @@ class WebSocketStream {
}
}
[SymbolFor("Deno.customInspect")](inspect) {
return `${this.constructor.name} ${
inspect({
url: this.url,
})
}`;
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
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} ${
inspect({
length: this.length,
...ObjectFromEntries(ObjectEntries(proxy)),
})
length: this.length,
}, inspectOptions)
}`;
};

View file

@ -112,10 +112,10 @@ class PermissionStatus extends EventTarget {
return dispatched;
}
[SymbolFor("Deno.privateCustomInspect")](inspect) {
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
const object = { state: this.state, onchange: this.onchange };
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,
String,
StringPrototypeStartsWith,
SymbolFor,
SymbolIterator,
SymbolToStringTag,
} = primordials;
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 { getLocationHref } from "ext:deno_web/12_location.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";
}
const WorkerPrototype = Worker.prototype;
defineEventHandler(Worker.prototype, "error");
defineEventHandler(Worker.prototype, "message");
defineEventHandler(Worker.prototype, "messageerror");

View file

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