Bug 1305230 - Splitting test_fileapi.html and test_fileapi_worker.html in multiple files, r=me
☠☠ backed out by daea2bcda8cb ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 13 Oct 2017 09:16:55 +0200
changeset 386128 a1407c6e9785c7b678ccfbbba09aca0f9e0cfffa
parent 386127 6c0e229ac2e85888be179d3126f51ff392b05eea
child 386129 b5b62b5edbee61873087c02de25fa67d242db501
push id32676
push userarchaeopteryx@coole-files.de
push dateFri, 13 Oct 2017 21:38:18 +0000
treeherdermozilla-central@a31334a65a1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1305230
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1305230 - Splitting test_fileapi.html and test_fileapi_worker.html in multiple files, r=me
dom/file/tests/common_fileReader.js
dom/file/tests/mochitest.ini
dom/file/tests/test_fileapi.html
dom/file/tests/test_fileapi_basic.html
dom/file/tests/test_fileapi_basic_worker.html
dom/file/tests/test_fileapi_encoding.html
dom/file/tests/test_fileapi_encoding_worker.html
dom/file/tests/test_fileapi_other.html
dom/file/tests/test_fileapi_other_worker.html
dom/file/tests/test_fileapi_twice.html
dom/file/tests/test_fileapi_twice_worker.html
dom/file/tests/test_fileapi_worker.html
dom/file/tests/worker_fileReader.js
--- a/dom/file/tests/common_fileReader.js
+++ b/dom/file/tests/common_fileReader.js
@@ -67,94 +67,98 @@ function test_setup() {
       "",
       dataurldata0,
       dataurldata1,
       dataurldata2,
     ]);
   });
 }
 
