Skip to content

Commit 8fc6914

Browse files
joyeecheungtargos
authored andcommitted
test: update wpt/encoding to 7287608f90
Using `git node wpt encoding` PR-URL: #27860 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 0f86c2b commit 8fc6914

6 files changed

Lines changed: 173 additions & 22 deletions

File tree

‎test/fixtures/wpt/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See [test/wpt](../../wpt/README.md) for information on how these tests are run.
1111
Last update:
1212

1313
- console: https://github.com/web-platform-tests/wpt/tree/9786a4b131/console
14-
- encoding: https://github.com/web-platform-tests/wpt/tree/a093a659ed/encoding
14+
- encoding: https://github.com/web-platform-tests/wpt/tree/7287608f90/encoding
1515
- url: https://github.com/web-platform-tests/wpt/tree/418f7fabeb/url
1616
- resources: https://github.com/web-platform-tests/wpt/tree/e1fddfbf80/resources
1717
- interfaces: https://github.com/web-platform-tests/wpt/tree/712c9f275e/interfaces
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
[
2+
{
3+
"input": "Hi",
4+
"read": 0,
5+
"destinationLength": 0,
6+
"written": []
7+
},
8+
{
9+
"input": "A",
10+
"read": 1,
11+
"destinationLength": 10,
12+
"written": [0x41]
13+
},
14+
{
15+
"input": "\u{1D306}",// "\uD834\uDF06"
16+
"read": 2,
17+
"destinationLength": 4,
18+
"written": [0xF0,0x9D,0x8C,0x86]
19+
},
20+
{
21+
"input": "\u{1D306}A",
22+
"read": 0,
23+
"destinationLength": 3,
24+
"written": []
25+
},
26+
{
27+
"input": "\uD834A\uDF06A¥Hi",
28+
"read": 5,
29+
"destinationLength": 10,
30+
"written": [0xEF,0xBF,0xBD,0x41,0xEF,0xBF,0xBD,0x41,0xC2,0xA5]
31+
},
32+
{
33+
"input": "A\uDF06",
34+
"read": 2,
35+
"destinationLength": 4,
36+
"written": [0x41,0xEF,0xBF,0xBD]
37+
},
38+
{
39+
"input": "¥¥",
40+
"read": 2,
41+
"destinationLength": 4,
42+
"written": [0xC2,0xA5,0xC2,0xA5]
43+
}
44+
].forEach(testData=>{
45+
[
46+
{
47+
"bufferIncrease": 0,
48+
"destinationOffset": 0,
49+
"filler": 0
50+
},
51+
{
52+
"bufferIncrease": 10,
53+
"destinationOffset": 4,
54+
"filler": 0
55+
},
56+
{
57+
"bufferIncrease": 0,
58+
"destinationOffset": 0,
59+
"filler": 0x80
60+
},
61+
{
62+
"bufferIncrease": 10,
63+
"destinationOffset": 4,
64+
"filler": 0x80
65+
},
66+
{
67+
"bufferIncrease": 0,
68+
"destinationOffset": 0,
69+
"filler": "random"
70+
},
71+
{
72+
"bufferIncrease": 10,
73+
"destinationOffset": 4,
74+
"filler": "random"
75+
}
76+
].forEach(destinationData=>{
77+
test(()=>{
78+
// Setup
79+
constbufferLength=testData.destinationLength+destinationData.bufferIncrease,
80+
destinationOffset=destinationData.destinationOffset,
81+
destinationLength=testData.destinationLength,
82+
destinationFiller=destinationData.filler,
83+
encoder=newTextEncoder(),
84+
buffer=newArrayBuffer(bufferLength),
85+
view=newUint8Array(buffer,destinationOffset,destinationLength),
86+
fullView=newUint8Array(buffer),
87+
control=newArray(bufferLength);
88+
letbyte=destinationFiller;
89+
for(leti=0;i<bufferLength;i++){
90+
if(destinationFiller==="random"){
91+
byte=Math.floor(Math.random()*256);
92+
}
93+
control[i]=byte;
94+
fullView[i]=byte;
95+
}
96+
97+
// It's happening
98+
constresult=encoder.encodeInto(testData.input,view);
99+
100+
// Basics
101+
assert_equals(view.byteLength,destinationLength);
102+
assert_equals(view.length,destinationLength);
103+
104+
// Remainder
105+
assert_equals(result.read,testData.read);
106+
assert_equals(result.written,testData.written.length);
107+
for(leti=0;i<bufferLength;i++){
108+
if(i<destinationOffset||i>=(destinationOffset+testData.written.length)){
109+
assert_equals(fullView[i],control[i]);
110+
}else{
111+
assert_equals(fullView[i],testData.written[i-destinationOffset]);
112+
}
113+
}
114+
},"encodeInto() with "+testData.input+" and destination length "+testData.destinationLength+", offset "+destinationData.destinationOffset+", filler "+destinationData.filler);
115+
});
116+
});
117+
118+
[DataView,
119+
Int8Array,
120+
Int16Array,
121+
Int32Array,
122+
Uint16Array,
123+
Uint32Array,
124+
Uint8ClampedArray,
125+
Float32Array,
126+
Float64Array].forEach(view=>{
127+
test(()=>{
128+
assert_throws(newTypeError(),()=>newTextEncoder().encodeInto("",newview(newArrayBuffer(0))));
129+
},"Invalid encodeInto() destination: "+view);
130+
});
131+
132+
test(()=>{
133+
assert_throws(newTypeError(),()=>newTextEncoder().encodeInto("",newArrayBuffer(10)));
134+
},"Invalid encodeInto() destination: ArrayBuffer");
135+
136+
test(()=>{
137+
constbuffer=newArrayBuffer(10),
138+
view=newUint8Array(buffer);
139+
let{ read, written }=newTextEncoder().encodeInto("",view);
140+
assert_equals(read,0);
141+
assert_equals(written,0);
142+
newMessageChannel().port1.postMessage(buffer,[buffer]);
143+
({ read, written }=newTextEncoder().encodeInto("",view));
144+
assert_equals(read,0);
145+
assert_equals(written,0);
146+
({ read, written }=newTextEncoder().encodeInto("test",view));
147+
assert_equals(read,0);
148+
assert_equals(written,0);
149+
},"encodeInto() and a detached output buffer");

