forked from mirrors/gecko-dev
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
64 lines
2.2 KiB
JavaScript
64 lines
2.2 KiB
JavaScript
// META: title=Blob Text
|
|
// META: script=../support/Blob.js
|
|
'use strict';
|
|
|
|
promise_test(async () => {
|
|
const blob = new Blob(["PASS"]);
|
|
const text = await blob.text();
|
|
assert_equals(text, "PASS");
|
|
}, "Blob.text()")
|
|
|
|
promise_test(async () => {
|
|
const blob = new Blob();
|
|
const text = await blob.text();
|
|
assert_equals(text, "");
|
|
}, "Blob.text() empty blob data")
|
|
|
|
promise_test(async () => {
|
|
const blob = new Blob(["P", "A", "SS"]);
|
|
const text = await blob.text();
|
|
assert_equals(text, "PASS");
|
|
}, "Blob.text() multi-element array in constructor")
|
|
|
|
promise_test(async () => {
|
|
const non_unicode = "\u0061\u030A";
|
|
const input_arr = new TextEncoder().encode(non_unicode);
|
|
const blob = new Blob([input_arr]);
|
|
const text = await blob.text();
|
|
assert_equals(text, non_unicode);
|
|
}, "Blob.text() non-unicode")
|
|
|
|
promise_test(async () => {
|
|
const blob = new Blob(["PASS"], { type: "text/plain;charset=utf-16le" });
|
|
const text = await blob.text();
|
|
assert_equals(text, "PASS");
|
|
}, "Blob.text() different charset param in type option")
|
|
|
|
promise_test(async () => {
|
|
const non_unicode = "\u0061\u030A";
|
|
const input_arr = new TextEncoder().encode(non_unicode);
|
|
const blob = new Blob([input_arr], { type: "text/plain;charset=utf-16le" });
|
|
const text = await blob.text();
|
|
assert_equals(text, non_unicode);
|
|
}, "Blob.text() different charset param with non-ascii 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 = await blob.text();
|
|
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")
|