summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/FileAPI/support
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/FileAPI/support
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/FileAPI/support')
-rw-r--r--testing/web-platform/tests/FileAPI/support/Blob.js49
-rw-r--r--testing/web-platform/tests/FileAPI/support/upload.txt1
2 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/FileAPI/support/Blob.js b/testing/web-platform/tests/FileAPI/support/Blob.js
new file mode 100644
index 000000000..1d66f23a6
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/support/Blob.js
@@ -0,0 +1,49 @@
+function test_blob(fn, expectations) {
+ var expected = expectations.expected,
+ type = expectations.type,
+ desc = expectations.desc;
+
+ var t = async_test(desc);
+ t.step(function() {
+ var blob = fn();
+ assert_true(blob instanceof Blob);
+ assert_false(blob instanceof File);
+ assert_equals(blob.type, type);
+ assert_equals(blob.size, expected.length);
+
+ var fr = new FileReader();
+ fr.onload = t.step_func_done(function(event) {
+ assert_equals(this.result, expected);
+ }, fr);
+ fr.onerror = t.step_func(function(e) {
+ assert_unreached("got error event on FileReader");
+ });
+ fr.readAsText(blob, "UTF-8");
+ });
+}
+
+function test_blob_binary(fn, expectations) {
+ var expected = expectations.expected,
+ type = expectations.type,
+ desc = expectations.desc;
+
+ var t = async_test(desc);
+ t.step(function() {
+ var blob = fn();
+ assert_true(blob instanceof Blob);
+ assert_false(blob instanceof File);
+ assert_equals(blob.type, type);
+ assert_equals(blob.size, expected.length);
+
+ var fr = new FileReader();
+ fr.onload = t.step_func_done(function(event) {
+ assert_true(this.result instanceof ArrayBuffer,
+ "Result should be an ArrayBuffer");
+ assert_array_equals(new Uint8Array(this.result), expected);
+ }, fr);
+ fr.onerror = t.step_func(function(e) {
+ assert_unreached("got error event on FileReader");
+ });
+ fr.readAsArrayBuffer(blob);
+ });
+}
diff --git a/testing/web-platform/tests/FileAPI/support/upload.txt b/testing/web-platform/tests/FileAPI/support/upload.txt
new file mode 100644
index 000000000..5ab2f8a43
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/support/upload.txt
@@ -0,0 +1 @@
+Hello \ No newline at end of file