Bug 1068838 - Fix file input element tests to open files in the parent process. r=sicking
authorJed Davis <jld@mozilla.com>
Mon, 26 Jan 2015 16:23:00 -0800
changeset 239219 a0f9be26c71e854ab8223bdae6f019ec3cd11dc2
parent 239218 f9131ff0a89b6c8f1c1c6c20610db71ee531780a
child 239220 08f5812826e7bbfe02325782e0199ebf85ce4226
push id489
push usermcmanus@ducksong.com
push dateTue, 27 Jan 2015 01:44:53 +0000
reviewerssicking
bugs1068838
milestone38.0a1
Bug 1068838 - Fix file input element tests to open files in the parent process. r=sicking The dom/base tests changed here use SpecialPowers.loadChromeScript to construct a DOM File in the parent and send it to the child, using the existing remote-blob infrastructure. The dom/html tests don't need a real file, so they now construct in-memory files. As a convenient side-effect, these tests are now enabled for desktop e10s (they were already being run out-of-process on B2G); most of them failed before this change due to the code that's being moved/removed.
dom/base/test/bug403852_fileOpener.js
dom/base/test/bug578096LoadChromeScript.js
dom/base/test/fileapi_chromeScript.js
dom/base/test/mochitest.ini
dom/base/test/test_bug403852.html
dom/base/test/test_bug578096.html
dom/base/test/test_fileapi.html
dom/html/test/mochitest.ini
dom/html/test/test_bug590353-2.html
dom/html/test/test_bug598643.html
new file mode 100644
--- /dev/null
+++ b/dom/base/test/bug403852_fileOpener.js
@@ -0,0 +1,15 @@
+const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+Cu.importGlobalProperties(["File"]);
+
+let testFile = Cc["@mozilla.org/file/directory_service;1"]
+                 .getService(Ci.nsIDirectoryService)
+                 .QueryInterface(Ci.nsIProperties)
+                 .get("ProfD", Ci.nsIFile);
+testFile.append("prefs.js");
+
+addMessageListener("file.open", function () {
+  sendAsyncMessage("file.opened", {
+    file: new File(testFile),
+    mtime: testFile.lastModifiedTime,
+  });
+});
--- a/dom/base/test/bug578096LoadChromeScript.js
+++ b/dom/base/test/bug578096LoadChromeScript.js
@@ -1,14 +1,16 @@
 var file;
+Components.utils.importGlobalProperties(["File"]);
+
 addMessageListener("file.create", function (message) {
   file = Components.classes["@mozilla.org/file/directory_service;1"]
              .getService(Components.interfaces.nsIProperties)
              .get("TmpD", Components.interfaces.nsIFile);
   file.append("foo.txt");
   file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
-  sendAsyncMessage("file.path", file.path);
+  sendAsyncMessage("file.created", new File(file));
 });
 
 addMessageListener("file.remove", function (message) {
   file.remove(false);
   sendAsyncMessage("file.removed", {});
 });
new file mode 100644
--- /dev/null
+++ b/dom/base/test/fileapi_chromeScript.js
@@ -0,0 +1,29 @@
+const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+Cu.importGlobalProperties(["File"]);
+
+var fileNum = 1;
+
+function createFileWithData(fileData) {
+  var willDelete = fileData === null;
+  var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
+  var testFile = dirSvc.get("ProfD", Ci.nsIFile);
+  testFile.append("fileAPItestfile" + fileNum);
+  fileNum++;
+  var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
+  outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
+                 0666, 0);
+  if (willDelete) {
+    fileData = "some irrelevant test data\n";
+  }
+  outStream.write(fileData, fileData.length);
+  outStream.close();
+  var domFile = new File(testFile);
+  if (willDelete) {
+    testFile.remove(/* recursive: */ false);
+  }
+  return domFile;
+}
+
+addMessageListener("files.open", function (message) {
+  sendAsyncMessage("files.opened", message.map(createFileWithData));
+});
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -22,16 +22,17 @@ support-files =
   badMessageEvent.eventsource
   badMessageEvent.eventsource^headers^
   badMessageEvent2.eventsource
   badMessageEvent2.eventsource^headers^
   bug282547.sjs
   bug298064-subframe.html
   bug313646.txt
   bug382113_object.html
+  bug403852_fileOpener.js
   bug419132.html
   bug426308-redirect.sjs
   bug435425.sjs
   bug435425_redirect.sjs
   bug444322.js
   bug444322.txt
   bug455629-helper.svg
   bug457746.sjs
@@ -213,16 +214,17 @@ support-files =
   file_xhtmlserializer_1_sibling_body.xhtml
   file_xhtmlserializer_1_sibling_body_only_body.xhtml
   file_xhtmlserializer_1_wrap.xhtml
   file_xhtmlserializer_2.xhtml
   file_xhtmlserializer_2_basic.xhtml
   file_xhtmlserializer_2_enthtml.xhtml
   file_xhtmlserializer_2_entw3c.xhtml
   file_xhtmlserializer_2_latin1.xhtml
+  fileapi_chromeScript.js
   fileutils.js
   forRemoval.resource
   forRemoval.resource^headers^
   formReset.html
   invalid_accesscontrol.resource
   invalid_accesscontrol.resource^headers^
   mutationobserver_dialog.html
   progressserver.sjs
@@ -426,17 +428,16 @@ skip-if = (os == 'mac' || os == 'win') &
 [test_bug395915.html]
 [test_bug397234.html]
 [test_bug398243.html]
 [test_bug401662.html]
 [test_bug402150.html]
 support-files = test_bug402150.html^headers^
 [test_bug403841.html]
 [test_bug403852.html]
-skip-if = e10s
 [test_bug403868.xml]
 [test_bug405182.html]
 [test_bug409380.html]
 [test_bug410229.html]
 [test_bug413974.html]
 [test_bug414190.html]
 [test_bug415860.html]
 [test_bug416317-1.html]
