Bug 1358230 - test_formSubmission.html must delete its temporary files and directories, r=qdot
☠☠ backed out by d8fb7831a005 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 20 Apr 2017 23:32:55 +0200
changeset 566337 16ec1022fb843058d71f8f74710e93ddf78ccaa1
parent 566336 0215b10785da65b35be75f193056b14e4434f259
child 566338 5ba7199ef8388481eff4f519c84ec2f61619bd01
push id55180
push userjjong@mozilla.com
push dateFri, 21 Apr 2017 09:36:13 +0000
reviewersqdot
bugs1358230
milestone55.0a1
Bug 1358230 - test_formSubmission.html must delete its temporary files and directories, r=qdot
dom/filesystem/compat/tests/test_formSubmission.html
--- a/dom/filesystem/compat/tests/test_formSubmission.html
+++ b/dom/filesystem/compat/tests/test_formSubmission.html
@@ -14,16 +14,17 @@
       method="POST" enctype="multipart/form-data">
 </form>
 
 <script class="testbody" type="text/javascript">
 
 var form;
 var iframe;
 var input;
+var script;
 var xhr;
 
 function setup_tests() {
   form = document.getElementById("form");
 
   iframe = document.getElementById("target_iframe");
   iframe.onload = function() {
     info("Frame loaded!");
@@ -32,47 +33,54 @@ function setup_tests() {
 
   SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
                                      ["dom.webkitBlink.dirPicker.enabled", true],
                                      ["dom.filesystem.pathcheck.disabled", true],
                                      ["dom.webkitBlink.filesystem.enabled", true]]}, next);
 }
 
 function populate_entries(webkitDirectory) {
+  var url = SimpleTest.getTestFileURL("script_entries.js");
+  script = SpecialPowers.loadChromeScript(url);
+
   if (input) {
     form.removeChild(input);
   }
 
   input = document.createElement('input');
   input.setAttribute('id', 'input');
   input.setAttribute('type', 'file');
   input.setAttribute('name', 'input');
 
   if (webkitDirectory) {
     input.setAttribute('webkitdirectory', 'true');
   }
 
   form.appendChild(input);
 
-  var url = SimpleTest.getTestFileURL("script_entries.js");
-  var script = SpecialPowers.loadChromeScript(url);
-
   function onOpened(message) {
     input.addEventListener("change", function() {
       next();
     }, {once: true});
 
     SpecialPowers.wrap(input).mozSetDndFilesAndDirectories([message.data[0]]);
-    script.destroy();
   }
 
   script.addMessageListener("entries.opened", onOpened);
   script.sendAsyncMessage("entries.open");
 }
 
+function delete_entries() {
+  script.sendAsyncMessage("entries.delete");
+  script.addMessageListener("entries.deleted", function() {
+    script.destroy();
+    next();
+  });
+}
+
 function setup_plain() {
   info("Preparing for a plain text submission...");
   form.action = "../../../html/test/form_submit_server.sjs?plain";
   form.method = "POST";
   form.enctype = "text/plain";
   form.submit();
 }
 
@@ -209,16 +217,17 @@ function test_webkit_multipart() {
       }
     }
     next();
   });
 }
 
 var tests = [
   setup_tests,
+
   function() { populate_entries(false); },
 
   setup_plain,
   test_plain,
 
   setup_urlencoded,
   test_urlencoded,
 
@@ -226,32 +235,36 @@ var tests = [
   test_urlencoded,
 
   setup_urlencoded_empty,
   test_urlencoded,
 
   setup_formData,
   test_multipart,
 
+  delete_entries,
+
   function() { populate_entries(true); },
 
   setup_plain,
   test_webkit_plain,
 
   setup_urlencoded,
   test_webkit_urlencoded,
 
   setup_urlencoded_get,
   test_webkit_urlencoded,
 
   setup_urlencoded_empty,
   test_webkit_urlencoded,
 
   setup_formData,
   test_webkit_multipart,
+
+  delete_entries,
 ];
 
 function next() {
   if (!tests.length) {
     SimpleTest.finish();
     return;
   }