aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js
diff options
context:
space:
mode:
authorWPT Sync Bot <josh+wptsync@joshmatthews.net>2019-04-15 21:58:05 -0400
committerWPT Sync Bot <josh+wptsync@joshmatthews.net>2019-04-16 00:29:32 -0400
commitc8202ddbe16fdb3894b8f725310096a345d6b37d (patch)
treec1f33904001632d9200f14dc6762d4c4c5a2fd6b /tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js
parent0ba7da443101f2c12e2b50473fe2165c35d52e99 (diff)
downloadservo-c8202ddbe16fdb3894b8f725310096a345d6b37d.tar.gz
servo-c8202ddbe16fdb3894b8f725310096a345d6b37d.zip
Update web-platform-tests to revision fd0429f0b45f975b25d85256dac33762134952c5
Diffstat (limited to 'tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js')
-rw-r--r--tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js
new file mode 100644
index 00000000000..960c9605462
--- /dev/null
+++ b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-text.any.js
@@ -0,0 +1,52 @@
+// 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")