@@ -543,17 +544,17 @@ skip-if = (buildapp == 'b2g' && toolkit 
 [test_bug562137.html]
 [test_bug562169-1.html]
 [test_bug562169-2.html]
 [test_bug562652.html]
 [test_bug564047.html]
 [test_bug564863.xhtml]
 [test_bug567350.html]
 [test_bug578096.html]
-skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) || e10s # b2g-debug(debug-only failure; crash) b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
+skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(debug-only failure; crash) b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
 [test_bug585978.html]
 skip-if = (toolkit == 'gonk' && debug) #debug-only timeout
 [test_bug587931.html]
 [test_bug588990.html]
 [test_bug590812.html]
 skip-if = toolkit == 'android' #bug 687032
 [test_bug590870.html]
 [test_bug592366.html]
@@ -674,17 +675,16 @@ skip-if = buildapp == 'b2g' || toolkit =
 [test_declare_stylesheet_obsolete.html]
 [test_document_constructor.html]
 [test_domparser_null_char.html]
 [test_domparsing.html]
 [test_elementTraversal.html]
 [test_element_closest.html]
 [test_encodeToStringWithMaxLength.html]
 [test_fileapi.html]
-skip-if = e10s
 [test_fileapi_slice.html]
 skip-if = buildapp == 'b2g' || buildapp == 'mulet' || toolkit == 'android' || e10s #bug 775227
 [test_getElementById.html]
 [test_html_colors_quirks.html]
 [test_html_colors_standards.html]
 [test_html_in_xhr.html]
 [test_htmlcopyencoder.html]
 [test_htmlcopyencoder.xhtml]
--- a/dom/base/test/test_bug403852.html
+++ b/dom/base/test/test_bug403852.html
@@ -14,40 +14,47 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display">
   <input id="fileList" type="file"></input>
 </p>
 <div id="content" style="display: none">
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
 
-var testFile = SpecialPowers.Services.dirsvc.get("ProfD", SpecialPowers.Ci.nsIFile);
-testFile.append("prefs.js");
-
-var fileList = document.getElementById('fileList');
-SpecialPowers.wrap(fileList).value = testFile.path;
+var url = SimpleTest.getTestFileURL("bug403852_fileOpener.js");
+var script = SpecialPowers.loadChromeScript(url);
+script.addMessageListener("file.opened", onOpened);
+script.sendAsyncMessage("file.open");
 
-// Make sure the file is accessible with indexed notation
-var domFile = fileList.files[0];
+function onOpened(message) {
+  var fileList = document.getElementById('fileList');
+  SpecialPowers.wrap(fileList).mozSetFileArray([message.file]);
 
-is(domFile.name, "prefs.js", "fileName should be prefs.js");
+  // Make sure the file is accessible with indexed notation
+  var domFile = fileList.files[0];
 
-ok("lastModifiedDate" in domFile, "lastModifiedDate must be present");
+  is(domFile.name, "prefs.js", "fileName should be prefs.js");
+
+  ok("lastModifiedDate" in domFile, "lastModifiedDate must be present");
 
-var d = new Date(testFile.lastModifiedTime);
-ok(d.getTime() == domFile.lastModifiedDate.getTime(), "lastModifiedDate should be the same.");
+  var d = new Date(message.mtime);
+  todo(d.getTime() == domFile.lastModifiedDate.getTime(), "lastModifiedDate should be the same (FIXME: bug 1121722)");
 
-var x = new Date();
+  var x = new Date();
 
-// In our implementation of File object, lastModifiedDate is unknown only for new objects.
-// Using canvas or input[type=file] elements, we 'often' have a valid lastModifiedDate values.
-// For canvas we use memory files and the lastModifiedDate is now().
-var f = new File([new Blob(['test'], {type: 'text/plain'})], "test-name");
+  // In our implementation of File object, lastModifiedDate is unknown only for new objects.
+  // Using canvas or input[type=file] elements, we 'often' have a valid lastModifiedDate values.
+  // For canvas we use memory files and the lastModifiedDate is now().
+  var f = new File([new Blob(['test'], {type: 'text/plain'})], "test-name");
 
-var y = f.lastModifiedDate;
-var z = new Date();
+  var y = f.lastModifiedDate;
+  var z = new Date();
 
-ok((x.getTime() <= y.getTime()) && (y.getTime() <= z.getTime()), "lastModifiedDate of file which does not have last modified date should be current time");
+  ok((x.getTime() <= y.getTime()) && (y.getTime() <= z.getTime()), "lastModifiedDate of file which does not have last modified date should be current time");
+  script.destroy();
+  SimpleTest.finish();
+}
 
 </script>
 </pre>
 </body> </html>
--- a/dom/base/test/test_bug578096.html
+++ b/dom/base/test/test_bug578096.html
@@ -17,18 +17,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
 var url = SimpleTest.getTestFileURL("bug578096LoadChromeScript.js");
 var script = SpecialPowers.loadChromeScript(url);
 
