Skip to content

Commit 198cf59

Browse files
cola119danielleadams
authored andcommitted
test: update WPT encoding tests
PR-URL: #43958 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Feng Yu <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 51cb0d4 commit 198cf59

15 files changed

+259
-22
lines changed

test/fixtures/wpt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Last update:
1414
- console: https://github.com/web-platform-tests/wpt/tree/3b1f72e99a/console
1515
- dom/abort: https://github.com/web-platform-tests/wpt/tree/c49cafb491/dom/abort
1616
- dom/events: https://github.com/web-platform-tests/wpt/tree/f8821adb28/dom/events
17-
- encoding: https://github.com/web-platform-tests/wpt/tree/35f70910d3/encoding
17+
- encoding: https://github.com/web-platform-tests/wpt/tree/c1b24fce6e/encoding
1818
- FileAPI: https://github.com/web-platform-tests/wpt/tree/3b279420d4/FileAPI
1919
- hr-time: https://github.com/web-platform-tests/wpt/tree/9910784394/hr-time
2020
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob

test/fixtures/wpt/encoding/encodeInto.any.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,22 @@
120120
});
121121
});
122122

123-
[DataView,
124-
Int8Array,
125-
Int16Array,
126-
Int32Array,
127-
Uint16Array,
128-
Uint32Array,
129-
Uint8ClampedArray,
130-
Float32Array,
131-
Float64Array].forEach(view => {
123+
["DataView",
124+
"Int8Array",
125+
"Int16Array",
126+
"Int32Array",
127+
"Uint16Array",
128+
"Uint32Array",
129+
"Uint8ClampedArray",
130+
"BigInt64Array",
131+
"BigUint64Array",
132+
"Float32Array",
133+
"Float64Array"].forEach(type => {
132134
["ArrayBuffer", "SharedArrayBuffer"].forEach((arrayBufferOrSharedArrayBuffer) => {
133135
test(() => {
134-
assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", new view(createBuffer(arrayBufferOrSharedArrayBuffer, 0))));
135-
}, "Invalid encodeInto() destination: " + view.name + ", backed by: " + arrayBufferOrSharedArrayBuffer);
136+
const viewInstance = new self[type](createBuffer(arrayBufferOrSharedArrayBuffer, 0));
137+
assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", viewInstance));
138+
}, "Invalid encodeInto() destination: " + type + ", backed by: " + arrayBufferOrSharedArrayBuffer);
136139
});
137140
});
138141

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Opener-Policy: same-origin
2+
Cross-Origin-Embedder-Policy: require-corp
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// META: script=/resources/idlharness-shadowrealm.js
2+
idl_test_shadowrealm(["encoding"], ["streams"]);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script>
5+
6+
test(() => {
7+
const decoder = new TextDecoder('utf-8');
8+
const buffer = new SharedArrayBuffer(4);
9+
assert_throws_js(TypeError, () => {
10+
decoder.decode(new Uint8Array(buffer));
11+
}, 'constructing TextDecoder with SharedArrayBuffer view should throw');
12+
}, 'decoding SharedArrayBuffer');
13+
14+
</script>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Opener-Policy:same-origin
2+
Cross-Origin-Embedder-Policy:require-corp

test/fixtures/wpt/encoding/single-byte-decoder.window.js

Lines changed: 107 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/wpt/encoding/streams/decode-utf8.any.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@
4343
const array = await readableStreamToArray(output);
4444
assert_array_equals(array, [expectedOutputString],
4545
'the output should be in one chunk');
46-
}, 'a trailing empty chunk should be ignored- ' + arrayBufferOrSharedArrayBuffer);
46+
}, 'a trailing empty chunk should be ignored - ' + arrayBufferOrSharedArrayBuffer);
47+
48+
promise_test(async () => {
49+
const chunk = new Uint8Array(createBuffer(arrayBufferOrSharedArrayBuffer, 3));
50+
chunk.set([0xF0, 0x9F, 0x92]);
51+
const input = readableStreamFromArray([chunk]);
52+
const output = input.pipeThrough(new TextDecoderStream());
53+
const array = await readableStreamToArray(output);
54+
assert_array_equals(array, ['\uFFFD']);
55+
}, 'UTF-8 EOF handling - ' + arrayBufferOrSharedArrayBuffer);
4756
});
4857

4958
promise_test(async () => {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Opener-Policy: same-origin
2+
Cross-Origin-Embedder-Policy: require-corp
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Opener-Policy: same-origin
2+
Cross-Origin-Embedder-Policy: require-corp

0 commit comments

Comments
 (0)