From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../content-encoding/gzip/bad-gzip-body.any.js | 22 +++++++++ .../gzip/big-gzip-body.https.any.js | 55 +++++++++++++++++++++ .../fetch/content-encoding/gzip/gzip-body.any.js | 16 ++++++ .../gzip/resources/bad-gzip-body.py | 3 ++ .../content-encoding/gzip/resources/big.text.gz | Bin 0 -> 65509 bytes .../gzip/resources/big.text.gz.headers | 3 ++ .../gzip/resources/foo.octetstream.gz | Bin 0 -> 64 bytes .../gzip/resources/foo.octetstream.gz.headers | 2 + .../content-encoding/gzip/resources/foo.text.gz | Bin 0 -> 57 bytes .../gzip/resources/foo.text.gz.headers | 2 + .../zstd/bad-zstd-body.https.any.js | 22 +++++++++ .../big-window-zstd-body.tentative.https.any.js | 9 ++++ .../zstd/big-zstd-body.https.any.js | 55 +++++++++++++++++++++ .../zstd/resources/bad-zstd-body.py | 3 ++ .../content-encoding/zstd/resources/big.text.zst | Bin 0 -> 2509 bytes .../zstd/resources/big.text.zst.headers | 3 ++ .../content-encoding/zstd/resources/big.window.zst | Bin 0 -> 599 bytes .../zstd/resources/big.window.zst.headers | 2 + .../zstd/resources/foo.octetstream.zst | Bin 0 -> 25 bytes .../zstd/resources/foo.octetstream.zst.headers | 2 + .../content-encoding/zstd/resources/foo.text.zst | Bin 0 -> 25 bytes .../zstd/resources/foo.text.zst.headers | 2 + .../content-encoding/zstd/zstd-body.https.any.js | 15 ++++++ 23 files changed, 216 insertions(+) create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/bad-gzip-body.any.js create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/big-gzip-body.https.any.js create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/gzip-body.any.js create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/bad-gzip-body.py create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz create mode 100644 testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/bad-zstd-body.https.any.js create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/big-window-zstd-body.tentative.https.any.js create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/big-zstd-body.https.any.js create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/bad-zstd-body.py create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst.headers create mode 100644 testing/web-platform/tests/fetch/content-encoding/zstd/zstd-body.https.any.js (limited to 'testing/web-platform/tests/fetch/content-encoding') diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/bad-gzip-body.any.js b/testing/web-platform/tests/fetch/content-encoding/gzip/bad-gzip-body.any.js new file mode 100644 index 0000000000..17bc1261a3 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/bad-gzip-body.any.js @@ -0,0 +1,22 @@ +// META: global=window,worker + +promise_test((test) => { + return fetch("resources/bad-gzip-body.py").then(res => { + assert_equals(res.status, 200); + }); +}, "Fetching a resource with bad gzip content should still resolve"); + +[ + "arrayBuffer", + "blob", + "formData", + "json", + "text" +].forEach(method => { + promise_test(t => { + return fetch("resources/bad-gzip-body.py").then(res => { + assert_equals(res.status, 200); + return promise_rejects_js(t, TypeError, res[method]()); + }); + }, "Consuming the body of a resource with bad gzip content with " + method + "() should reject"); +}); diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/big-gzip-body.https.any.js b/testing/web-platform/tests/fetch/content-encoding/gzip/big-gzip-body.https.any.js new file mode 100644 index 0000000000..b5d62c9804 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/big-gzip-body.https.any.js @@ -0,0 +1,55 @@ +// META: global=window,worker + +const EXPECTED_SIZE = 27000000; +const EXPECTED_SHA256 = [ + 74, 100, 37, 243, 147, 61, 116, 60, 241, 221, 126, + 18, 24, 71, 204, 28, 50, 62, 201, 130, 152, 225, + 217, 183, 10, 201, 143, 214, 102, 155, 212, 248, + ]; + +promise_test(async () => { + const response = await fetch('resources/big.text.gz'); + assert_true(response.ok); + const arrayBuffer = await response.arrayBuffer(); + assert_equals(arrayBuffer.byteLength, EXPECTED_SIZE, + 'uncompressed size should match'); + const sha256 = await crypto.subtle.digest('SHA-256', arrayBuffer); + assert_array_equals(new Uint8Array(sha256), EXPECTED_SHA256, + 'digest should match'); +}, 'large gzip data should be decompressed successfully'); + +promise_test(async () => { + const response = await fetch('resources/big.text.gz'); + assert_true(response.ok); + const reader = response.body.getReader({mode: 'byob'}); + let offset = 0; + // Pre-allocate space for the output. The response body will be read + // chunk-by-chunk into this array. + let ab = new ArrayBuffer(EXPECTED_SIZE); + while (offset < EXPECTED_SIZE) { + // To stress the data pipe, we want to use a different size read each + // time. Unfortunately, JavaScript doesn't have a seeded random number + // generator, so this creates the possibility of making this test flaky if + // it doesn't work for some edge cases. + let size = Math.floor(Math.random() * 65535 + 1); + if (size + offset > EXPECTED_SIZE) { + size = EXPECTED_SIZE - offset; + } + const u8 = new Uint8Array(ab, offset, size); + const { value, done } = await reader.read(u8); + ab = value.buffer; + // Check that we got our original array back. + assert_equals(ab.byteLength, EXPECTED_SIZE, + 'backing array should be the same size'); + assert_equals(offset, value.byteOffset, 'offset should match'); + assert_less_than_equal(value.byteLength, size, + 'we should not have got more than we asked for'); + offset = value.byteOffset + value.byteLength; + if (done) break; + } + assert_equals(offset, EXPECTED_SIZE, + 'we should have read the whole thing'); + const sha256 = await crypto.subtle.digest('SHA-256', new Uint8Array(ab)); + assert_array_equals(new Uint8Array(sha256), EXPECTED_SHA256, + 'digest should match'); +}, 'large gzip data should be decompressed successfully with byte stream'); diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/gzip-body.any.js b/testing/web-platform/tests/fetch/content-encoding/gzip/gzip-body.any.js new file mode 100644 index 0000000000..37758b7d91 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/gzip-body.any.js @@ -0,0 +1,16 @@ +// META: global=window,worker + +const expectedDecompressedSize = 10500; +[ + "text", + "octetstream" +].forEach(contentType => { + promise_test(async t => { + let response = await fetch(`resources/foo.${contentType}.gz`); + assert_true(response.ok); + let arrayBuffer = await response.arrayBuffer() + let u8 = new Uint8Array(arrayBuffer); + assert_equals(u8.length, expectedDecompressedSize); + }, `fetched gzip data with content type ${contentType} should be decompressed.`); +}); + diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/bad-gzip-body.py b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/bad-gzip-body.py new file mode 100644 index 0000000000..a79b94ed04 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/bad-gzip-body.py @@ -0,0 +1,3 @@ +def main(request, response): + headers = [(b"Content-Encoding", b"gzip")] + return headers, b"not actually gzip" diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz new file mode 100644 index 0000000000..13441bc399 Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz differ diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz.headers b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz.headers new file mode 100644 index 0000000000..55d2345c23 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/big.text.gz.headers @@ -0,0 +1,3 @@ +Content-type: text/plain +Content-Encoding: gzip +Cache-Control: no-store diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz new file mode 100644 index 0000000000..f3df4cb89b Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz differ diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz.headers b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz.headers new file mode 100644 index 0000000000..27d4f401f1 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.octetstream.gz.headers @@ -0,0 +1,2 @@ +Content-type: application/octet-stream +Content-Encoding: gzip diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz new file mode 100644 index 0000000000..05a5cce07b Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz differ diff --git a/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz.headers b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz.headers new file mode 100644 index 0000000000..7def3ddc14 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/gzip/resources/foo.text.gz.headers @@ -0,0 +1,2 @@ +Content-type: text/plain +Content-Encoding: gzip diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/bad-zstd-body.https.any.js b/testing/web-platform/tests/fetch/content-encoding/zstd/bad-zstd-body.https.any.js new file mode 100644 index 0000000000..3f32e4dfba --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/bad-zstd-body.https.any.js @@ -0,0 +1,22 @@ +// META: global=window,worker + +promise_test((test) => { + return fetch("resources/bad-zstd-body.py").then(res => { + assert_equals(res.status, 200); + }); +}, "Fetching a resource with bad zstd content should still resolve"); + +[ + "arrayBuffer", + "blob", + "formData", + "json", + "text" +].forEach(method => { + promise_test(t => { + return fetch("resources/bad-zstd-body.py").then(res => { + assert_equals(res.status, 200); + return promise_rejects_js(t, TypeError, res[method]()); + }); + }, "Consuming the body of a resource with bad zstd content with " + method + "() should reject"); +}); diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/big-window-zstd-body.tentative.https.any.js b/testing/web-platform/tests/fetch/content-encoding/zstd/big-window-zstd-body.tentative.https.any.js new file mode 100644 index 0000000000..c1dc944956 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/big-window-zstd-body.tentative.https.any.js @@ -0,0 +1,9 @@ +// META: global=window,worker +// See https://github.com/facebook/zstd/issues/2713 for discussion about +// standardizing window size limits. + +promise_test(async t => { + const response = await fetch('resources/big.window.zst'); + assert_true(response.ok); + await promise_rejects_js(t, TypeError, response.text()); +}, 'Consuming the body of a resource with too large of a zstd window size should reject'); diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/big-zstd-body.https.any.js b/testing/web-platform/tests/fetch/content-encoding/zstd/big-zstd-body.https.any.js new file mode 100644 index 0000000000..6835f6e425 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/big-zstd-body.https.any.js @@ -0,0 +1,55 @@ +// META: global=window,worker + +const EXPECTED_SIZE = 27000000; +const EXPECTED_SHA256 = [ + 74, 100, 37, 243, 147, 61, 116, 60, 241, 221, 126, + 18, 24, 71, 204, 28, 50, 62, 201, 130, 152, 225, + 217, 183, 10, 201, 143, 214, 102, 155, 212, 248, + ]; + +promise_test(async () => { + const response = await fetch('resources/big.text.zst'); + assert_true(response.ok); + const arrayBuffer = await response.arrayBuffer(); + assert_equals(arrayBuffer.byteLength, EXPECTED_SIZE, + 'uncompressed size should match'); + const sha256 = await crypto.subtle.digest('SHA-256', arrayBuffer); + assert_array_equals(new Uint8Array(sha256), EXPECTED_SHA256, + 'digest should match'); +}, 'large zstd data should be decompressed successfully'); + +promise_test(async () => { + const response = await fetch('resources/big.text.zst'); + assert_true(response.ok); + const reader = response.body.getReader({mode: 'byob'}); + let offset = 0; + // Pre-allocate space for the output. The response body will be read + // chunk-by-chunk into this array. + let ab = new ArrayBuffer(EXPECTED_SIZE); + while (offset < EXPECTED_SIZE) { + // To stress the data pipe, we want to use a different size read each + // time. Unfortunately, JavaScript doesn't have a seeded random number + // generator, so this creates the possibility of making this test flaky if + // it doesn't work for some edge cases. + let size = Math.floor(Math.random() * 65535 + 1); + if (size + offset > EXPECTED_SIZE) { + size = EXPECTED_SIZE - offset; + } + const u8 = new Uint8Array(ab, offset, size); + const { value, done } = await reader.read(u8); + ab = value.buffer; + // Check that we got our original array back. + assert_equals(ab.byteLength, EXPECTED_SIZE, + 'backing array should be the same size'); + assert_equals(offset, value.byteOffset, 'offset should match'); + assert_less_than_equal(value.byteLength, size, + 'we should not have got more than we asked for'); + offset = value.byteOffset + value.byteLength; + if (done) break; + } + assert_equals(offset, EXPECTED_SIZE, + 'we should have read the whole thing'); + const sha256 = await crypto.subtle.digest('SHA-256', new Uint8Array(ab)); + assert_array_equals(new Uint8Array(sha256), EXPECTED_SHA256, + 'digest should match'); +}, 'large zstd data should be decompressed successfully with byte stream'); diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/bad-zstd-body.py b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/bad-zstd-body.py new file mode 100644 index 0000000000..496f26881d --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/bad-zstd-body.py @@ -0,0 +1,3 @@ +def main(request, response): + headers = [(b"Content-Encoding", b"zstd")] + return headers, b"not actually zstd" diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst new file mode 100644 index 0000000000..30eda2443f Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst differ diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst.headers b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst.headers new file mode 100644 index 0000000000..ea5b05cf2c --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.text.zst.headers @@ -0,0 +1,3 @@ +Content-type: text/plain +Content-Encoding: zstd +Cache-Control: no-store diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst new file mode 100644 index 0000000000..a1bca73228 Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst differ diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst.headers b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst.headers new file mode 100644 index 0000000000..c5974e126a --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/big.window.zst.headers @@ -0,0 +1,2 @@ +Content-type: text/plain +Content-Encoding: zstd diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst new file mode 100644 index 0000000000..a73bbdd224 Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst differ diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst.headers b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst.headers new file mode 100644 index 0000000000..e397816f54 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.octetstream.zst.headers @@ -0,0 +1,2 @@ +Content-type: application/octet-stream +Content-Encoding: zstd diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst new file mode 100644 index 0000000000..a73bbdd224 Binary files /dev/null and b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst differ diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst.headers b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst.headers new file mode 100644 index 0000000000..c5974e126a --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/resources/foo.text.zst.headers @@ -0,0 +1,2 @@ +Content-type: text/plain +Content-Encoding: zstd diff --git a/testing/web-platform/tests/fetch/content-encoding/zstd/zstd-body.https.any.js b/testing/web-platform/tests/fetch/content-encoding/zstd/zstd-body.https.any.js new file mode 100644 index 0000000000..8692385743 --- /dev/null +++ b/testing/web-platform/tests/fetch/content-encoding/zstd/zstd-body.https.any.js @@ -0,0 +1,15 @@ +// META: global=window,worker + +const expectedDecompressedSize = 10500; +[ + "text", + "octetstream" +].forEach(contentType => { + promise_test(async t => { + let response = await fetch(`resources/foo.${contentType}.zst`); + assert_true(response.ok); + let arrayBuffer = await response.arrayBuffer() + let u8 = new Uint8Array(arrayBuffer); + assert_equals(u8.length, expectedDecompressedSize); + }, `fetched zstd data with content type ${contentType} should be decompressed.`); +}); -- cgit v1.2.3