-script.addMessageListener("file.path", function (message) {
-  SpecialPowers.wrap(document.getElementById('file')).value = message;
+script.addMessageListener("file.created", function (message) {
+  SpecialPowers.wrap(document.getElementById('file')).mozSetFileArray([message]);
 
   var xhr = new XMLHttpRequest();
   xhr.onreadystatechange = function(event) {
     if (xhr.readyState == 4) {
       script.sendAsyncMessage("file.remove", {});
     }
   }
 
--- a/dom/base/test/test_fileapi.html
+++ b/dom/base/test/test_fileapi.html
@@ -7,36 +7,35 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 414796</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=414796">Mozilla Bug 414796</a>
 <p id="display">
-  <input id="fileList" type="file"></input>
 </p>
 <div id="content" style="display: none">
 </div>
 
 <pre id="test">
-<script class="testbody" type="text/javascript">
+<script class="testbody" type="text/javascript;version=1.7">
 
 // File constructors should not work from non-chrome code
 try {
   var file = File("/etc/passwd");
   ok(false, "Did not throw on unprivileged attempt to construct a File");
 } catch (e) {
   ok(true, "Threw on an unprivileged attempt to construct a File");
 }
 
 const minFileSize = 20000;
-var fileNum = 1;
 var testRanCounter = 0;
 var expectedTestCount = 0;
+var testSetupFinished = false;
 SimpleTest.waitForExplicitFinish();
 
 is(FileReader.EMPTY, 0, "correct EMPTY value");
 is(FileReader.LOADING, 1, "correct LOADING value");
 is(FileReader.DONE, 2, "correct DONE value");
 
 // Create strings containing data we'll test with. We'll want long
 // strings to ensure they span multiple buffers while loading
@@ -53,405 +52,414 @@ while (testASCIIData.length < minFileSiz
 var testBinaryData = "";
 for (var i = 0; i < 256; i++) {
   testBinaryData += String.fromCharCode(i);
 }
 while (testBinaryData.length < minFileSize) {
   testBinaryData = testBinaryData + testBinaryData;
 }
 
+var dataurldata0 = testBinaryData.substr(0, testBinaryData.length -
+					 testBinaryData.length % 3);
+var dataurldata1 = testBinaryData.substr(0, testBinaryData.length - 2 -
+					 testBinaryData.length % 3);
+var dataurldata2 = testBinaryData.substr(0, testBinaryData.length - 1 -
+					 testBinaryData.length % 3);
+
 
 //Set up files for testing
-var asciiFile = createFileWithData(testASCIIData);
-var binaryFile = createFileWithData(testBinaryData);
-
-var fileList = document.getElementById('fileList');
-SpecialPowers.Cu.import("resource://gre/modules/FileUtils.jsm", window);
-var FU = SpecialPowers.wrap(FileUtils);
-var fakeFile = FU.getDir("TmpD", [], false);
-fakeFile.append("FileThatDoesntExist.abc");
-SpecialPowers.wrap(fileList).value = fakeFile.path;
-var nonExistingFile = fileList.files[0];
+var openerURL = SimpleTest.getTestFileURL("fileapi_chromeScript.js");
+var opener = SpecialPowers.loadChromeScript(openerURL);
+opener.addMessageListener("files.opened", onFilesOpened);
+opener.sendAsyncMessage("files.open", [
+  testASCIIData,
+  testBinaryData,
+  null,
+  convertToUTF8(testTextData),
+  convertToUTF16(testTextData),
+  "",
+  dataurldata0,
+  dataurldata1,
+  dataurldata2,
+]);
 
-// Test that plain reading works and fires events as expected, both
-// for text and binary reading
-
-var onloadHasRunText = false;
-var onloadStartHasRunText = false;
-r = new FileReader();
-is(r.readyState, FileReader.EMPTY, "correct initial text readyState");
-r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "plain reading");
-r.addEventListener("load", function() { onloadHasRunText = true }, false);
-r.addEventListener("loadstart", function() { onloadStartHasRunText = true }, false);
-r.readAsText(asciiFile);
-is(r.readyState, FileReader.LOADING, "correct loading text readyState");
-is(onloadHasRunText, false, "text loading must be async");
-is(onloadStartHasRunText, true, "text loadstart should fire sync");
-expectedTestCount++;
+function onFilesOpened(message) {
+  let [
+    asciiFile,
+    binaryFile,
+    nonExistingFile,
+    utf8TextFile,
+    utf16TextFile,
+    emptyFile,
+    dataUrlFile0,
+    dataUrlFile1,
+    dataUrlFile2,
+  ] = message;
 
-var onloadHasRunBinary = false;
-var onloadStartHasRunBinary = false;
-r = new FileReader();
-is(r.readyState, FileReader.EMPTY, "correct initial binary readyState");
-r.addEventListener("load", function() { onloadHasRunBinary = true }, false);
-r.addEventListener("loadstart", function() { onloadStartHasRunBinary = true }, false);
-r.readAsBinaryString(binaryFile);
-r.onload = getLoadHandler(testBinaryData, testBinaryData.length, "binary reading");
-is(r.readyState, FileReader.LOADING, "correct loading binary readyState");
-is(onloadHasRunBinary, false, "binary loading must be async");
-is(onloadStartHasRunBinary, true, "binary loadstart should fire sync");
-expectedTestCount++;
+  // Test that plain reading works and fires events as expected, both
+  // for text and binary reading
 
-var onloadHasRunArrayBuffer = false;
-var onloadStartHasRunArrayBuffer = false;
-r = new FileReader();
-is(r.readyState, FileReader.EMPTY, "correct initial arrayBuffer readyState");
-r.addEventListener("load", function() { onloadHasRunArrayBuffer = true }, false);
-r.addEventListener("loadstart", function() { onloadStartHasRunArrayBuffer = true }, false);
-r.readAsArrayBuffer(binaryFile);
-r.onload = getLoadHandlerForArrayBuffer(testBinaryData, testBinaryData.length, "array buffer reading");
-is(r.readyState, FileReader.LOADING, "correct loading arrayBuffer readyState");
-is(onloadHasRunArrayBuffer, false, "arrayBuffer loading must be async");
-is(onloadStartHasRunArrayBuffer, true, "arrayBuffer loadstart should fire sync");
-expectedTestCount++;
+  var onloadHasRunText = false;
+  var onloadStartHasRunText = false;
+  r = new FileReader();
+  is(r.readyState, FileReader.EMPTY, "correct initial text readyState");
+  r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "plain reading");
+  r.addEventListener("load", function() { onloadHasRunText = true }, false);
+  r.addEventListener("loadstart", function() { onloadStartHasRunText = true }, false);
+  r.readAsText(asciiFile);
+  is(r.readyState, FileReader.LOADING, "correct loading text readyState");
+  is(onloadHasRunText, false, "text loading must be async");
+  is(onloadStartHasRunText, true, "text loadstart should fire sync");
+  expectedTestCount++;
 
-// Test a variety of encodings, and make sure they work properly
-r = new FileReader();
-r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "no encoding reading");
-r.readAsText(asciiFile, "");
-expectedTestCount++;
-
-r = new FileReader();
-r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "iso8859 reading");
-r.readAsText(asciiFile, "iso-8859-1");
-expectedTestCount++;
+  var onloadHasRunBinary = false;
+  var onloadStartHasRunBinary = false;
+  r = new FileReader();
+  is(r.readyState, FileReader.EMPTY, "correct initial binary readyState");
+  r.addEventListener("load", function() { onloadHasRunBinary = true }, false);
+  r.addEventListener("loadstart", function() { onloadStartHasRunBinary = true }, false);
+  r.readAsBinaryString(binaryFile);
+  r.onload = getLoadHandler(testBinaryData, testBinaryData.length, "binary reading");
+  is(r.readyState, FileReader.LOADING, "correct loading binary readyState");
+  is(onloadHasRunBinary, false, "binary loading must be async");
+  is(onloadStartHasRunBinary, true, "binary loadstart should fire sync");
+  expectedTestCount++;
 
-r = new FileReader();
-r.onload = getLoadHandler(testTextData,
-                          convertToUTF8(testTextData).length,
-                          "utf8 reading");
-r.readAsText(createFileWithData(convertToUTF8(testTextData)), "utf8");
-expectedTestCount++;
+  var onloadHasRunArrayBuffer = false;
+  var onloadStartHasRunArrayBuffer = false;
+  r = new FileReader();
+  is(r.readyState, FileReader.EMPTY, "correct initial arrayBuffer readyState");
+  r.addEventListener("load", function() { onloadHasRunArrayBuffer = true }, false);
+  r.addEventListener("loadstart", function() { onloadStartHasRunArrayBuffer = true }, false);
+  r.readAsArrayBuffer(binaryFile);
+  r.onload = getLoadHandlerForArrayBuffer(testBinaryData, testBinaryData.length, "array buffer reading");
+  is(r.readyState, FileReader.LOADING, "correct loading arrayBuffer readyState");
+  is(onloadHasRunArrayBuffer, false, "arrayBuffer loading must be async");
+  is(onloadStartHasRunArrayBuffer, true, "arrayBuffer loadstart should fire sync");
+  expectedTestCount++;
 
-r = new FileReader();
-r.readAsText(createFileWithData(convertToUTF16(testTextData)), "utf-16");
-r.onload = getLoadHandler(testTextData,
-                          convertToUTF16(testTextData).length,
-                          "utf16 reading");
-expectedTestCount++;
+  // Test a variety of encodings, and make sure they work properly
+  r = new FileReader();
+  r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "no encoding reading");
+  r.readAsText(asciiFile, "");
+  expectedTestCount++;
 
-// Test get result without reading
-r = new FileReader();
-is(r.readyState, FileReader.EMPTY,
-  "readyState in test reader get result without reading");
-is(r.error, null,
-  "no error in test reader get result without reading");
-is(r.result, null,
-  "result in test reader get result without reading");
+  r = new FileReader();
+  r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "iso8859 reading");
+  r.readAsText(asciiFile, "iso-8859-1");
+  expectedTestCount++;
 
