diff --git a/testing/web-platform/tests/FileAPI/blob/Blob-array-buffer.any.js b/testing/web-platform/tests/FileAPI/blob/Blob-array-buffer.any.js index b72427fd5cfa..2310646e5fde 100644 --- a/testing/web-platform/tests/FileAPI/blob/Blob-array-buffer.any.js +++ b/testing/web-platform/tests/FileAPI/blob/Blob-array-buffer.any.js @@ -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") diff --git a/testing/web-platform/tests/FileAPI/blob/Blob-stream.any.js b/testing/web-platform/tests/FileAPI/blob/Blob-stream.any.js index 894f09f8ece4..bd4f8dc40bca 100644 --- a/testing/web-platform/tests/FileAPI/blob/Blob-stream.any.js +++ b/testing/web-platform/tests/FileAPI/blob/Blob-stream.any.js @@ -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") diff --git a/testing/web-platform/tests/FileAPI/blob/Blob-text.any.js b/testing/web-platform/tests/FileAPI/blob/Blob-text.any.js index 960c96054627..d04fa97cffe6 100644 --- a/testing/web-platform/tests/FileAPI/blob/Blob-text.any.js +++ b/testing/web-platform/tests/FileAPI/blob/Blob-text.any.js @@ -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")