11cb0ef41Sopenharmony_ci// META: title=Blob Text
21cb0ef41Sopenharmony_ci// META: script=../support/Blob.js
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_cipromise_test(async () => {
61cb0ef41Sopenharmony_ci  const blob = new Blob(["PASS"]);
71cb0ef41Sopenharmony_ci  const text = await blob.text();
81cb0ef41Sopenharmony_ci  assert_equals(text, "PASS");
91cb0ef41Sopenharmony_ci}, "Blob.text()")
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cipromise_test(async () => {
121cb0ef41Sopenharmony_ci  const blob = new Blob();
131cb0ef41Sopenharmony_ci  const text = await blob.text();
141cb0ef41Sopenharmony_ci  assert_equals(text, "");
151cb0ef41Sopenharmony_ci}, "Blob.text() empty blob data")
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cipromise_test(async () => {
181cb0ef41Sopenharmony_ci  const blob = new Blob(["P", "A", "SS"]);
191cb0ef41Sopenharmony_ci  const text = await blob.text();
201cb0ef41Sopenharmony_ci  assert_equals(text, "PASS");
211cb0ef41Sopenharmony_ci}, "Blob.text() multi-element array in constructor")
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cipromise_test(async () => {
241cb0ef41Sopenharmony_ci  const non_unicode = "\u0061\u030A";
251cb0ef41Sopenharmony_ci  const input_arr = new TextEncoder().encode(non_unicode);
261cb0ef41Sopenharmony_ci  const blob = new Blob([input_arr]);
271cb0ef41Sopenharmony_ci  const text = await blob.text();
281cb0ef41Sopenharmony_ci  assert_equals(text, non_unicode);
291cb0ef41Sopenharmony_ci}, "Blob.text() non-unicode")
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_cipromise_test(async () => {
321cb0ef41Sopenharmony_ci  const blob = new Blob(["PASS"], { type: "text/plain;charset=utf-16le" });
331cb0ef41Sopenharmony_ci  const text = await blob.text();
341cb0ef41Sopenharmony_ci  assert_equals(text, "PASS");
351cb0ef41Sopenharmony_ci}, "Blob.text() different charset param in type option")
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_cipromise_test(async () => {
381cb0ef41Sopenharmony_ci  const non_unicode = "\u0061\u030A";
391cb0ef41Sopenharmony_ci  const input_arr = new TextEncoder().encode(non_unicode);
401cb0ef41Sopenharmony_ci  const blob = new Blob([input_arr], { type: "text/plain;charset=utf-16le" });
411cb0ef41Sopenharmony_ci  const text = await blob.text();
421cb0ef41Sopenharmony_ci  assert_equals(text, non_unicode);
431cb0ef41Sopenharmony_ci}, "Blob.text() different charset param with non-ascii input")
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_cipromise_test(async () => {
461cb0ef41Sopenharmony_ci  const input_arr = new Uint8Array([192, 193, 245, 246, 247, 248, 249, 250, 251,
471cb0ef41Sopenharmony_ci      252, 253, 254, 255]);
481cb0ef41Sopenharmony_ci  const blob = new Blob([input_arr]);
491cb0ef41Sopenharmony_ci  const text = await blob.text();
501cb0ef41Sopenharmony_ci  assert_equals(text, "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd" +
511cb0ef41Sopenharmony_ci      "\ufffd\ufffd\ufffd\ufffd");
521cb0ef41Sopenharmony_ci}, "Blob.text() invalid utf-8 input")
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_cipromise_test(async () => {
551cb0ef41Sopenharmony_ci  const input_arr = new Uint8Array([192, 193, 245, 246, 247, 248, 249, 250, 251,
561cb0ef41Sopenharmony_ci      252, 253, 254, 255]);
571cb0ef41Sopenharmony_ci  const blob = new Blob([input_arr]);
581cb0ef41Sopenharmony_ci  const text_results = await Promise.all([blob.text(), blob.text(),
591cb0ef41Sopenharmony_ci      blob.text()]);
601cb0ef41Sopenharmony_ci  for (let text of text_results) {
611cb0ef41Sopenharmony_ci    assert_equals(text, "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd" +
621cb0ef41Sopenharmony_ci        "\ufffd\ufffd\ufffd\ufffd");
631cb0ef41Sopenharmony_ci  }
641cb0ef41Sopenharmony_ci}, "Blob.text() concurrent reads")
65