Update web-platform-tests to revision f1e1bd6bfa544af8059ff8ef79d622281f9ec0a8

This commit is contained in:
WPT Sync Bot 2019-10-01 10:52:57 +00:00
parent 1b6715158d
commit 38ab56be1a
64 changed files with 5155 additions and 165 deletions

View file

@ -34,20 +34,16 @@ const badChunks = [
{
name: 'shared Uint8Array',
get value() {
new Uint8Array(new SharedArrayBuffer())
return new Uint8Array(new SharedArrayBuffer())
}
},
{
name: 'invalid deflate bytes',
get value() {
new Uint8Array([0, 156, 75, 173, 40, 72, 77, 46, 73, 77, 81, 200, 47, 45, 41, 40, 45, 1, 0, 48, 173, 6, 36])
}
value: new Uint8Array([0, 156, 75, 173, 40, 72, 77, 46, 73, 77, 81, 200, 47, 45, 41, 40, 45, 1, 0, 48, 173, 6, 36])
},
{
name: 'invalid gzip bytes',
get value() {
new Uint8Array([0, 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])
}
value: new Uint8Array([0, 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])
},
];

View file

@ -0,0 +1,30 @@
// META: global=worker
'use strict';
const gzipEmptyValue = new Uint8Array([31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
const deflateEmptyValue = new Uint8Array([120, 156, 3, 0, 0, 0, 0, 1]);
promise_test(async t => {
const ds = new DecompressionStream('gzip');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(gzipEmptyValue);
writer.close();
const { value, done } = await reader.read();
assert_true(done, "read() should set done");
assert_equals(value, undefined, "value should be undefined");
await writePromise;
}, 'decompressing gzip empty input should work');
promise_test(async t => {
const ds = new DecompressionStream('deflate');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(deflateEmptyValue);
writer.close();
const { value, done } = await reader.read();
assert_true(done, "read() should set done");
assert_equals(value, undefined, "value should be undefined");
await writePromise;
}, 'decompressing deflate empty input should work');

View file

@ -0,0 +1,44 @@
// META: global=worker
'use strict';
const compressedBytesWithDeflate = 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]);
const compressedBytesWithGzip = 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]);
const expectedChunkValue = new TextEncoder().encode('expected output');
async function decompressArrayBuffer(input, format, chunkSize) {
const ds = new DecompressionStream(format);
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
for (let beginning = 0; beginning < input.length; beginning += chunkSize) {
writer.write(input.slice(beginning, beginning + chunkSize));
}
writer.close();
const out = [];
let totalSize = 0;
while (true) {
const { value, done } = await reader.read();
if (done) break;
out.push(value);
totalSize += value.byteLength;
}
const concatenated = new Uint8Array(totalSize);
let offset = 0;
for (const array of out) {
concatenated.set(array, offset);
offset += array.byteLength;
}
return concatenated;
}
for (let chunkSize = 1; chunkSize < 16; ++chunkSize) {
promise_test(async t => {
const decompressedData = await decompressArrayBuffer(compressedBytesWithDeflate, 'deflate', chunkSize);
assert_array_equals(decompressedData, expectedChunkValue, "value should match");
}, `decompressing splitted chunk into pieces of size ${chunkSize} should work in deflate`);
promise_test(async t => {
const decompressedData = await decompressArrayBuffer(compressedBytesWithGzip, 'gzip', chunkSize);
assert_array_equals(decompressedData, expectedChunkValue, "value should match");
}, `decompressing splitted chunk into pieces of size ${chunkSize} should work in gzip`);
}

View file

@ -0,0 +1,26 @@
// META: global=worker
'use strict';
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]);
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]);
promise_test(async t => {
const ds = new DecompressionStream('deflate');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(deflateChunkValue);
const { value } = await reader.read();
assert_equals(value.constructor, Uint8Array, "type should match");
await writePromise;
}, 'decompressing deflated output should give Uint8Array chunks');
promise_test(async t => {
const ds = new DecompressionStream('gzip');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(gzipChunkValue);
const { value } = await reader.read();
assert_equals(value.constructor, Uint8Array, "type should match");
await writePromise;
}, 'decompressing gzip output should give Uint8Array chunks');