-function runTests(data) {
+function runBasicTests(data) {
   return test_basic()
     .then(() => {
       return test_readAsText(data.blobs.asciiFile, data.data.ascii);
     })
     .then(() => {
-      return test_readAsTextWithEncoding(data.blobs.asciiFile, data.data.ascii,
-                                         data.data.ascii.length, "");
+      return test_readAsBinaryString(data.blobs.binaryFile, data.data.binary);
     })
     .then(() => {
+      return test_readAsArrayBuffer(data.blobs.binaryFile, data.data.binary);
+    });
+}
+
+function runEncodingTests(data) {
+  return test_readAsTextWithEncoding(data.blobs.asciiFile, data.data.ascii,
+                                     data.data.ascii.length, "")
+    .then(() => {
       return test_readAsTextWithEncoding(data.blobs.asciiFile, data.data.ascii,
                                          data.data.ascii.length, "iso8859-1");
     })
     .then(() => {
       return test_readAsTextWithEncoding(data.blobs.utf8TextFile, data.data.text,
                                          convertToUTF8(data.data.text).length,
                                          "utf8");
     })
     .then(() => {
       return test_readAsTextWithEncoding(data.blobs.utf16TextFile, data.data.text,
                                          convertToUTF16(data.data.text).length,
                                          "utf-16");
     })
     .then(() => {
-      return test_readAsBinaryString(data.blobs.binaryFile, data.data.binary);
-    })
-    .then(() => {
-      return test_readAsArrayBuffer(data.blobs.binaryFile, data.data.binary);
-    })
-    .then(() => {
-      return test_onlyResult()
-    })
-    .then(() => {
-      return test_readAsText(data.blobs.emptyFile, "");
-    })
-    .then(() => {
       return test_readAsTextWithEncoding(data.blobs.emptyFile, "", 0, "");
     })
     .then(() => {
       return test_readAsTextWithEncoding(data.blobs.emptyFile, "", 0, "utf8");
     })
     .then(() => {
       return test_readAsTextWithEncoding(data.blobs.emptyFile, "", 0, "utf-16");
+    });
+}
+
+function runEmptyTests(data) {
+  return test_onlyResult()
+    .then(() => {
+      return test_readAsText(data.blobs.emptyFile, "");
     })
     .then(() => {
       return test_readAsBinaryString(data.blobs.emptyFile, "");
     })
     .then(() => {
       return test_readAsArrayBuffer(data.blobs.emptyFile, "");
     })
     .then(() => {
       return test_readAsDataURL(data.blobs.emptyFile, convertToDataURL(""), 0);
-    })
-    .then(() => {
-      return test_readAsTextTwice(data.blobs.asciiFile, data.data.ascii);
-    })
+    });
+}
+
+function runTwiceTests(data) {
+  return test_readAsTextTwice(data.blobs.asciiFile, data.data.ascii)
     .then(() => {
       return test_readAsBinaryStringTwice(data.blobs.binaryFile,
                                           data.data.binary);
     })
     .then(() => {
       return test_readAsDataURLTwice(data.blobs.binaryFile,
                                      convertToDataURL(data.data.binary),
                                      data.data.binary.length);
     })
     .then(() => {
       return test_readAsArrayBufferTwice(data.blobs.binaryFile,
                                          data.data.binary);
     })
     .then(() => {
       return test_readAsArrayBufferTwice2(data.blobs.binaryFile,
                                           data.data.binary);
-    })
-    .then(() => {
-      return test_readAsDataURL_customLength(data.blobs.dataUrlFile0,
-                                             convertToDataURL(data.data.url0),
-                                             data.data.url0.length, 0);
-    })
+    });
+}
+
+function runOtherTests(data) {
+  return test_readAsDataURL_customLength(data.blobs.dataUrlFile0,
+                                         convertToDataURL(data.data.url0),
+                                         data.data.url0.length, 0)
     .then(() => {
       return test_readAsDataURL_customLength(data.blobs.dataUrlFile1,
                                              convertToDataURL(data.data.url1),
                                              data.data.url1.length, 1);
     })
     .then(() => {
       return test_readAsDataURL_customLength(data.blobs.dataUrlFile2,
                                              convertToDataURL(data.data.url2),
@@ -505,17 +509,17 @@ function test_abort(blob) {
   });
 }
 
 // Test calling readAsX to cause abort()
 function test_abort_readAsX(blob, text) {
   return new Promise(resolve => {
     let reuseAbortHasRun = false;
 
-    letr = new FileReader();
+    let r = new FileReader();
     r.onabort = function (event) {
       is(reuseAbortHasRun, false, "abort should only fire once");
       reuseAbortHasRun = true;
       is(event.target.readyState, FileReader.DONE, "should be DONE while firing onabort");
       is(event.target.error.name, "AbortError", "error set to AbortError for aborted reads");
       is(event.target.result, null, "file data should be null on aborted reads");
     }
     r.onload = function() { ok(false, "load should fire for nested reads"); };
--- a/dom/file/tests/mochitest.ini
+++ b/dom/file/tests/mochitest.ini
@@ -17,18 +17,24 @@ support-files =
 [test_blob_fragment_and_query.html]
 [test_blobconstructor.html]
 [test_blobURL_expiring.html]
 [test_file_from_blob.html]
 [test_ipc_messagemanager_blob.html]
 support-files = file_ipc_messagemanager_blob.html
 [test_nonascii_blob_url.html]
 [test_file_negative_date.html]
-[test_fileapi.html]
-[test_fileapi_worker.html]
+[test_fileapi_basic.html]
+[test_fileapi_encoding.html]
+[test_fileapi_twice.html]
+[test_fileapi_other.html]
+[test_fileapi_basic_worker.html]
+[test_fileapi_encoding_worker.html]
+[test_fileapi_twice_worker.html]
+[test_fileapi_other_worker.html]
 support-files = worker_fileReader.js
 [test_fileapi_slice.html]
 skip-if = (toolkit == 'android') # Android: Bug 775227
 [test_fileapi_slice2.html]
 skip-if = (toolkit == 'android') # Android: Bug 775227
 [test_fileapi_slice_image.html]
 skip-if = (toolkit == 'android') # Android: Bug 775227
 [test_mozfiledataurl.html]
rename from dom/file/tests/test_fileapi.html
rename to dom/file/tests/test_fileapi_basic.html
--- a/dom/file/tests/test_fileapi.html
+++ b/dom/file/tests/test_fileapi_basic.html
@@ -9,15 +9,15 @@
 
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
-  return runTests(data);
+  return runBasicTests(data);
 })
 .then(SimpleTest.finish);
 
 </script>
 </body>
 </html>
rename from dom/file/tests/test_fileapi_worker.html
rename to dom/file/tests/test_fileapi_basic_worker.html
--- a/dom/file/tests/test_fileapi_worker.html
+++ b/dom/file/tests/test_fileapi_basic_worker.html
@@ -10,17 +10,17 @@
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
   let worker = new Worker('worker_fileReader.js');
-  worker.postMessage(data);
+  worker.postMessage({ tests: 'basic', data });
 
   worker.onmessage = event => {
     if (event.data.type == 'finish') {
       SimpleTest.finish();
       return;
     }
 
     if (event.data.type == 'check') {
copy from dom/file/tests/test_fileapi.html
copy to dom/file/tests/test_fileapi_encoding.html
--- a/dom/file/tests/test_fileapi.html
+++ b/dom/file/tests/test_fileapi_encoding.html
@@ -9,15 +9,15 @@
 
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
-  return runTests(data);
+  return runEncodingTests(data);
 })
 .then(SimpleTest.finish);
 
 </script>
 </body>
 </html>
copy from dom/file/tests/test_fileapi_worker.html
copy to dom/file/tests/test_fileapi_encoding_worker.html
--- a/dom/file/tests/test_fileapi_worker.html
+++ b/dom/file/tests/test_fileapi_encoding_worker.html
@@ -10,17 +10,17 @@
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
   let worker = new Worker('worker_fileReader.js');
-  worker.postMessage(data);
+  worker.postMessage({ tests: 'encoding', data });
 
   worker.onmessage = event => {
     if (event.data.type == 'finish') {
       SimpleTest.finish();
       return;
     }
 
     if (event.data.type == 'check') {
copy from dom/file/tests/test_fileapi.html
copy to dom/file/tests/test_fileapi_other.html
--- a/dom/file/tests/test_fileapi.html
+++ b/dom/file/tests/test_fileapi_other.html
@@ -9,15 +9,15 @@
 
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
-  return runTests(data);
+  return runOtherTests(data);
 })
 .then(SimpleTest.finish);
 
 </script>
 </body>
 </html>
copy from dom/file/tests/test_fileapi_worker.html
copy to dom/file/tests/test_fileapi_other_worker.html
--- a/dom/file/tests/test_fileapi_worker.html
+++ b/dom/file/tests/test_fileapi_other_worker.html
@@ -10,17 +10,17 @@
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
   let worker = new Worker('worker_fileReader.js');
-  worker.postMessage(data);
+  worker.postMessage({ tests: 'other', data });
 
   worker.onmessage = event => {
     if (event.data.type == 'finish') {
       SimpleTest.finish();
       return;
     }
 
     if (event.data.type == 'check') {
copy from dom/file/tests/test_fileapi.html
copy to dom/file/tests/test_fileapi_twice.html
--- a/dom/file/tests/test_fileapi.html
+++ b/dom/file/tests/test_fileapi_twice.html
@@ -9,15 +9,15 @@
 
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
-  return runTests(data);
+  return runTwiceTests(data);
 })
 .then(SimpleTest.finish);
 
 </script>
 </body>
 </html>
copy from dom/file/tests/test_fileapi_worker.html
copy to dom/file/tests/test_fileapi_twice_worker.html
--- a/dom/file/tests/test_fileapi_worker.html
+++ b/dom/file/tests/test_fileapi_twice_worker.html
@@ -10,17 +10,17 @@
 <body>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 test_setup()
 .then(data => {
   let worker = new Worker('worker_fileReader.js');
-  worker.postMessage(data);
+  worker.postMessage({ tests: 'twice', data });
 
   worker.onmessage = event => {
     if (event.data.type == 'finish') {
       SimpleTest.finish();
       return;
     }
 
     if (event.data.type == 'check') {
--- a/dom/file/tests/worker_fileReader.js
+++ b/dom/file/tests/worker_fileReader.js
@@ -4,12 +4,27 @@ function ok(a, msg) {
   postMessage({type:'check', msg, status: !!a});
 }
 
 function is(a, b, msg) {
   ok(a === b, msg);
 }
 
 onmessage = event => {
-  runTests(event.data).then(() => {
+  let p;
+
+  if (event.data.tests == 'basic') {
+    p = runBasicTests(event.data.data);
+  } else if (event.data.tests == 'encoding') {
+    p = runEncodingTests(event.data.data);
+  } else if (event.data.tests == 'twice') {
+    p = runTwiceTests(event.data.data);
+  } else if (event.data.tests == 'other') {
+    p = runOtherTests(event.data.data);
+  } else {
+    postMessage({type: 'error'});
+    return;
+  }
+
+  p.then(() => {
     postMessage({ type: 'finish' });
   });
 };