From 5fa58c92165e23386b8ed3c3079103997fe1bef9 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 8 Jul 2021 09:43:36 -0400 Subject: fix: inspecting prototypes of built-ins with custom inspect implementations should not throw (#11308) --- extensions/web/01_dom_exception.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'extensions/web/01_dom_exception.js') diff --git a/extensions/web/01_dom_exception.js b/extensions/web/01_dom_exception.js index 90ddb267b..3e282d969 100644 --- a/extensions/web/01_dom_exception.js +++ b/extensions/web/01_dom_exception.js @@ -17,6 +17,7 @@ ObjectSetPrototypeOf, } = window.__bootstrap.primordials; const webidl = window.__bootstrap.webidl; + const consoleInternal = window.__bootstrap.console; // Defined in WebIDL 4.3. // https://heycam.github.io/webidl/#idl-DOMException @@ -109,8 +110,20 @@ return "DOMException"; } - [Symbol.for("Deno.customInspect")]() { - return `DOMException: ${this.#message}`; + [Symbol.for("Deno.customInspect")](inspect) { + if (this instanceof DOMException) { + return `DOMException: ${this.#message}`; + } else { + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: false, + keys: [ + "message", + "name", + "code", + ], + })); + } } } -- cgit v1.2.3