-// Test loading an empty file works (and doesn't crash!)
-var emptyFile = createFileWithData("");
-r = new FileReader();
-r.onload = getLoadHandler("", 0, "empty no encoding reading");
-r.readAsText(emptyFile, "");
-expectedTestCount++;
+  r = new FileReader();
+  r.onload = getLoadHandler(testTextData,
+                            convertToUTF8(testTextData).length,
+                            "utf8 reading");
+  r.readAsText(utf8TextFile, "utf8");
+  expectedTestCount++;
+
+  r = new FileReader();
+  r.readAsText(utf16TextFile, "utf-16");
+  r.onload = getLoadHandler(testTextData,
+                            convertToUTF16(testTextData).length,
+                            "utf16 reading");
+  expectedTestCount++;
 
-r = new FileReader();
-r.onload = getLoadHandler("", 0, "empty utf8 reading");
-r.readAsText(emptyFile, "utf8");
-expectedTestCount++;
+  // Test get result without reading
+  r = new FileReader();
+  is(r.readyState, FileReader.EMPTY,
+     "readyState in test reader get result without reading");
+  is(r.error, null,
+     "no error in test reader get result without reading");
+  is(r.result, null,
+     "result in test reader get result without reading");
 
-r = new FileReader();
-r.onload = getLoadHandler("", 0, "empty utf16 reading");
-r.readAsText(emptyFile, "utf-16");
-expectedTestCount++;
+  // Test loading an empty file works (and doesn't crash!)
+  r = new FileReader();
+  r.onload = getLoadHandler("", 0, "empty no encoding reading");
+  r.readAsText(emptyFile, "");
+  expectedTestCount++;
 
-r = new FileReader();
-r.onload = getLoadHandler("", 0, "empty binary string reading");
-r.readAsBinaryString(emptyFile);
-expectedTestCount++;
+  r = new FileReader();
+  r.onload = getLoadHandler("", 0, "empty utf8 reading");
+  r.readAsText(emptyFile, "utf8");
+  expectedTestCount++;
 
-r = new FileReader();
-r.onload = getLoadHandlerForArrayBuffer("", 0, "empty array buffer reading");
-r.readAsArrayBuffer(emptyFile);
-expectedTestCount++;
+  r = new FileReader();
+  r.onload = getLoadHandler("", 0, "empty utf16 reading");
+  r.readAsText(emptyFile, "utf-16");
+  expectedTestCount++;
+
+  r = new FileReader();
+  r.onload = getLoadHandler("", 0, "empty binary string reading");
+  r.readAsBinaryString(emptyFile);
+  expectedTestCount++;
 
