mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision b'45fdf45f79582953fb3aa708566cd2c0707cb222'
This commit is contained in:
parent
f7e88665c6
commit
812c6de70b
125 changed files with 1400 additions and 1046 deletions
|
@ -6,7 +6,8 @@
|
|||
// Helper function that triggers garbage collection while reading a chunk
|
||||
// if perform_gc is true.
|
||||
async function read_and_gc(reader, perform_gc) {
|
||||
const read_promise = reader.read();
|
||||
// Passing Uint8Array for byte streams; non-byte streams will simply ignore it
|
||||
const read_promise = reader.read(new Uint8Array(64));
|
||||
if (perform_gc) {
|
||||
await garbageCollect();
|
||||
}
|
||||
|
@ -16,10 +17,10 @@ async function read_and_gc(reader, perform_gc) {
|
|||
// Takes in a ReadableStream and reads from it until it is done, returning
|
||||
// an array that contains the results of each read operation. If perform_gc
|
||||
// is true, garbage collection is triggered while reading every chunk.
|
||||
async function read_all_chunks(stream, perform_gc = false) {
|
||||
async function read_all_chunks(stream, { perform_gc = false, mode } = {}) {
|
||||
assert_true(stream instanceof ReadableStream);
|
||||
assert_true('getReader' in stream);
|
||||
const reader = stream.getReader();
|
||||
const reader = stream.getReader({ mode });
|
||||
|
||||
assert_true('read' in reader);
|
||||
let read_value = await read_and_gc(reader, perform_gc);
|
||||
|
@ -67,7 +68,16 @@ promise_test(async() => {
|
|||
const stream = blob.stream();
|
||||
blob = null;
|
||||
await garbageCollect();
|
||||
const chunks = await read_all_chunks(stream, /*perform_gc=*/true);
|
||||
const chunks = await read_all_chunks(stream, { perform_gc: true });
|
||||
assert_array_equals(chunks, input_arr);
|
||||
}, "Blob.stream() garbage collection of blob shouldn't break stream" +
|
||||
"consumption")
|
||||
|
||||
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();
|
||||
const chunks = await read_all_chunks(stream, { mode: "byob" });
|
||||
assert_array_equals(chunks, input_arr);
|
||||
}, "Reading Blob.stream() with BYOB reader")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue