Bug 1225202, part 3 - Create files in test_fileapi_slice.html using SpecialPowers.createFiles. r=baku
authorAndrew McCreight <continuation@gmail.com>
Thu, 19 Nov 2015 10:24:20 -0800
changeset 273395 e7fa9a0b61f69e6f61d0e22298ddf3848620e997
parent 273394 1da4e678744314f60155add5675ff996ad5be45c
child 273396 94d80c1508bfed035b52d5564d81138d3657431d
push id29702
push usercbook@mozilla.com
push dateFri, 20 Nov 2015 12:13:22 +0000
treeherdermozilla-central@ec628289d8b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1225202
milestone45.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 1225202, part 3 - Create files in test_fileapi_slice.html using SpecialPowers.createFiles. r=baku This makes the test work with e10s enabled. Remove createFileWithData from fileutils.js which is no longer used.
dom/base/test/fileutils.js
dom/base/test/mochitest.ini
dom/base/test/test_fileapi_slice.html
--- a/dom/base/test/fileutils.js
+++ b/dom/base/test/fileutils.js
@@ -122,33 +122,16 @@ function convertXHRBinary(s) {
 function testHasRun() {
  //alert(testRanCounter);
  ++testRanCounter;
  if (testRanCounter == expectedTestCount) {
     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("fileAPItestfile2-" + 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();
-
-  var fileList = document.getElementById('fileList');
-  SpecialPowers.wrap(fileList).value = testFile.path;
-
-  return fileList.files[0];
-}
-
 function gc() {
   window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
         .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils)
         .garbageCollect();
 }
 
 function checkMPSubmission(sub, expected) {
   function getPropCount(o) {
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -737,17 +737,17 @@ skip-if = buildapp == 'b2g' || toolkit =
 [test_document_importNode_document.html]
 [test_domparser_null_char.html]
 [test_domparsing.html]
 [test_elementTraversal.html]
 [test_element_closest.html]
 [test_encodeToStringWithMaxLength.html]
 [test_fileapi.html]
 [test_fileapi_slice.html]
-skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 775227
+skip-if = buildapp == 'b2g' || toolkit == 'android' #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]
 [test_ipc_messagemanager_blob.html]
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 936226
--- a/dom/base/test/test_fileapi_slice.html
+++ b/dom/base/test/test_fileapi_slice.html
@@ -80,17 +80,18 @@ var fileData =
 var size = fileData.length;
 var testBinaryData = "";
 
 // This might fail if we dramatically improve the png encoder. If that happens
 // please increase the complexity or size of the image generated above to ensure
 // that we're testing with files that are large enough.
 ok(size > 65536, "test data sufficiently large");
 
-basicTest([createFileWithData(fileData)]);
+SpecialPowers.createFiles([{name: "basicTestFile", data: fileData}],
+                          basicTest);
 
 function basicTest(files) {
   var fileFile = files[0];
 
   // Test that basic properties work
   var memFile = cx.canvas.mozGetAsFile("image/png");
   testSlice(memFile, size, "image/png", fileData, "memFile");
   testSlice(fileFile, size, "", fileData, "fileFile");
@@ -99,53 +100,61 @@ function basicTest(files) {
   for (var i = 0; i < 256; i++) {
     testBinaryData += String.fromCharCode(i);
   }
   while (testBinaryData.length < 20000) {
     testBinaryData += testBinaryData;
   }
 
   // image in the middle
-  imageMiddleTest([createFileWithData(testBinaryData + fileData + testBinaryData)]);
+  SpecialPowers.createFiles([{name: "middleTestFile",
+                             data: testBinaryData + fileData + testBinaryData}],
+                            imageMiddleTest);
 }
 
 function imageMiddleTest(files) {
   var imgfile = files[0];
   is(imgfile.size, size + testBinaryData.length * 2, "correct file size (middle)");
   var img = new Image;
   img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, testBinaryData.length + size));
   img.onload = imageLoadHandler;
   expectedTestCount++;
 
   // image at start
-  imageStartTest([createFileWithData(fileData + testBinaryData)]);
+  SpecialPowers.createFiles([{name: "startTestFile",
+                             data: fileData + testBinaryData}],
+                            imageStartTest);
 }
 
 function imageStartTest(files) {
   var imgfile = files[0];
   is(imgfile.size, size + testBinaryData.length, "correct file size (start)");
   var img = new Image;
   img.src = URL.createObjectURL(imgfile.slice(0, size));
   img.onload = imageLoadHandler;
   expectedTestCount++;
 
   // image at end
-  imageEndTest([createFileWithData(testBinaryData + fileData)]);
+  SpecialPowers.createFiles([{name: "endTestFile",
+                             data: testBinaryData + fileData}],
+                            imageEndTest);
 }
 
 function imageEndTest(files) {
   var imgfile = files[0];
   is(imgfile.size, size + testBinaryData.length, "correct file size (end)");
   var img = new Image;
   img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, testBinaryData.length + size));
   img.onload = imageLoadHandler;
   expectedTestCount++;
 
   // image past end
-  imagePastEndTest([createFileWithData(testBinaryData + fileData)]);
+  SpecialPowers.createFiles([{name: "pastEndTestFile",
+                             data: testBinaryData + fileData}],
+                            imagePastEndTest);
 }
 
 function imagePastEndTest(files) {
   var imgfile = files[0];
   is(imgfile.size, size + testBinaryData.length, "correct file size (past end)");
   var img = new Image;
   img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, testBinaryData.length + size + 1000));
   img.onload = imageLoadHandler;