-r = new FileReader();
-r.onload = getLoadHandler(convertToDataURL(""), 0, "empt binary string reading");
-r.readAsDataURL(emptyFile);
-expectedTestCount++;
+  r = new FileReader();
+  r.onload = getLoadHandlerForArrayBuffer("", 0, "empty array buffer reading");
+  r.readAsArrayBuffer(emptyFile);
+  expectedTestCount++;
 
-// Test reusing a FileReader to read multiple times
-r = new FileReader();
-r.onload = getLoadHandler(testASCIIData,
-                          testASCIIData.length,
-                          "to-be-reused reading text")
-var makeAnotherReadListener = function(event) {
-  r = event.target;
-  r.removeEventListener("load", makeAnotherReadListener, false);
+  r = new FileReader();
+  r.onload = getLoadHandler(convertToDataURL(""), 0, "empt binary string reading");
+  r.readAsDataURL(emptyFile);
+  expectedTestCount++;
+
+  // Test reusing a FileReader to read multiple times
+  r = new FileReader();
   r.onload = getLoadHandler(testASCIIData,
                             testASCIIData.length,
-                            "reused reading text");
+                            "to-be-reused reading text")
+  var makeAnotherReadListener = function(event) {
+    r = event.target;
+    r.removeEventListener("load", makeAnotherReadListener, false);
+    r.onload = getLoadHandler(testASCIIData,
+                              testASCIIData.length,
+                              "reused reading text");
+    r.readAsText(asciiFile);
+  };
+  r.addEventListener("load", makeAnotherReadListener, false);
   r.readAsText(asciiFile);
-};
-r.addEventListener("load", makeAnotherReadListener, false);
-r.readAsText(asciiFile);
-expectedTestCount += 2;
+  expectedTestCount += 2;
 
-r = new FileReader();
-r.onload = getLoadHandler(testBinaryData,
-                          testBinaryData.length,
-                          "to-be-reused reading binary")
-var makeAnotherReadListener2 = function(event) {
-  r = event.target;
-  r.removeEventListener("load", makeAnotherReadListener2, false);
+  r = new FileReader();
   r.onload = getLoadHandler(testBinaryData,
                             testBinaryData.length,
-                            "reused reading binary");
+                            "to-be-reused reading binary")
+  var makeAnotherReadListener2 = function(event) {
+    r = event.target;
+    r.removeEventListener("load", makeAnotherReadListener2, false);
+    r.onload = getLoadHandler(testBinaryData,
+                              testBinaryData.length,
+                              "reused reading binary");
+    r.readAsBinaryString(binaryFile);
+  };
+  r.addEventListener("load", makeAnotherReadListener2, false);
   r.readAsBinaryString(binaryFile);
-};
-r.addEventListener("load", makeAnotherReadListener2, false);
-r.readAsBinaryString(binaryFile);
-expectedTestCount += 2;
+  expectedTestCount += 2;
 
-r = new FileReader();
-r.onload = getLoadHandler(convertToDataURL(testBinaryData),
-                          testBinaryData.length,
-                          "to-be-reused reading data url")
-var makeAnotherReadListener3 = function(event) {
-  r = event.target;
-  r.removeEventListener("load", makeAnotherReadListener3, false);
+  r = new FileReader();
   r.onload = getLoadHandler(convertToDataURL(testBinaryData),
                             testBinaryData.length,
-                            "reused reading data url");
+                            "to-be-reused reading data url")
+  var makeAnotherReadListener3 = function(event) {
+    r = event.target;
+    r.removeEventListener("load", makeAnotherReadListener3, false);
+    r.onload = getLoadHandler(convertToDataURL(testBinaryData),
+                              testBinaryData.length,
+                              "reused reading data url");
+    r.readAsDataURL(binaryFile);
+  };
+  r.addEventListener("load", makeAnotherReadListener3, false);
   r.readAsDataURL(binaryFile);
-};
-r.addEventListener("load", makeAnotherReadListener3, false);
-r.readAsDataURL(binaryFile);
-expectedTestCount += 2;
+  expectedTestCount += 2;
 
-r = new FileReader();
-r.onload = getLoadHandlerForArrayBuffer(testBinaryData,
-                          testBinaryData.length,
-                          "to-be-reused reading arrayBuffer")
-var makeAnotherReadListener4 = function(event) {
-  r = event.target;
-  r.removeEventListener("load", makeAnotherReadListener4, false);
+  r = new FileReader();
   r.onload = getLoadHandlerForArrayBuffer(testBinaryData,
-                            testBinaryData.length,
-                            "reused reading arrayBuffer");
+                                          testBinaryData.length,
+                                          "to-be-reused reading arrayBuffer")
+  var makeAnotherReadListener4 = function(event) {
+    r = event.target;
+    r.removeEventListener("load", makeAnotherReadListener4, false);
+    r.onload = getLoadHandlerForArrayBuffer(testBinaryData,
+                                            testBinaryData.length,
+                                            "reused reading arrayBuffer");
+    r.readAsArrayBuffer(binaryFile);
+  };
+  r.addEventListener("load", makeAnotherReadListener4, false);
   r.readAsArrayBuffer(binaryFile);
-};
-r.addEventListener("load", makeAnotherReadListener4, false);
-r.readAsArrayBuffer(binaryFile);
-expectedTestCount += 2;
+  expectedTestCount += 2;
 
