Skip to content

Commit 70c0a53

Browse files
committed
webidl: implement resizable arraybuffer checks
1 parent 21832bf commit 70c0a53

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/web/fetch/webidl.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,12 @@ webidl.converters.ArrayBuffer = function (V, opts = {}) {
536536
// with the [AllowResizable] extended attribute, and
537537
// IsResizableArrayBuffer(V) is true, then throw a
538538
// TypeError.
539-
// Note: resizable ArrayBuffers are currently a proposal.
539+
if (V.resizable || V.growable) {
540+
throw webidl.errors.exception({
541+
header: 'ArrayBuffer',
542+
message: 'Received a resizable ArrayBuffer.'
543+
})
544+
}
540545

541546
// 4. Return the IDL ArrayBuffer value that is a
542547
// reference to the same object as V.
@@ -576,7 +581,12 @@ webidl.converters.TypedArray = function (V, T, opts = {}) {
576581
// with the [AllowResizable] extended attribute, and
577582
// IsResizableArrayBuffer(V.[[ViewedArrayBuffer]]) is
578583
// true, then throw a TypeError.
579-
// Note: resizable array buffers are currently a proposal
584+
if (V.buffer.resizable || V.buffer.growable) {
585+
throw webidl.errors.exception({
586+
header: 'ArrayBuffer',
587+
message: 'Received a resizable ArrayBuffer.'
588+
})
589+
}
580590

581591
// 5. Return the IDL value of type T that is a reference
582592
// to the same object as V.
@@ -608,7 +618,12 @@ webidl.converters.DataView = function (V, opts = {}) {
608618
// with the [AllowResizable] extended attribute, and
609619
// IsResizableArrayBuffer(V.[[ViewedArrayBuffer]]) is
610620
// true, then throw a TypeError.
611-
// Note: resizable ArrayBuffers are currently a proposal
621+
if (V.buffer.resizable || V.buffer.growable) {
622+
throw webidl.errors.exception({
623+
header: 'ArrayBuffer',
624+
message: 'Received a resizable ArrayBuffer.'
625+
})
626+
}
612627

613628
// 4. Return the IDL DataView value that is a reference
614629
// to the same object as V.

0 commit comments

Comments
 (0)