Skip to content

Commit

Permalink
webidl: implement resizable arraybuffer checks (#2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored Feb 25, 2024
1 parent 21832bf commit c49058b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/web/fetch/webidl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c49058b

Please sign in to comment.