-// Test first reading as ArrayBuffer then read as something else
-// (BinaryString) and doesn't crash
-r = new FileReader();
-r.onload = getLoadHandlerForArrayBuffer(testBinaryData,
-                          testBinaryData.length,
-                          "to-be-reused reading arrayBuffer")
-var makeAnotherReadListener5 = function(event) {
-  r = event.target;
-  r.removeEventListener("load", makeAnotherReadListener5, false);
-  r.onload = getLoadHandler(testBinaryData,
-                            testBinaryData.length,
-                            "reused reading binary string");
-  r.readAsBinaryString(binaryFile);
-};
-r.addEventListener("load", makeAnotherReadListener5, false);
-r.readAsArrayBuffer(binaryFile);
-expectedTestCount += 2;
+  // Test first reading as ArrayBuffer then read as something else
+  // (BinaryString) and doesn't crash
+  r = new FileReader();
+  r.onload = getLoadHandlerForArrayBuffer(testBinaryData,
+                                          testBinaryData.length,
+                                          "to-be-reused reading arrayBuffer")
+  var makeAnotherReadListener5 = function(event) {
+    r = event.target;
+    r.removeEventListener("load", makeAnotherReadListener5, false);
+    r.onload = getLoadHandler(testBinaryData,
+                              testBinaryData.length,
+                              "reused reading binary string");
+    r.readAsBinaryString(binaryFile);
+  };
+  r.addEventListener("load", makeAnotherReadListener5, false);
+  r.readAsArrayBuffer(binaryFile);
+  expectedTestCount += 2;
 
-//Test data-URI encoding on differing file sizes
-dataurldata = testBinaryData.substr(0, testBinaryData.length -
-                                       testBinaryData.length % 3);
-is(dataurldata.length % 3, 0, "Want to test data with length % 3 == 0");
-r = new FileReader();
-r.onload = getLoadHandler(convertToDataURL(dataurldata),
-                          dataurldata.length,
-                          "dataurl reading, %3 = 0");
-r.readAsDataURL(createFileWithData(dataurldata));
-expectedTestCount++;
+  //Test data-URI encoding on differing file sizes
+  is(dataurldata0.length % 3, 0, "Want to test data with length % 3 == 0");
+  r = new FileReader();
+  r.onload = getLoadHandler(convertToDataURL(dataurldata0),
+                            dataurldata0.length,
+                            "dataurl reading, %3 = 0");
+  r.readAsDataURL(dataUrlFile0);
+  expectedTestCount++;
 
-dataurldata = testBinaryData.substr(0, testBinaryData.length - 2 -
-                                       testBinaryData.length % 3);
-is(dataurldata.length % 3, 1, "Want to test data with length % 3 == 1");
-r = new FileReader();
-r.onload = getLoadHandler(convertToDataURL(dataurldata),
-                          dataurldata.length,
-                          "dataurl reading, %3 = 1");
-r.readAsDataURL(createFileWithData(dataurldata));
-expectedTestCount++;
+  is(dataurldata1.length % 3, 1, "Want to test data with length % 3 == 1");
+  r = new FileReader();
+  r.onload = getLoadHandler(convertToDataURL(dataurldata1),
+                            dataurldata1.length,
+                            "dataurl reading, %3 = 1");
+  r.readAsDataURL(dataUrlFile1);
+  expectedTestCount++;
 
