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/timers/02_performance.js | 42 +++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'extensions/timers') diff --git a/extensions/timers/02_performance.js b/extensions/timers/02_performance.js index b4cf5760b..f752ba933 100644 --- a/extensions/timers/02_performance.js +++ b/extensions/timers/02_performance.js @@ -16,6 +16,7 @@ } = window.__bootstrap.primordials; const { webidl, structuredClone } = window.__bootstrap; + const consoleInternal = window.__bootstrap.console; const { opNow } = window.__bootstrap.timers; const { DOMException } = window.__bootstrap.domException; @@ -175,7 +176,16 @@ } [customInspect](inspect) { - return `${this.constructor.name} ${inspect(this.toJSON())}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof PerformanceEntry, + keys: [ + "name", + "entryType", + "startTime", + "duration", + ], + })); } } webidl.configurePrototype(PerformanceEntry); @@ -235,7 +245,17 @@ } [customInspect](inspect) { - return `${this.constructor.name} ${inspect(this.toJSON())}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof PerformanceMark, + keys: [ + "name", + "entryType", + "startTime", + "duration", + "detail", + ], + })); } } webidl.configurePrototype(PerformanceMark); @@ -283,7 +303,17 @@ } [customInspect](inspect) { - return `${this.constructor.name} ${inspect(this.toJSON())}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof PerformanceMeasure, + keys: [ + "name", + "entryType", + "startTime", + "duration", + "detail", + ], + })); } } webidl.configurePrototype(PerformanceMeasure); @@ -516,7 +546,11 @@ } [customInspect](inspect) { - return `${this.constructor.name} ${inspect(this.toJSON())}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof Performance, + keys: [], + })); } get [SymbolToStringTag]() { -- cgit v1.2.3