Skip to content

Commit d494ffd

Browse files
committed
webidl: implement resizable arraybuffer checks
1 parent a3efc98 commit d494ffd

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/fetch/webidl.js

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

539544
// 4. Return the IDL ArrayBuffer value that is a
540545
// reference to the same object as V.
@@ -574,7 +579,12 @@ webidl.converters.TypedArray = function (V, T, opts = {}) {
574579
// with the [AllowResizable] extended attribute, and
575580
// IsResizableArrayBuffer(V.[[ViewedArrayBuffer]]) is
576581
// true, then throw a TypeError.
577-
// Note: resizable array buffers are currently a proposal
582+
if (V.buffer.resizable || V.buffer.growable) {
583+
throw webidl.errors.exception({
584+
header: 'ArrayBuffer',
585+
message: 'Received a resizable ArrayBuffer.'
586+
})
587+
}
578588

579589
// 5. Return the IDL value of type T that is a reference
580590
// to the same object as V.
@@ -606,7 +616,12 @@ webidl.converters.DataView = function (V, opts = {}) {
606616
// with the [AllowResizable] extended attribute, and
607617
// IsResizableArrayBuffer(V.[[ViewedArrayBuffer]]) is
608618
// true, then throw a TypeError.
609-
// Note: resizable ArrayBuffers are currently a proposal
619+
if (V.buffer.resizable || V.buffer.growable) {
620+
throw webidl.errors.exception({
621+
header: 'ArrayBuffer',
622+
message: 'Received a resizable ArrayBuffer.'
623+
})
624+
}
610625

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

0 commit comments

Comments
 (0)