From c49058b956bda999bc26a1c43c66f1bede2ebc18 Mon Sep 17 00:00:00 2001 From: Khafra Date: Sun, 25 Feb 2024 11:05:39 -0500 Subject: [PATCH] webidl: implement resizable arraybuffer checks (#2094) --- lib/web/fetch/webidl.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/web/fetch/webidl.js b/lib/web/fetch/webidl.js index 41f5813db69..f111162a10d 100644 --- a/lib/web/fetch/webidl.js +++ b/lib/web/fetch/webidl.js @@ -536,7 +536,12 @@ webidl.converters.ArrayBuffer = function (V, opts = {}) { // with the [AllowResizable] extended attribute, and // IsResizableArrayBuffer(V) is true, then throw a // TypeError. - // Note: resizable ArrayBuffers are currently a proposal. + if (V.resizable || V.growable) { + throw webidl.errors.exception({ + header: 'ArrayBuffer', + message: 'Received a resizable ArrayBuffer.' + }) + } // 4. Return the IDL ArrayBuffer value that is a // reference to the same object as V. @@ -576,7 +581,12 @@ webidl.converters.TypedArray = function (V, T, opts = {}) { // with the [AllowResizable] extended attribute, and // IsResizableArrayBuffer(V.[[ViewedArrayBuffer]]) is // true, then throw a TypeError. - // Note: resizable array buffers are currently a proposal + if (V.buffer.resizable || V.buffer.growable) { + throw webidl.errors.exception({ + header: 'ArrayBuffer', + message: 'Received a resizable ArrayBuffer.' + }) + } // 5. Return the IDL value of type T that is a reference // to the same object as V. @@ -608,7 +618,12 @@ webidl.converters.DataView = function (V, opts = {}) { // with the [AllowResizable] extended attribute, and // IsResizableArrayBuffer(V.[[ViewedArrayBuffer]]) is // true, then throw a TypeError. - // Note: resizable ArrayBuffers are currently a proposal + if (V.buffer.resizable || V.buffer.growable) { + throw webidl.errors.exception({ + header: 'ArrayBuffer', + message: 'Received a resizable ArrayBuffer.' + }) + } // 4. Return the IDL DataView value that is a reference // to the same object as V.