Skip to content

Commit dbb0954

Browse files
saschanazmoz-wptsync-bot
authored andcommitted
Enqueue the decode result even if stream end is met
This corresponds to the not-merged-yet spec PR: whatwg/compression#77 Differential Revision: https://phabricator.services.mozilla.com/D266433 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1990921 gecko-commit: 86cb8e42ea52ae9f19fd1edb128d9abf2bb009d3 gecko-reviewers: smaug
1 parent a1b074e commit dbb0954

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

compression/decompression-correct-input.tentative.any.js renamed to compression/decompression-correct-input.any.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// META: global=window,worker,shadowrealm
2+
// META: script=decompression-correct-input.js
23

34
'use strict';
45

5-
const deflateChunkValue = new Uint8Array([120, 156, 75, 173, 40, 72, 77, 46, 73, 77, 81, 200, 47, 45, 41, 40, 45, 1, 0, 48, 173, 6, 36]);
6-
const gzipChunkValue = new Uint8Array([31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 75, 173, 40, 72, 77, 46, 73, 77, 81, 200, 47, 45, 41, 40, 45, 1, 0, 176, 1, 57, 179, 15, 0, 0, 0]);
7-
const deflateRawChunkValue = new Uint8Array([
8-
0x4b, 0xad, 0x28, 0x48, 0x4d, 0x2e, 0x49, 0x4d, 0x51, 0xc8,
9-
0x2f, 0x2d, 0x29, 0x28, 0x2d, 0x01, 0x00,
10-
]);
11-
const trueChunkValue = new TextEncoder().encode('expected output');
12-
136
promise_test(async t => {
147
const ds = new DecompressionStream('deflate');
158
const reader = ds.readable.getReader();
@@ -19,7 +12,6 @@ promise_test(async t => {
1912
assert_array_equals(Array.from(value), trueChunkValue, "value should match");
2013
}, 'decompressing deflated input should work');
2114

22-
2315
promise_test(async t => {
2416
const ds = new DecompressionStream('gzip');
2517
const reader = ds.readable.getReader();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const deflateChunkValue = new Uint8Array([120, 156, 75, 173, 40, 72, 77, 46, 73, 77, 81, 200, 47, 45, 41, 40, 45, 1, 0, 48, 173, 6, 36]);
2+
const gzipChunkValue = new Uint8Array([31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 75, 173, 40, 72, 77, 46, 73, 77, 81, 200, 47, 45, 41, 40, 45, 1, 0, 176, 1, 57, 179, 15, 0, 0, 0]);
3+
const deflateRawChunkValue = new Uint8Array([
4+
0x4b, 0xad, 0x28, 0x48, 0x4d, 0x2e, 0x49, 0x4d, 0x51, 0xc8,
5+
0x2f, 0x2d, 0x29, 0x28, 0x2d, 0x01, 0x00,
6+
]);
7+
const trueChunkValue = new TextEncoder().encode('expected output');
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// META: global=window,worker,shadowrealm
2+
// META: script=decompression-correct-input.js
3+
4+
'use strict';
5+
6+
const tests = [
7+
["deflate", new Uint8Array([...deflateChunkValue, 0])],
8+
["gzip", new Uint8Array([...gzipChunkValue, 0])],
9+
["deflate-raw", new Uint8Array([...deflateRawChunkValue, 0])],
10+
];
11+
12+
for (const [format, chunk] of tests) {
13+
promise_test(async t => {
14+
const ds = new DecompressionStream(format);
15+
const reader = ds.readable.getReader();
16+
const writer = ds.writable.getWriter();
17+
writer.write(chunk).catch(() => { });
18+
const { done, value } = await reader.read();
19+
assert_array_equals(Array.from(value), trueChunkValue, "value should match");
20+
await promise_rejects_js(t, TypeError, reader.read(), "Extra input should eventually throw");
21+
}, `decompressing ${format} input with extra pad should still give the output`);
22+
}

0 commit comments

Comments
 (0)