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/fetch | |
parent | 5e092b19fe113bdecd36b4e0184c82f4b3343bca (diff) |
fix: inspecting prototypes of built-ins with custom inspect implementations should not throw (#11308)
Diffstat (limited to 'extensions/fetch')
-rw-r--r-- | extensions/fetch/23_request.js | 20 | ||||
-rw-r--r-- | extensions/fetch/23_response.js | 26 |
2 files changed, 27 insertions, 19 deletions
diff --git a/extensions/fetch/23_request.js b/extensions/fetch/23_request.js index 829f7e6dc..1372125c1 100644 --- a/extensions/fetch/23_request.js +++ b/extensions/fetch/23_request.js @@ -12,6 +12,7 @@ ((window) => { const webidl = window.__bootstrap.webidl; + const consoleInternal = window.__bootstrap.console; const { HTTP_TOKEN_CODE_POINT_RE, byteUpperCase } = window.__bootstrap.infra; const { URL } = window.__bootstrap.url; const { guardFromHeaders } = window.__bootstrap.headers; @@ -393,14 +394,17 @@ } [SymbolFor("Deno.customInspect")](inspect) { - const inner = { - bodyUsed: this.bodyUsed, - headers: this.headers, - method: this.method, - redirect: this.redirect, - url: this.url, - }; - return `Request ${inspect(inner)}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof Request, + keys: [ + "bodyUsed", + "headers", + "method", + "redirect", + "url", + ], + })); } } diff --git a/extensions/fetch/23_response.js b/extensions/fetch/23_response.js index 11eb13570..0db20e90e 100644 --- a/extensions/fetch/23_response.js +++ b/extensions/fetch/23_response.js @@ -13,6 +13,7 @@ ((window) => { const webidl = window.__bootstrap.webidl; + const consoleInternal = window.__bootstrap.console; const { HTTP_TAB_OR_SPACE, regexMatcher } = window.__bootstrap.infra; const { extractBody, mixinBody } = window.__bootstrap.fetchBody; const { getLocationHref } = window.__bootstrap.location; @@ -377,17 +378,20 @@ } [SymbolFor("Deno.customInspect")](inspect) { - const inner = { - body: this.body, - bodyUsed: this.bodyUsed, - headers: this.headers, - ok: this.ok, - redirected: this.redirected, - status: this.status, - statusText: this.statusText, - url: this.url, - }; - return `Response ${inspect(inner)}`; + return inspect(consoleInternal.createFilteredInspectProxy({ + object: this, + evaluate: this instanceof Response, + keys: [ + "body", + "bodyUsed", + "headers", + "ok", + "redirected", + "status", + "statusText", + "url", + ], + })); } } |