summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/web/08_text_encoding.js21
-rw-r--r--ext/webidl/00_webidl.js43
-rw-r--r--tools/wpt/expectation.json12
3 files changed, 15 insertions, 61 deletions
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js
index d3f6d45fb..d2922a6d4 100644
--- a/ext/web/08_text_encoding.js
+++ b/ext/web/08_text_encoding.js
@@ -105,14 +105,19 @@
}
try {
- if (ArrayBufferIsView(input)) {
- input = new Uint8Array(
- input.buffer,
- input.byteOffset,
- input.byteLength,
- );
- } else {
- input = new Uint8Array(input);
+ try {
+ if (ArrayBufferIsView(input)) {
+ input = new Uint8Array(
+ input.buffer,
+ input.byteOffset,
+ input.byteLength,
+ );
+ } else {
+ input = new Uint8Array(input);
+ }
+ } catch {
+ // If the buffer is detached, just create a new empty Uint8Array.
+ input = new Uint8Array();
}
if (input.buffer instanceof SharedArrayBuffer) {
// We clone the data into a non-shared ArrayBuffer so we can pass it
diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js
index fa9d14e65..4cbba195c 100644
--- a/ext/webidl/00_webidl.js
+++ b/ext/webidl/00_webidl.js
@@ -441,15 +441,6 @@
return V instanceof SharedArrayBuffer;
}
- function isArrayBufferDetached(V) {
- try {
- new Uint8Array(V);
- return false;
- } catch {
- return true;
- }
- }
-
converters.ArrayBuffer = (V, opts = {}) => {
if (!isNonSharedArrayBuffer(V)) {
if (opts.allowShared && !isSharedArrayBuffer(V)) {
@@ -461,9 +452,6 @@
}
throw makeException(TypeError, "is not an ArrayBuffer", opts);
}
- if (isArrayBufferDetached(V)) {
- throw makeException(TypeError, "is a detached ArrayBuffer", opts);
- }
return V;
};
@@ -480,13 +468,6 @@
opts,
);
}
- if (isArrayBufferDetached(V.buffer)) {
- throw makeException(
- TypeError,
- "is backed by a detached ArrayBuffer",
- opts,
- );
- }
return V;
};
@@ -529,13 +510,6 @@
opts,
);
}
- if (isArrayBufferDetached(V.buffer)) {
- throw makeException(
- TypeError,
- "is a view on a detached ArrayBuffer",
- opts,
- );
- }
return V;
};
@@ -561,13 +535,6 @@
);
}
- if (isArrayBufferDetached(V.buffer)) {
- throw makeException(
- TypeError,
- "is a view on a detached ArrayBuffer",
- opts,
- );
- }
return V;
};
@@ -581,13 +548,6 @@
);
}
- if (isArrayBufferDetached(V.buffer)) {
- throw makeException(
- TypeError,
- "is a view on a detached ArrayBuffer",
- opts,
- );
- }
return V;
}
@@ -609,9 +569,6 @@
opts,
);
}
- if (isArrayBufferDetached(V)) {
- throw makeException(TypeError, "is a detached ArrayBuffer", opts);
- }
return V;
};
diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json
index c80aeea25..d8931aefe 100644
--- a/tools/wpt/expectation.json
+++ b/tools/wpt/expectation.json
@@ -5908,7 +5908,6 @@
"api-surrogates-utf8.any.html": true,
"api-surrogates-utf8.any.worker.html": true,
"encodeInto.any.html": [
- "encodeInto() and a detached output buffer",
"encodeInto() into SharedArrayBuffer with Hi and destination length 0, offset 0, filler 0",
"encodeInto() into SharedArrayBuffer with Hi and destination length 0, offset 4, filler 0",
"encodeInto() into SharedArrayBuffer with Hi and destination length 0, offset 0, filler 128",
@@ -5953,7 +5952,6 @@
"encodeInto() into SharedArrayBuffer with ¥¥ and destination length 4, offset 4, filler random"
],
"encodeInto.any.worker.html": [
- "encodeInto() and a detached output buffer",
"encodeInto() into SharedArrayBuffer with Hi and destination length 0, offset 0, filler 0",
"encodeInto() into SharedArrayBuffer with Hi and destination length 0, offset 4, filler 0",
"encodeInto() into SharedArrayBuffer with Hi and destination length 0, offset 0, filler 128",
@@ -6028,14 +6026,8 @@
"decode-non-utf8.any.worker.html": true,
"decode-split-character.any.html": true,
"decode-split-character.any.worker.html": true,
- "decode-utf8.any.html": [
- "decoding a transferred Uint8Array chunk should give no output",
- "decoding a transferred ArrayBuffer chunk should give no output"
- ],
- "decode-utf8.any.worker.html": [
- "decoding a transferred Uint8Array chunk should give no output",
- "decoding a transferred ArrayBuffer chunk should give no output"
- ],
+ "decode-utf8.any.html": true,
+ "decode-utf8.any.worker.html": true,
"encode-bad-chunks.any.html": true,
"encode-bad-chunks.any.worker.html": true,
"encode-utf8.any.html": true,