Update web-platform-tests to revision 2f95271debcba3e26e7294beeee4fa5a2ecfbfa0

This commit is contained in:
WPT Sync Bot 2020-12-02 08:20:38 +00:00
parent 6fab7a7d84
commit 48add2991a
74 changed files with 789 additions and 263 deletions

View file

@ -3,15 +3,25 @@
// META: script=../../streams/resources/test-utils.js
'use strict';
// 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();
if (perform_gc)
garbageCollect();
return read_promise;
}
// Takes in a ReadableStream and reads from it until it is done, returning
// an array that contains the results of each read operation
async function read_all_chunks(stream) {
// 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) {
assert_true(stream instanceof ReadableStream);
assert_true('getReader' in stream);
const reader = stream.getReader();
assert_true('read' in reader);
let read_value = await reader.read();
let read_value = await read_and_gc(reader, perform_gc);
let out = [];
let i = 0;
@ -19,7 +29,7 @@ async function read_all_chunks(stream) {
for (let val of read_value.value) {
out[i++] = val;
}
read_value = await reader.read();
read_value = await read_and_gc(reader, perform_gc);
}
return out;
}
@ -56,7 +66,7 @@ promise_test(async() => {
const stream = blob.stream();
blob = null;
garbageCollect();
const chunks = await read_all_chunks(stream);
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")