-dataurldata = testBinaryData.substr(0, testBinaryData.length - 1 -
-                                       testBinaryData.length % 3);
-is(dataurldata.length % 3, 2, "Want to test data with length % 3 == 2");
-r = new FileReader();
-r.onload = getLoadHandler(convertToDataURL(dataurldata),
-                          dataurldata.length,
-                          "dataurl reading, %3 = 2");
-r.readAsDataURL(createFileWithData(dataurldata));
-expectedTestCount++;
+  is(dataurldata2.length % 3, 2, "Want to test data with length % 3 == 2");
+  r = new FileReader();
+  r.onload = getLoadHandler(convertToDataURL(dataurldata2),
+                            dataurldata2.length,
+                            "dataurl reading, %3 = 2");
+  r.readAsDataURL(dataUrlFile2),
+  expectedTestCount++;
 
 
-// Test abort()
-var abortHasRun = false;
-var loadEndHasRun = false;
-r = new FileReader();
-r.onabort = function (event) {
-  is(abortHasRun, false, "abort should only fire once");
-  is(loadEndHasRun, false, "loadend shouldn't have fired yet");
-  abortHasRun = 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.onloadend = function (event) {
-  is(abortHasRun, true, "abort should fire before loadend");
-  is(loadEndHasRun, false, "loadend should only fire once");
-  loadEndHasRun = 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 not fire for aborted reads") };
-r.onerror = function() { ok(false, "error should not fire for aborted reads") };
-r.onprogress = function() { ok(false, "progress should not fire for aborted reads") };
-var abortThrew = false;
-try {
+  // Test abort()
+  var abortHasRun = false;
+  var loadEndHasRun = false;
+  r = new FileReader();
+  r.onabort = function (event) {
+    is(abortHasRun, false, "abort should only fire once");
+    is(loadEndHasRun, false, "loadend shouldn't have fired yet");
+    abortHasRun = 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.onloadend = function (event) {
+    is(abortHasRun, true, "abort should fire before loadend");
+    is(loadEndHasRun, false, "loadend should only fire once");
+    loadEndHasRun = 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 not fire for aborted reads") };
+  r.onerror = function() { ok(false, "error should not fire for aborted reads") };
+  r.onprogress = function() { ok(false, "progress should not fire for aborted reads") };
+  var abortThrew = false;
+  try {
+    r.abort();
+  } catch(e) {
+    abortThrew = true;
+  }
+  is(abortThrew, true, "abort() must throw if not loading");
+  is(abortHasRun, false, "abort() is a no-op unless loading");
+  r.readAsText(asciiFile);
   r.abort();
-} catch(e) {
-  abortThrew = true;
-}
-is(abortThrew, true, "abort() must throw if not loading");
-is(abortHasRun, false, "abort() is a no-op unless loading");
-r.readAsText(asciiFile);
-r.abort();
-is(abortHasRun, true, "abort should fire sync");
-is(loadEndHasRun, true, "loadend should fire sync");
+  is(abortHasRun, true, "abort should fire sync");
+  is(loadEndHasRun, true, "loadend should fire sync");
 
-// Test calling readAsX to cause abort()
-var reuseAbortHasRun = false;
-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 not fire for aborted reads") };
-var abortThrew = false;
-try {
-  r.abort();
-} catch(e) {
-  abortThrew = true;
-}
-is(abortThrew, true, "abort() must throw if not loading");
-is(reuseAbortHasRun, false, "abort() is a no-op unless loading");
-r.readAsText(asciiFile);
-r.readAsText(asciiFile);
-is(reuseAbortHasRun, true, "abort should fire sync");
-r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "reuse-as-abort reading");
-expectedTestCount++;
+  // Test calling readAsX to cause abort()
+  var reuseAbortHasRun = false;
+  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 not fire for aborted reads") };
+  var abortThrew = false;
+  try {
+    r.abort();
+  } catch(e) {
+    abortThrew = true;
+  }
+  is(abortThrew, true, "abort() must throw if not loading");
+  is(reuseAbortHasRun, false, "abort() is a no-op unless loading");
+  r.readAsText(asciiFile);
+  r.readAsText(asciiFile);
+  is(reuseAbortHasRun, true, "abort should fire sync");
+  r.onload = getLoadHandler(testASCIIData, testASCIIData.length, "reuse-as-abort reading");
+  expectedTestCount++;
 
 
-// Test reading from nonexistent files
-r = new FileReader();
-var didThrow = false;
-r.onerror = function (event) {
-  is(event.target.readyState, FileReader.DONE, "should be DONE while firing onerror");
-  is(event.target.error.name, "NotFoundError", "error set to NotFoundError for nonexistent files");
-  is(event.target.result, null, "file data should be null on aborted reads");
-  testHasRun();
-};
-try {
-  r.readAsDataURL(nonExistingFile);
-  expectedTestCount++;
-} catch(ex) {
-  didThrow = true;
-}
-// Once this test passes, we should test that onerror gets called and
-// that the FileReader object is in the right state during that call.
-is(didThrow, false, "shouldn't throw when opening nonexistent file, should fire error instead");
+  // Test reading from nonexistent files
+  r = new FileReader();
+  var didThrow = false;
+  r.onerror = function (event) {
+    is(event.target.readyState, FileReader.DONE, "should be DONE while firing onerror");
+    is(event.target.error.name, "NotFoundError", "error set to NotFoundError for nonexistent files");
+    is(event.target.result, null, "file data should be null on aborted reads");
+    testHasRun();
+  };
+  r.onload = function (event) {
+    todo(false, "nonexistent file shouldn't load! (FIXME: bug 1122788)");
+    testHasRun();
+  };
+  try {
+    r.readAsDataURL(nonExistingFile);
+    expectedTestCount++;
+  } catch(ex) {
+    didThrow = true;
+  }
+  // Once this test passes, we should test that onerror gets called and
+  // that the FileReader object is in the right state during that call.
+  is(didThrow, false, "shouldn't throw when opening nonexistent file, should fire error instead");
 
 
-function getLoadHandler(expectedResult, expectedLength, testName) {
-  return function (event) {
-    is(event.target.readyState, FileReader.DONE,
-       "readyState in test " + testName);
-    is(event.target.error, null,
-       "no error in test " + testName);
-    is(event.target.result, expectedResult,
-       "result in test " + testName);
-    is(event.lengthComputable, true,
-       "lengthComputable in test " + testName);
-    is(event.loaded, expectedLength,
-       "loaded in test " + testName);
-    is(event.total, expectedLength,
-       "total in test " + testName);
-    testHasRun();
+  function getLoadHandler(expectedResult, expectedLength, testName) {
+    return function (event) {
+      is(event.target.readyState, FileReader.DONE,
+         "readyState in test " + testName);
+      is(event.target.error, null,
+         "no error in test " + testName);
+      is(event.target.result, expectedResult,
+         "result in test " + testName);
+      is(event.lengthComputable, true,
+         "lengthComputable in test " + testName);
+      is(event.loaded, expectedLength,
+         "loaded in test " + testName);
+      is(event.total, expectedLength,
+         "total in test " + testName);
+      testHasRun();
+    }
   }
-}
 
-function getLoadHandlerForArrayBuffer(expectedResult, expectedLength, testName) {
-  return function (event) {
-    is(event.target.readyState, FileReader.DONE,
-       "readyState in test " + testName);
-    is(event.target.error, null,
-       "no error in test " +  testName);
-    is(event.lengthComputable, true,
-       "lengthComputable in test " + testName);
-    is(event.loaded, expectedLength,
-       "loaded in test " + testName);
-    is(event.total, expectedLength,
-       "total in test " + testName);
-    is(event.target.result.byteLength, expectedLength,
-       "array buffer size in test " + testName);
-    var u8v = new Uint8Array(event.target.result);
-    is(String.fromCharCode.apply(String, u8v), expectedResult,
-       "array buffer contents in test " + testName);
-    u8v = null;
-    SpecialPowers.gc();
-    is(event.target.result.byteLength, expectedLength,
-       "array buffer size after gc in test " + testName);
-    u8v = new Uint8Array(event.target.result);
-    is(String.fromCharCode.apply(String, u8v), expectedResult,
-       "array buffer contents after gc in test " + testName);
-    testHasRun();
+  function getLoadHandlerForArrayBuffer(expectedResult, expectedLength, testName) {
+    return function (event) {
+      is(event.target.readyState, FileReader.DONE,
+         "readyState in test " + testName);
+      is(event.target.error, null,
+         "no error in test " +  testName);
+      is(event.lengthComputable, true,
+         "lengthComputable in test " + testName);
+      is(event.loaded, expectedLength,
+         "loaded in test " + testName);
+      is(event.total, expectedLength,
+         "total in test " + testName);
+      is(event.target.result.byteLength, expectedLength,
+         "array buffer size in test " + testName);
+      var u8v = new Uint8Array(event.target.result);
+      is(String.fromCharCode.apply(String, u8v), expectedResult,
+         "array buffer contents in test " + testName);
+      u8v = null;
+      SpecialPowers.gc();
+      is(event.target.result.byteLength, expectedLength,
+         "array buffer size after gc in test " + testName);
+      u8v = new Uint8Array(event.target.result);
+      is(String.fromCharCode.apply(String, u8v), expectedResult,
+         "array buffer contents after gc in test " + testName);
+      testHasRun();
+    }
   }
-}
-
-function testHasRun() {
- //alert(testRanCounter);
- ++testRanCounter;
- if (testRanCounter == expectedTestCount) {
-    is(onloadHasRunText, true, "onload text should have fired by now");
-    is(onloadHasRunBinary, true, "onload binary should have fired by now");
-    SimpleTest.finish();
-  }
-}
 
-function createFileWithData(fileData) {
-  var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"].getService(SpecialPowers.Ci.nsIProperties);
-  var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
-  testFile.append("fileAPItestfile" + fileNum);
-  fileNum++;
-  var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-  outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
-                 0666, 0);
-  outStream.write(fileData, fileData.length);
-  outStream.close();
+  function testHasRun() {
+    //alert(testRanCounter);
+    ++testRanCounter;
+    if (testRanCounter == expectedTestCount) {
+      is(testSetupFinished, true, "test setup should have finished; check for exceptions");
+      is(onloadHasRunText, true, "onload text should have fired by now");
+      is(onloadHasRunBinary, true, "onload binary should have fired by now");
+      opener.destroy();
+      SimpleTest.finish();
+    }
+  }
 
-  var fileList = document.getElementById('fileList');
-  SpecialPowers.wrap(fileList).value = testFile.path;
-
-  return fileList.files[0];
+  testSetupFinished = true;
 }
 
 function convertToUTF16(s) {
   res = "";
   for (var i = 0; i < s.length; ++i) {
     c = s.charCodeAt(i);
     res += String.fromCharCode(c & 255, c >>> 8);
   }
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -316,29 +316,27 @@ skip-if = buildapp == 'b2g' || e10s # b2
 [test_bug583514.html]
 [test_bug583533.html]
 [test_bug586763.html]
 [test_bug586786.html]
 [test_bug587469.html]
 [test_bug589.html]
 [test_bug590353-1.html]
 [test_bug590353-2.html]
-skip-if = e10s
 [test_bug590363.html]
 [test_bug592802.html]
 [test_bug593689.html]
 [test_bug595429.html]
 skip-if = e10s
 [test_bug595447.html]
 [test_bug595449.html]
 skip-if = (toolkit == 'gonk' && debug) || e10s #debug-only failure
 [test_bug596350.html]
 [test_bug596511.html]
 [test_bug598643.html]
-skip-if = e10s
 [test_bug598833-1.html]
 [test_bug600155.html]
 [test_bug601030.html]
 [test_bug605124-1.html]
 [test_bug605124-2.html]
 [test_bug605125-1.html]
 [test_bug605125-2.html]
 [test_bug606817.html]
--- a/dom/html/test/test_bug590353-2.html
+++ b/dom/html/test/test_bug590353-2.html
@@ -30,43 +30,32 @@ var testData = [
   [ "reset", "foo", "foo" ],
   [ "submit", "foo", "foo" ],
   [ "checkbox", true, false ],
   [ "radio", true, false ],
   [ "file", "590353_file", "" ],
 ];
 
 function createFileWithData(fileName, fileData) {
-  var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
-                            .getService(SpecialPowers.Ci.nsIProperties);
-  var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
-  testFile.append(fileName);
-  var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].
-                  createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-  outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
-                 0666, 0);
-  outStream.write(fileData, fileData.length);
-  outStream.close();
-
-  return testFile;
+  return new File([new Blob([fileData], { type: "text/plain" })], fileName);
 }
 
 var content = document.getElementById('content');
 var form = document.createElement('form');
 content.appendChild(form);
 
 for (var data of testData) {
   var e = document.createElement('input');
   e.type = data[0];
 
   if (data[0] == 'checkbox' || data[0] == 'radio') {
     e.checked = data[1];
   } else if (data[0] == 'file') {
     var file = createFileWithData(data[1], "file content");
-    SpecialPowers.wrap(e).value = file.path;
+    SpecialPowers.wrap(e).mozSetFileArray([file]);
   } else {
     e.value = data[1];
   }
 
   form.appendChild(e);
 }
 
 form.reset();
--- a/dom/html/test/test_bug598643.html
+++ b/dom/html/test/test_bug598643.html
@@ -13,36 +13,25 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 598643 **/
 
 function createFileWithData(fileName, fileData)
 {
-  var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
-                            .getService(SpecialPowers.Ci.nsIProperties);
-  var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
-  testFile.append(fileName);
-  var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].
-                  createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-  outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
-                 0666, 0);
-  outStream.write(fileData, fileData.length);
-  outStream.close();
-
-  return testFile;
+  return new File([new Blob([fileData], { type: "text/plain" })], fileName);
 }
 
 function testFileControl(aElement)
 {
   aElement.type = 'file';
 
   var file = createFileWithData("file_bug598643", "file content");
-  SpecialPowers.wrap(aElement).value = file.path;
+  SpecialPowers.wrap(aElement).mozSetFileArray([file]);
 
   ok(aElement.validity.valid, "the file control should be valid");
   ok(!aElement.validity.tooLong,
      "the file control shouldn't suffer from being too long");
 }
 
 var types = [
   // These types can be too long.