зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1547580 [wpt PR 16543] - FileAPI: Add more WPT for Blob read methods., a=testonly
Automatic update from web-platform-tests FileAPI: Add more WPT for Blob read methods. This change adds 3 new tests: 1. Make sure that garbage collection of the Blob will not break consumption of it's readable stream. 2. Make sure that concurrent reads via the text() method work. 3. Make sure that concurrent reads via the arrayBuffer() method work. Bug: 945893 Change-Id: Ie1fb2095ba921d0b8638fc6c53264938bc9e871c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1584703 Commit-Queue: Jarryd Goodman <jarrydg@chromium.org> Auto-Submit: Jarryd Goodman <jarrydg@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Cr-Commit-Position: refs/heads/master@{#654330} -- wpt-commits: 137236ccb7ea90e5f49b8f126b294307e8ecd955 wpt-pr: 16543
This commit is contained in:
Родитель
ec2c22ef25
Коммит
7120c26ac8
|
@ -32,3 +32,14 @@ promise_test(async () => {
|
|||
const array_buffer = await blob.arrayBuffer();
|
||||
assert_equals_typed_array(new Uint8Array(array_buffer), typed_arr);
|
||||
}, "Blob.arrayBuffer() non-unicode input")
|
||||
|
||||
promise_test(async () => {
|
||||
const input_arr = new TextEncoder().encode("PASS");
|
||||
const blob = new Blob([input_arr]);
|
||||
const array_buffer_results = await Promise.all([blob.arrayBuffer(),
|
||||
blob.arrayBuffer(), blob.arrayBuffer()]);
|
||||
for (let array_buffer of array_buffer_results) {
|
||||
assert_true(array_buffer instanceof ArrayBuffer);
|
||||
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr);
|
||||
}
|
||||
}, "Blob.arrayBuffer() concurrent reads")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// META: title=Blob Stream
|
||||
// META: script=../support/Blob.js
|
||||
// META: script=../../streams/resources/test-utils.js
|
||||
'use strict';
|
||||
|
||||
// Takes in a ReadableStream and reads from it until it is done, returning
|
||||
|
@ -25,7 +26,7 @@ async function read_all_chunks(stream) {
|
|||
|
||||
promise_test(async () => {
|
||||
const blob = new Blob(["PASS"]);
|
||||
const stream = await blob.stream()
|
||||
const stream = blob.stream();
|
||||
const chunks = await read_all_chunks(stream);
|
||||
for (let [index, value] of chunks.entries()) {
|
||||
assert_equals(value, "PASS".charCodeAt(index));
|
||||
|
@ -34,9 +35,8 @@ promise_test(async () => {
|
|||
|
||||
promise_test(async () => {
|
||||
const blob = new Blob();
|
||||
const stream = await blob.stream()
|
||||
const stream = blob.stream();
|
||||
const chunks = await read_all_chunks(stream);
|
||||
|
||||
assert_array_equals(chunks, []);
|
||||
}, "Blob.stream() empty Blob")
|
||||
|
||||
|
@ -44,7 +44,19 @@ promise_test(async () => {
|
|||
const input_arr = [8, 241, 48, 123, 151];
|
||||
const typed_arr = new Uint8Array(input_arr);
|
||||
const blob = new Blob([typed_arr]);
|
||||
const stream = await blob.stream()
|
||||
const stream = blob.stream();
|
||||
const chunks = await read_all_chunks(stream);
|
||||
assert_array_equals(chunks, input_arr)
|
||||
assert_array_equals(chunks, input_arr);
|
||||
}, "Blob.stream() non-unicode input")
|
||||
|
||||
promise_test(async() => {
|
||||
const input_arr = [8, 241, 48, 123, 151];
|
||||
const typed_arr = new Uint8Array(input_arr);
|
||||
let blob = new Blob([typed_arr]);
|
||||
const stream = blob.stream();
|
||||
blob = null;
|
||||
garbageCollect();
|
||||
const chunks = await read_all_chunks(stream);
|
||||
assert_array_equals(chunks, input_arr);
|
||||
}, "Blob.stream() garbage collection of blob shouldn't break stream" +
|
||||
"consumption")
|
||||
|
|
|
@ -50,3 +50,15 @@ promise_test(async () => {
|
|||
assert_equals(text, "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd" +
|
||||
"\ufffd\ufffd\ufffd\ufffd");
|
||||
}, "Blob.text() invalid utf-8 input")
|
||||
|
||||
promise_test(async () => {
|
||||
const input_arr = new Uint8Array([192, 193, 245, 246, 247, 248, 249, 250, 251,
|
||||
252, 253, 254, 255]);
|
||||
const blob = new Blob([input_arr]);
|
||||
const text_results = await Promise.all([blob.text(), blob.text(),
|
||||
blob.text()]);
|
||||
for (let text of text_results) {
|
||||
assert_equals(text, "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd" +
|
||||
"\ufffd\ufffd\ufffd\ufffd");
|
||||
}
|
||||
}, "Blob.text() concurrent reads")
|
||||
|
|
Загрузка…
Ссылка в новой задаче