diff options
author | Luca Casonato <hello@lcas.dev> | 2021-08-25 13:48:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 13:48:53 +0200 |
commit | 5d814a4c244d489b4ae51002a0cf1d3c2fe16058 (patch) | |
tree | 3597ab7d4c438b96c34dac52f9f537989129001e /ext/console/02_console.js | |
parent | f84cd9403db3545c8058a9c28474b3c99d4c2dd4 (diff) |
feat: ArrayBuffer in structured clone transfer (#11840)
Diffstat (limited to 'ext/console/02_console.js')
-rw-r--r-- | ext/console/02_console.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 178b3955b..455df4570 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -362,6 +362,7 @@ const entries = []; let iter; + let valueIsTypedArray = false; switch (options.typeName) { case "Map": @@ -376,6 +377,7 @@ default: if (isTypedArray(value)) { iter = ArrayPrototypeEntries(value); + valueIsTypedArray = true; } else { throw new TypeError("unreachable"); } @@ -385,7 +387,24 @@ const next = () => { return iter.next(); }; - for (const el of iter) { + while (true) { + let el; + try { + const res = iter.next(); + if (res.done) { + break; + } + el = res.value; + } catch (err) { + if (valueIsTypedArray) { + // TypedArray.prototype.entries doesn't throw, unless the ArrayBuffer + // is detached. We don't want to show the exception in that case, so + // we catch it here and pretend the ArrayBuffer has no entries (like + // Chrome DevTools does). + break; + } + throw err; + } if (entriesLength < inspectOptions.iterableLimit) { ArrayPrototypePush( entries, |