From 03edd48edd004cec091541e6b71095cfbc4b4c87 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Mon, 3 Apr 2023 02:41:41 +0900 Subject: chore: Turn back on dlintPreferPrimordials (#17715) Closes #17709 --- ext/webidl/00_webidl.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'ext/webidl') diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index 124c81c73..43c0cb621 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -18,6 +18,7 @@ const { BigInt, BigIntAsIntN, BigIntAsUintN, + DataViewPrototypeGetBuffer, Float32Array, Float64Array, FunctionPrototypeBind, @@ -76,6 +77,7 @@ const { Symbol, SymbolIterator, SymbolToStringTag, + TypedArrayPrototypeGetBuffer, TypedArrayPrototypeGetSymbolToStringTag, TypeError, Uint16Array, @@ -476,7 +478,7 @@ converters.DataView = (V, opts = {}) => { throw makeException(TypeError, "is not a DataView", opts); } - if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) { + if (!opts.allowShared && isSharedArrayBuffer(DataViewPrototypeGetBuffer(V))) { throw makeException( TypeError, "is backed by a SharedArrayBuffer, which is not allowed", @@ -512,7 +514,10 @@ ArrayPrototypeForEach( opts, ); } - if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) { + if ( + !opts.allowShared && + isSharedArrayBuffer(TypedArrayPrototypeGetBuffer(V)) + ) { throw makeException( TypeError, "is a view on a SharedArrayBuffer, which is not allowed", @@ -535,8 +540,13 @@ converters.ArrayBufferView = (V, opts = {}) => { opts, ); } - - if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) { + let buffer; + if (TypedArrayPrototypeGetSymbolToStringTag(V) !== undefined) { + buffer = TypedArrayPrototypeGetBuffer(V); + } else { + buffer = DataViewPrototypeGetBuffer(V); + } + if (!opts.allowShared && isSharedArrayBuffer(buffer)) { throw makeException( TypeError, "is a view on a SharedArrayBuffer, which is not allowed", @@ -549,7 +559,13 @@ converters.ArrayBufferView = (V, opts = {}) => { converters.BufferSource = (V, opts = {}) => { if (ArrayBufferIsView(V)) { - if (!opts.allowShared && isSharedArrayBuffer(V.buffer)) { + let buffer; + if (TypedArrayPrototypeGetSymbolToStringTag(V) !== undefined) { + buffer = TypedArrayPrototypeGetBuffer(V); + } else { + buffer = DataViewPrototypeGetBuffer(V); + } + if (!opts.allowShared && isSharedArrayBuffer(buffer)) { throw makeException( TypeError, "is a view on a SharedArrayBuffer, which is not allowed", -- cgit v1.2.3