aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/encoding/encodeInto.any.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wpt/web-platform-tests/encoding/encodeInto.any.js')
-rw-r--r--tests/wpt/web-platform-tests/encoding/encodeInto.any.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/wpt/web-platform-tests/encoding/encodeInto.any.js b/tests/wpt/web-platform-tests/encoding/encodeInto.any.js
index 7e18c812499..eca0e1bca15 100644
--- a/tests/wpt/web-platform-tests/encoding/encodeInto.any.js
+++ b/tests/wpt/web-platform-tests/encoding/encodeInto.any.js
@@ -1,3 +1,6 @@
+// META: global=window,worker
+// META: script=/common/sab.js
+
[
{
"input": "Hi",
@@ -77,15 +80,15 @@
["ArrayBuffer", "SharedArrayBuffer"].forEach(arrayBufferOrSharedArrayBuffer => {
test(() => {
// Setup
- const bufferLength = testData.destinationLength + destinationData.bufferIncrease,
- destinationOffset = destinationData.destinationOffset,
- destinationLength = testData.destinationLength,
- destinationFiller = destinationData.filler,
- encoder = new TextEncoder(),
- buffer = new self[arrayBufferOrSharedArrayBuffer](bufferLength),
- view = new Uint8Array(buffer, destinationOffset, destinationLength),
- fullView = new Uint8Array(buffer),
- control = new Array(bufferLength);
+ const bufferLength = testData.destinationLength + destinationData.bufferIncrease;
+ const destinationOffset = destinationData.destinationOffset;
+ const destinationLength = testData.destinationLength;
+ const destinationFiller = destinationData.filler;
+ const encoder = new TextEncoder();
+ const buffer = createBuffer(arrayBufferOrSharedArrayBuffer, bufferLength);
+ const view = new Uint8Array(buffer, destinationOffset, destinationLength);
+ const fullView = new Uint8Array(buffer);
+ const control = new Array(bufferLength);
let byte = destinationFiller;
for (let i = 0; i < bufferLength; i++) {
if (destinationFiller === "random") {
@@ -128,19 +131,17 @@
Float64Array].forEach(view => {
["ArrayBuffer", "SharedArrayBuffer"].forEach((arrayBufferOrSharedArrayBuffer) => {
test(() => {
- assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", new view(new self[arrayBufferOrSharedArrayBuffer](0))));
+ assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", new view(createBuffer(arrayBufferOrSharedArrayBuffer, 0))));
}, "Invalid encodeInto() destination: " + view.name + ", backed by: " + arrayBufferOrSharedArrayBuffer);
});
});
["ArrayBuffer", "SharedArrayBuffer"].forEach((arrayBufferOrSharedArrayBuffer) => {
test(() => {
- assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", new self[arrayBufferOrSharedArrayBuffer](10)));
+ assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", createBuffer(arrayBufferOrSharedArrayBuffer, 10)));
}, "Invalid encodeInto() destination: " + arrayBufferOrSharedArrayBuffer);
});
-
-
test(() => {
const buffer = new ArrayBuffer(10),
view = new Uint8Array(buffer);