‎test/fixtures/wpt/encoding/streams/decode-bad-chunks.any.js‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,6 @@ const badChunks = [
2323
name: 'array',
2424
value: [65]
2525
},
26-
{
27-
name: 'detached ArrayBufferView',
28-
value: (()=>{
29-
constu8=newUint8Array([65]);
30-
constab=u8.buffer;
31-
constmc=newMessageChannel();
32-
mc.port1.postMessage(ab,[ab]);
33-
returnu8;
34-
})()
35-
},
36-
{
37-
name: 'detached ArrayBuffer',
38-
value: (()=>{
39-
constu8=newUint8Array([65]);
40-
constab=u8.buffer;
41-
constmc=newMessageChannel();
42-
mc.port1.postMessage(ab,[ab]);
43-
returnab;
44-
})()
45-
},
4626
{
4727
name: 'SharedArrayBuffer',
4828
// Use a getter to postpone construction so that all tests don't fail where

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,23 @@ promise_test(async () => {
3939
assert_array_equals(array,[expectedOutputString],
4040
'the output should be in one chunk');
4141
},'a trailing empty chunk should be ignored');
42+
43+
promise_test(async()=>{
44+
constbuffer=newArrayBuffer(3);
45+
constview=newUint8Array(buffer,1,1);
46+
view[0]=65;
47+
newMessageChannel().port1.postMessage(buffer,[buffer]);
48+
constinput=readableStreamFromArray([view]);
49+
constoutput=input.pipeThrough(newTextDecoderStream());
50+
constarray=awaitreadableStreamToArray(output);
51+
assert_array_equals(array,[],'no chunks should be output');
52+
},'decoding a transferred Uint8Array chunk should give no output');
53+
54+
promise_test(async()=>{
55+
constbuffer=newArrayBuffer(1);
56+
newMessageChannel().port1.postMessage(buffer,[buffer]);
57+
constinput=readableStreamFromArray([buffer]);
58+
constoutput=input.pipeThrough(newTextDecoderStream());
59+
constarray=awaitreadableStreamToArray(output);
60+
assert_array_equals(array,[],'no chunks should be output');
61+
},'decoding a transferred ArrayBuffer chunk should give no output');

‎test/fixtures/wpt/encoding/textdecoder-fatal-single-byte.any.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// META: timeout=long
12
// META: title=Encoding API: Fatal flag for single byte encodings
3+
// META: timeout=long
24

35
varsingleByteEncodings=[
46
{encoding: 'IBM866',bad: []},

‎test/fixtures/wpt/versions.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"path": "console"
55
},
66
"encoding": {
7-
"commit": "a093a659ed118112138f8a1ffba97a66c1ea8235",
7+
"commit": "7287608f90f6b9530635d10086fd2ab386faab38",
88
"path": "encoding"
99
},
1010
"url": {

0 commit comments

Comments
 (0)