From d494ffdd8960e8c18d33b0537ae6cff5cacd901b Mon Sep 17 00:00:00 2001 From: Khafra Date: Mon, 24 Apr 2023 22:04:11 -0400 Subject: [PATCH] webidl: implement resizable arraybuffer checks --- lib/fetch/webidl.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/fetch/webidl.js b/lib/fetch/webidl.js index 38a05e65759..b8758341568 100644 --- a/lib/fetch/webidl.js +++ b/lib/fetch/webidl.js @@ -534,7 +534,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. @@ -574,7 +579,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. @@ -606,7 +616,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.