diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-07-08 09:43:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-08 09:43:36 -0400 |
commit | 5fa58c92165e23386b8ed3c3079103997fe1bef9 (patch) | |
tree | d7efc34a11322d10f2749b5083cd84fa1b4a18d6 /extensions/web/06_streams.js | |
parent | 5e092b19fe113bdecd36b4e0184c82f4b3343bca (diff) |
fix: inspecting prototypes of built-ins with custom inspect implementations should not throw (#11308)
Diffstat (limited to 'extensions/web/06_streams.js')
-rw-r--r-- | extensions/web/06_streams.js | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/extensions/web/06_streams.js b/extensions/web/06_streams.js index 388b7b13c..ff6c9d7d8 100644 --- a/extensions/web/06_streams.js +++ b/extensions/web/06_streams.js @@ -36,6 +36,7 @@ WeakMapPrototypeHas, WeakMapPrototypeSet, } = globalThis.__bootstrap.primordials; + const consoleInternal = window.__bootstrap.console; const { DOMException } = window.__bootstrap.domException; class AssertionError extends Error { @@ -3018,9 +3019,14 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ highWaterMark: this.highWaterMark, size: this.size }) - }`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof ByteLengthQueuingStrategy, + keys: [ + "highWaterMark", + "size", + ], + })); } get [Symbol.toStringTag]() { @@ -3069,9 +3075,14 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ highWaterMark: this.highWaterMark, size: this.size }) - }`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof CountQueuingStrategy, + keys: [ + "highWaterMark", + "size", + ], + })); } get [Symbol.toStringTag]() { @@ -3561,9 +3572,11 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ desiredSize: this.desiredSize }) - }`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof ReadableByteStreamController, + keys: ["desiredSize"], + })); } get [Symbol.toStringTag]() { @@ -3684,9 +3697,11 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ desiredSize: this.desiredSize }) - }`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof ReadableStreamDefaultController, + keys: ["desiredSize"], + })); } get [Symbol.toStringTag]() { @@ -3905,9 +3920,11 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ desiredSize: this.desiredSize }) - }`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof TransformStreamDefaultController, + keys: ["desiredSize"], + })); } get [Symbol.toStringTag]() { @@ -4182,13 +4199,15 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${ - inspect({ - closed: this.closed, - desiredSize: this.desiredSize, - ready: this.ready, - }) - }`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof WritableStreamDefaultWriter, + keys: [ + "closed", + "desiredSize", + "ready", + ], + })); } get [Symbol.toStringTag]() { @@ -4240,7 +4259,11 @@ } [Symbol.for("Deno.customInspect")](inspect) { - return `${this.constructor.name} ${inspect({})}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof WritableStreamDefaultController, + keys: [], + })); } get [Symbol.toStringTag]() { |