summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/FileAPI/reading-data-section
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/reading-data-section
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/reading-data-section')
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/Determining-Encoding.html91
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/FileReader-event-handler-attributes.html23
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/FileReader-multiple-reads.html73
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_abort.html46
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_error.html35
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_file-manual.html69
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_file_img-manual.html47
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html38
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsDataURL.html39
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsText.html51
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_readystate.html34
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/filereader_result.html59
-rw-r--r--testing/web-platform/tests/FileAPI/reading-data-section/support/blue-100x100.pngbin0 -> 227 bytes
13 files changed, 605 insertions, 0 deletions
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/Determining-Encoding.html b/testing/web-platform/tests/FileAPI/reading-data-section/Determining-Encoding.html
new file mode 100644
index 000000000..d65ae9db1
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/Determining-Encoding.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>FileAPI Test: Blob Determining Encoding</title>
+<link ref="author" title="march1993" href="mailto:march511@gmail.com">
+<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#enctype">
+<link rel=help href="http://encoding.spec.whatwg.org/#decode">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test("Blob Determing Encoding with encoding argument");
+t.step(function() {
+ // string 'hello'
+ var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F];
+ var blob = new Blob([new Uint8Array(data)]);
+ var reader = new FileReader();
+
+ reader.onloadend = t.step_func_done (function(event) {
+ assert_equals(this.result, "hello", "The FileReader should read the ArrayBuffer through UTF-16BE.")
+ }, reader);
+
+ reader.readAsText(blob, "UTF-16BE");
+});
+
+var t = async_test("Blob Determing Encoding with type attribute");
+t.step(function() {
+ var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F];
+ var blob = new Blob([new Uint8Array(data)], {type:"text/plain;charset=UTF-16BE"});
+ var reader = new FileReader();
+
+ reader.onloadend = t.step_func_done (function(event) {
+ assert_equals(this.result, "hello", "The FileReader should read the ArrayBuffer through UTF-16BE.")
+ }, reader);
+
+ reader.readAsText(blob);
+});
+
+
+var t = async_test("Blob Determing Encoding with UTF-8 BOM");
+t.step(function() {
+ var data = [0xEF,0xBB,0xBF,0x68,0x65,0x6C,0x6C,0xC3,0xB6];
+ var blob = new Blob([new Uint8Array(data)]);
+ var reader = new FileReader();
+
+ reader.onloadend = t.step_func_done (function(event) {
+ assert_equals(this.result, "hellö", "The FileReader should read the blob with UTF-8.");
+ }, reader);
+
+ reader.readAsText(blob);
+});
+
+var t = async_test("Blob Determing Encoding without anything implying charset.");
+t.step(function() {
+ var data = [0x68,0x65,0x6C,0x6C,0xC3,0xB6];
+ var blob = new Blob([new Uint8Array(data)]);
+ var reader = new FileReader();
+
+ reader.onloadend = t.step_func_done (function(event) {
+ assert_equals(this.result, "hellö", "The FileReader should read the blob by default with UTF-8.");
+ }, reader);
+
+ reader.readAsText(blob);
+});
+
+var t = async_test("Blob Determing Encoding with UTF-16BE BOM");
+t.step(function() {
+ var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F];
+ var blob = new Blob([new Uint8Array(data)]);
+ var reader = new FileReader();
+
+ reader.onloadend = t.step_func_done (function(event) {
+ assert_equals(this.result, "hello", "The FileReader should read the ArrayBuffer through UTF-16BE.");
+ }, reader);
+
+ reader.readAsText(blob);
+});
+
+var t = async_test("Blob Determing Encoding with UTF-16LE BOM");
+t.step(function() {
+ var data = [0xFF,0xFE,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F,0x00];
+ var blob = new Blob([new Uint8Array(data)]);
+ var reader = new FileReader();
+
+ reader.onloadend = t.step_func_done (function(event) {
+ assert_equals(this.result, "hello", "The FileReader should read the ArrayBuffer through UTF-16LE.");
+ }, reader);
+
+ reader.readAsText(blob);
+});
+
+</script>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/FileReader-event-handler-attributes.html b/testing/web-platform/tests/FileAPI/reading-data-section/FileReader-event-handler-attributes.html
new file mode 100644
index 000000000..86657b571
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/FileReader-event-handler-attributes.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>FileReader event handler attributes</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var attributes = [
+ "onloadstart",
+ "onprogress",
+ "onload",
+ "onabort",
+ "onerror",
+ "onloadend",
+];
+attributes.forEach(function(a) {
+ test(function() {
+ var reader = new FileReader();
+ assert_equals(reader[a], null,
+ "event handler attribute should initially be null");
+ }, "FileReader." + a + ": initial value");
+});
+</script>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/FileReader-multiple-reads.html b/testing/web-platform/tests/FileAPI/reading-data-section/FileReader-multiple-reads.html
new file mode 100644
index 000000000..86a29d187
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/FileReader-multiple-reads.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<title>FileReader: starting new reads while one is in progress</title>
+<link rel="author" title="Yinkan Li" href="mailto:liyinkan.biz@gmail.com">
+<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#MultipleReads">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var blob_1 = new Blob(['TEST000000001'])
+ var blob_2 = new Blob(['TEST000000002'])
+ var reader = new FileReader();
+ reader.readAsText(blob_1)
+ assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
+ assert_throws("InvalidStateError", function () {
+ reader.readAsText(blob_2)
+ })
+}, 'test FileReader InvalidStateError exception for readAsText');
+
+test(function() {
+ var blob_1 = new Blob(['TEST000000001'])
+ var blob_2 = new Blob(['TEST000000002'])
+ var reader = new FileReader();
+ reader.readAsDataURL(blob_1)
+ assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
+ assert_throws("InvalidStateError", function () {
+ reader.readAsDataURL(blob_2)
+ })
+}, 'test FileReader InvalidStateError exception for readAsDataURL');
+
+test(function() {
+ var blob_1 = new Blob(['TEST000000001'])
+ var blob_2 = new Blob(['TEST000000002'])
+ var reader = new FileReader();
+ reader.readAsArrayBuffer(blob_1)
+ assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
+ assert_throws("InvalidStateError", function () {
+ reader.readAsArrayBuffer(blob_2)
+ })
+}, 'test FileReader InvalidStateError exception for readAsArrayBuffer');
+
+async_test(function() {
+ var blob_1 = new Blob(['TEST000000001'])
+ var blob_2 = new Blob(['TEST000000002'])
+ var reader = new FileReader();
+ var triggered = false;
+ reader.onloadstart = this.step_func_done(function() {
+ assert_false(triggered, "Only one loadstart event should be dispatched");
+ triggered = true;
+ assert_equals(reader.readyState, FileReader.LOADING,
+ "readyState must be LOADING")
+ assert_throws("InvalidStateError", function () {
+ reader.readAsArrayBuffer(blob_2)
+ })
+ });
+ reader.readAsArrayBuffer(blob_1)
+ assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
+}, 'test FileReader InvalidStateError exception in onloadstart event for readAsArrayBuffer');
+
+async_test(function() {
+ var blob_1 = new Blob(['TEST000000001'])
+ var blob_2 = new Blob(['TEST000000002'])
+ var reader = new FileReader();
+ reader.onloadend = this.step_func_done(function() {
+ assert_equals(reader.readyState, FileReader.LOADING,
+ "readyState must be LOADING")
+ reader.readAsArrayBuffer(blob_2)
+ assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
+ });
+ reader.readAsArrayBuffer(blob_1)
+ assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
+}, 'test FileReader no InvalidStateError exception in onloadstart event for readAsArrayBuffer');
+</script>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_abort.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_abort.html
new file mode 100644
index 000000000..a96389c21
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_abort.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_abort</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#abort">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ test(function() {
+ var readerNoRead = new FileReader();
+ readerNoRead.abort();
+ assert_equals(readerNoRead.readyState, readerNoRead.EMPTY);
+ assert_equals(readerNoRead.result, null);
+ }, "Aborting before read");
+
+ async_test(function() {
+ var blob = new Blob(["TEST THE ABORT METHOD"]);
+ var readerAbort = new FileReader();
+
+ readerAbort.onabort = this.step_func(function(evt) {
+ assert_equals(readerAbort.readyState, readerAbort.DONE);
+ });
+
+ readerAbort.onloadstart = this.step_func(function(evt) {
+ assert_equals(readerAbort.readyState, readerAbort.LOADING);
+ readerAbort.abort();
+ });
+
+ readerAbort.onloadend = this.step_func(function(evt) {
+ // https://www.w3.org/Bugs/Public/show_bug.cgi?id=24401
+ assert_equals(readerAbort.result, null);
+ assert_equals(readerAbort.readyState, readerAbort.DONE);
+ this.done();
+ });
+
+ readerAbort.readAsText(blob);
+ }, "Aborting after read");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_error.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_error.html
new file mode 100644
index 000000000..cf4524825
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_error.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_error</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-domerror">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#abort">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ async_test(function() {
+ var blob = new Blob(["TEST THE ERROR ATTRIBUTE AND ERROR EVENT"]);
+ var reader = new FileReader();
+ assert_equals(reader.error, null, "The error is null when no error occurred");
+
+ reader.onload = this.step_func(function(evt) {
+ assert_unreached("Should not dispatch the load event");
+ });
+
+ reader.onloadend = this.step_func(function(evt) {
+ assert_equals(reader.result, null, "The result is null");
+ this.done();
+ });
+
+ reader.readAsText(blob);
+ reader.abort();
+ });
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_file-manual.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_file-manual.html
new file mode 100644
index 000000000..702ca9afd
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_file-manual.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_file</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#FileReader-interface">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#file">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div>
+ <p>Test step:</p>
+ <ol>
+ <li>Download <a href="support/blue-100x100.png">blue-100x100.png</a> to local.</li>
+ <li>Select the local file (blue-100x100.png) to run the test.</li>
+ </ol>
+ </div>
+
+ <form name="uploadData">
+ <input type="file" id="fileChooser">
+ </form>
+
+ <div id="log"></div>
+ <script>
+ var fileInput = document.querySelector('#fileChooser');
+ var reader = new FileReader();
+
+ //readType: 1-> ArrayBuffer, 2-> Text, 3-> DataURL
+ var readType = 1;
+
+ setup({
+ explicit_done: true,
+ explicit_timeout: true,
+ });
+
+ on_event(fileInput, "change", function(evt) {
+ reader.readAsArrayBuffer(fileInput.files[0]);
+ });
+
+ on_event(reader, "load", function(evt) {
+ if (readType == 1) {
+ test(function() {
+ assert_true(reader.result instanceof ArrayBuffer, "The result is instanceof ArrayBuffer");
+ }, "Check if the readAsArrayBuffer works");
+
+ readType++;
+ reader.readAsText(fileInput.files[0]);
+ } else if (readType == 2) {
+ test(function() {
+ assert_equals(typeof reader.result, "string", "The result is typeof string");
+ }, "Check if the readAsText works");
+
+ readType++;
+ reader.readAsDataURL(fileInput.files[0]);
+ } else if (readType == 3) {
+ test(function() {
+ assert_equals(typeof reader.result, "string", "The result is typeof string");
+ assert_equals(reader.result.indexOf("data"), 0, "The result starts with 'data'");
+ assert_true(reader.result.indexOf("base64") > 0, "The result contains 'base64'");
+ }, "Check if the readAsDataURL works");
+
+ done();
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_file_img-manual.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_file_img-manual.html
new file mode 100644
index 000000000..fca42c7fc
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_file_img-manual.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_file_img</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#FileReader-interface">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#file">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div>
+ <p>Test step:</p>
+ <ol>
+ <li>Download <a href="support/blue-100x100.png">blue-100x100.png</a> to local.</li>
+ <li>Select the local file (blue-100x100.png) to run the test.</li>
+ </ol>
+ </div>
+
+ <form name="uploadData">
+ <input type="file" id="fileChooser">
+ </form>
+
+ <div id="log"></div>
+ <script>
+ var fileInput = document.querySelector('#fileChooser');
+ var reader = new FileReader();
+
+ setup({
+ explicit_done: true,
+ explicit_timeout: true,
+ });
+
+ fileInput.addEventListener("change", function(evt) {
+ reader.readAsDataURL(fileInput.files[0]);
+ }, false);
+
+ reader.addEventListener("loadend", function(evt) {
+ test(function () {
+ assert_true(reader.result.indexOf("iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAqklEQVR42u3RsREAMAgDMe+/M4E7ZkhBoeI9gJWkWpfaeToTECACAkRAgAgIEAEB4gQgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgAgJEQIAICBABASIgQJwARECACAgQ/W4AQauujc8IdAoAAAAASUVORK5CYII=") != -1, "Encoded image")
+ }, "Check if readAsDataURL returns correct image");
+ done();
+ }, false);
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html
new file mode 100644
index 000000000..31001a51a
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsArrayBuffer.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_readAsArrayBuffer</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#readAsArrayBuffer">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ async_test(function() {
+ var blob = new Blob(["TEST"]);
+ var reader = new FileReader();
+
+ reader.onload = this.step_func(function(evt) {
+ assert_equals(reader.result.byteLength, 4, "The byteLength is 4");
+ assert_true(reader.result instanceof ArrayBuffer, "The result is instanceof ArrayBuffer");
+ assert_equals(reader.readyState, reader.DONE);
+ this.done();
+ });
+
+ reader.onloadstart = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING);
+ });
+
+ reader.onprogress = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING);
+ });
+
+ reader.readAsArrayBuffer(blob);
+ });
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsDataURL.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsDataURL.html
new file mode 100644
index 000000000..f0a3957e7
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsDataURL.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_readAsDataURL</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#readAsDataURL">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ async_test(function() {
+ var blob = new Blob(["TEST"]);
+ var reader = new FileReader();
+
+ reader.onload = this.step_func(function(evt) {
+ assert_equals(typeof reader.result, "string", "The result is string");
+ assert_equals(reader.result.indexOf("data:"), 0, "The result attribute starts with 'data'");
+ assert_true(reader.result.indexOf("base64") > 0, "The result attribute contains 'base64'");
+ assert_equals(reader.readyState, reader.DONE);
+ this.done();
+ });
+
+ reader.onloadstart = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING);
+ });
+
+ reader.onprogress = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING);
+ });
+
+ reader.readAsDataURL(blob);
+ });
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsText.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsText.html
new file mode 100644
index 000000000..7d639d011
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsText.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_readAsText</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#readAsDataText">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ async_test(function() {
+ var blob = new Blob(["TEST"]);
+ var reader = new FileReader();
+
+ reader.onload = this.step_func(function(evt) {
+ assert_equals(typeof reader.result, "string", "The result is typeof string");
+ assert_equals(reader.result, "TEST", "The result is TEST");
+ this.done();
+ });
+
+ reader.onloadstart = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING, "The readyState");
+ });
+
+ reader.onprogress = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING);
+ });
+
+ reader.readAsText(blob);
+ }, "readAsText should correctly read UTF-8.");
+
+ async_test(function() {
+ var blob = new Blob(["TEST"]);
+ var reader = new FileReader();
+ var reader_UTF16 = new FileReader();
+ reader_UTF16.onload = this.step_func(function(evt) {
+ // "TEST" in UTF-8 is 0x54 0x45 0x53 0x54.
+ // Decoded as utf-16 (little-endian), we get 0x4554 0x5453.
+ assert_equals(reader_UTF16.readyState, reader.DONE, "The readyState");
+ assert_equals(reader_UTF16.result, "\u4554\u5453", "The result is not TEST");
+ this.done();
+ });
+ reader_UTF16.readAsText(blob, "UTF-16");
+ }, "readAsText should correctly read UTF-16.");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readystate.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readystate.html
new file mode 100644
index 000000000..1586b8995
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readystate.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_readystate</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#blobreader-state">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ async_test(function() {
+ var blob = new Blob(["THIS TEST THE READYSTATE WHEN READ BLOB"]);
+ var reader = new FileReader();
+
+ assert_equals(reader.readyState, reader.EMPTY);
+
+ reader.onloadstart = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.LOADING);
+ });
+
+ reader.onloadend = this.step_func(function(evt) {
+ assert_equals(reader.readyState, reader.DONE);
+ this.done();
+ });
+
+ reader.readAsDataURL(blob);
+ });
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/filereader_result.html b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_result.html
new file mode 100644
index 000000000..957d0337a
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/filereader_result.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>FileAPI Test: filereader_result</title>
+ <link rel="author" title="Intel" href="http://www.intel.com">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#filedata-attr">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+
+ <script>
+ var blob;
+ setup(function() {
+ blob = new Blob(["This test the result attribute"]);
+ });
+
+ async_test(function() {
+ var readText = new FileReader();
+ assert_equals(readText.result, null);
+
+ readText.onloadend = this.step_func(function(evt) {
+ assert_equals(typeof readText.result, "string", "The result type is string");
+ assert_equals(readText.result, "This test the result attribute", "The result is correct");
+ this.done();
+ });
+
+ readText.readAsText(blob);
+ }, "readAsText");
+
+ async_test(function() {
+ var readDataURL = new FileReader();
+ assert_equals(readDataURL.result, null);
+
+ readDataURL.onloadend = this.step_func(function(evt) {
+ assert_equals(typeof readDataURL.result, "string", "The result type is string");
+ assert_true(readDataURL.result.indexOf("VGhpcyB0ZXN0IHRoZSByZXN1bHQgYXR0cmlidXRl") != -1, "return the right base64 string");
+ this.done();
+ });
+
+ readDataURL.readAsDataURL(blob);
+ }, "readAsDataURL");
+
+ async_test(function() {
+ var readArrayBuffer = new FileReader();
+ assert_equals(readArrayBuffer.result, null);
+
+ readArrayBuffer.onloadend = this.step_func(function(evt) {
+ assert_true(readArrayBuffer.result instanceof ArrayBuffer, "The result is instanceof ArrayBuffer");
+ this.done();
+ });
+
+ readArrayBuffer.readAsArrayBuffer(blob);
+ }, "readAsArrayBuffer");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/FileAPI/reading-data-section/support/blue-100x100.png b/testing/web-platform/tests/FileAPI/reading-data-section/support/blue-100x100.png
new file mode 100644
index 000000000..5748719ff
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/reading-data-section/support/blue-100x100.png
Binary files differ