Bug 1058977 - Adjust mochitests that do content-process file creation/deletion. r=bz
authorJed Davis <jld@mozilla.com>
Mon, 08 Sep 2014 18:48:50 -0700
changeset 204234 2743fe09d35a990198cddf7e171e112c37cfa4d2
parent 204233 1e76fdd58e7d2b66cd146bbae32dc69006577c6f
child 204235 bb9d094bfd938f285f6ca9eb7d1bcb918025a7a4
push id27452
push usercbook@mozilla.com
push dateTue, 09 Sep 2014 13:57:12 +0000
treeherdermozilla-central@2eaf94a4f837 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1058977
milestone35.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 1058977 - Adjust mochitests that do content-process file creation/deletion. r=bz Some form tests are switched to Blob-backed DOM files; some tests now use nsIFile but don't create the file, if the test simply uses the path but doesn't access it; and some tests are moved to mochi-chrome
content/base/test/test_bug345339.html
content/html/content/test/forms/chrome.ini
content/html/content/test/forms/mochitest.ini
content/html/content/test/forms/test_change_event.html
content/html/content/test/forms/test_input_event.html
content/html/content/test/forms/test_max_attribute.html
content/html/content/test/forms/test_min_attribute.html
content/html/content/test/forms/test_required_attribute.html
content/html/content/test/forms/test_step_attribute.html
content/html/content/test/forms/test_submit_invalid_file.html
content/html/content/test/test_bug592802.html
embedding/test/chrome.ini
embedding/test/mochitest.ini
embedding/test/moz.build
embedding/test/test_bug449141.html
--- a/content/base/test/test_bug345339.html
+++ b/content/base/test/test_bug345339.html
@@ -31,17 +31,18 @@ function afterLoad() {
     iframeDoc.getElementById("radio2").checked = true;
     iframeDoc.getElementById("password").value = "123456";
     iframeDoc.getElementById("hidden").value = "gecko";
 
     var file = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
              .getService(SpecialPowers.Ci.nsIProperties)
              .get("TmpD", SpecialPowers.Ci.nsILocalFile);
     file.append("345339_test.file");
-    file.createUnique(SpecialPowers.Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
+    // Only the file's path is used, so it doesn't need to be created.
+    // See also bug 1058977.
     filePath = file.path;
 
     SpecialPowers.wrap(iframeDoc).getElementById("file").value = filePath;
 
     /* Reload the page */
     $("testframe").setAttribute("onload", "afterReload()");
     iframeDoc.location.reload();
 }
--- a/content/html/content/test/forms/chrome.ini
+++ b/content/html/content/test/forms/chrome.ini
@@ -1,2 +1,5 @@
 [DEFAULT]
+support-files =
+  submit_invalid_file.sjs
 [test_autocompleteinfo.html]
+[test_submit_invalid_file.html]
--- a/content/html/content/test/forms/mochitest.ini
+++ b/content/html/content/test/forms/mochitest.ini
@@ -1,12 +1,11 @@
 [DEFAULT]
 support-files =
   save_restore_radio_groups.sjs
-  submit_invalid_file.sjs
   test_input_number_data.js
 
 [test_bug1039548.html]
 [test_button_attributes_reflection.html]
 [test_input_radio_radiogroup.html]
 [test_change_event.html]
 skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
 [test_datalist_element.html]
@@ -86,16 +85,15 @@ skip-if = e10s
 [test_restore_form_elements.html]
 [test_save_restore_radio_groups.html]
 [test_select_selectedOptions.html]
 [test_select_validation.html]
 [test_set_range_text.html]
 [test_step_attribute.html]
 skip-if = e10s
 [test_stepup_stepdown.html]
-[test_submit_invalid_file.html]
 [test_textarea_attributes_reflection.html]
 [test_validation.html]
 skip-if = buildapp == 'b2g' || e10s # b2g(374 total, bug 901848, no keygen support) b2g-debug(374 total, bug 901848, no keygen support) b2g-desktop(374 total, bug 901848, no keygen support)
 [test_valueAsDate_pref.html]
 [test_valueasdate_attribute.html]
 [test_valueasnumber_attribute.html]
 [test_validation_not_in_doc.html]
--- a/content/html/content/test/forms/test_change_event.html
+++ b/content/html/content/test/forms/test_change_event.html
@@ -62,17 +62,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     var btn = document.getElementById('fileInput');
     btn.focus()
     btn.blur();
     is(fileInputChange, 1, "change event shouldn't be dispatched on blur for file input element(1)");
   }
 
   function testUserInput() {
     //Simulating an OK click and with a file name return.
-    MockFilePicker.useAnyFile();
+    MockFilePicker.useBlobFile();
     MockFilePicker.returnValue = MockFilePicker.returnOK;
     var input = document.getElementById('fileInput');
     input.focus();
 
     input.addEventListener("change", function (aEvent) {
       ++fileInputChange;
       if (!blurTestCalled) {
         is(fileInputChange, 1, "change event should have been dispatched on file input.");
--- a/content/html/content/test/forms/test_input_event.html
+++ b/content/html/content/test/forms/test_input_event.html
@@ -54,17 +54,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   var numberInput = 0;
 
   SimpleTest.waitForExplicitFinish();
   var MockFilePicker = SpecialPowers.MockFilePicker;
   MockFilePicker.init(window);
 
   function testUserInput() {
     // Simulating an OK click and with a file name return.
-    MockFilePicker.useAnyFile();
+    MockFilePicker.useBlobFile();
     MockFilePicker.returnValue = MockFilePicker.returnOK;
     var input = document.getElementById('fileInput');
     input.focus();
 
     input.addEventListener("input", function (aEvent) {
       ok(false, "input event doesn't apply to type='file'");
     }, false);
 
--- a/content/html/content/test/forms/test_max_attribute.html
+++ b/content/html/content/test/forms/test_max_attribute.html
@@ -174,27 +174,22 @@ for (var test of data) {
       input.value = 'foo@bar.com';
       checkValidity(input, true, apply, apply);
       break;
     case 'file':
       var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
                                 .getService(SpecialPowers.Ci.nsIProperties);
       var file = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
       file.append('635499_file');
-      var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].
-                      createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-      outStream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
-                     0666, 0);
-      outStream.write("foo", 3);
-      outStream.close();
+      // Only the file's path is used, so it doesn't need to be created.
+      // See also bug 1058977.
 
       SpecialPowers.wrap(input).value = file.path;
       checkValidity(input, true, apply, apply);
 
-      file.remove(false);
       break;
     case 'date':
       input.max = '2012-06-27';
       input.value = '2012-06-26';
       checkValidity(input, true, apply, apply);
 
       input.value = '2012-06-27';
       checkValidity(input, true, apply, apply);
--- a/content/html/content/test/forms/test_min_attribute.html
+++ b/content/html/content/test/forms/test_min_attribute.html
@@ -172,27 +172,22 @@ for (var test of data) {
       input.value = 'foo@bar.com';
       checkValidity(input, true, apply, apply);
       break;
     case 'file':
       var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
                                 .getService(SpecialPowers.Ci.nsIProperties);
       var file = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
       file.append('635499_file');
-      var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].
-                      createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-      outStream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
-                     0666, 0);
-      outStream.write("foo", 3);
-      outStream.close();
+      // Only the file's path is used, so it doesn't need to be created.
+      // See also bug 1058977.
 
       SpecialPowers.wrap(input).value = file.path;
       checkValidity(input, true, apply, apply);
 
-      file.remove(false);
       break;
     case 'date':
       input.value = '2012-06-28';
       checkValidity(input, true, apply, apply);
 
       input.value = '2012-06-27';
       checkValidity(input, true, apply, apply);
 
--- a/content/html/content/test/forms/test_required_attribute.html
+++ b/content/html/content/test/forms/test_required_attribute.html
@@ -303,32 +303,28 @@ function checkInputRequiredValidityForRa
 }
 
 function checkInputRequiredValidityForFile()
 {
   var element = document.createElement('input');
   element.type = 'file'
   document.forms[0].appendChild(element);
 
-  function createFileWithData(fileName, fileData) {
+  function createFile(fileName) {
     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();
+    // Only the file's path is used, so it doesn't need to be created.
+    // See also bug 1058977.
 
     return testFile;
   }
 
-  var file = createFileWithData("345822_file", "file content");
+  var file = createFile("345822_file");
 
   SpecialPowers.wrap(element).value = "";
   element.required = false;
   checkNotSufferingFromBeingMissing(element);
 
   element.required = true;
   checkSufferingFromBeingMissing(element, true);
 
@@ -345,17 +341,16 @@ function checkInputRequiredValidityForFi
   SpecialPowers.wrap(element).value = file.path;
   element.required = true;
   element.blur();
   element.form.reset();
   checkSufferingFromBeingMissing(element, false);
 
   element.required = true;
   SpecialPowers.wrap(element).value = '';
-  file.remove(false);
   document.forms[0].removeChild(element);
   checkSufferingFromBeingMissing(element, true);
 }
 
 checkTextareaRequiredValidity();
 
 // The require attribute behavior depend of the input type.
 // First of all, checks for types that make the element barred from
--- a/content/html/content/test/forms/test_step_attribute.html
+++ b/content/html/content/test/forms/test_step_attribute.html
@@ -127,27 +127,22 @@ for (var test of data) {
       input.value = 'foo@bar.com';
       checkValidity(input, true, apply);
       break;
     case 'file':
       var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
                                 .getService(SpecialPowers.Ci.nsIProperties);
       var file = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
       file.append('635499_file');
-      var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"].
-                      createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-      outStream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
-                     0666, 0);
-      outStream.write("foo", 3);
-      outStream.close();
+      // Only the file's path is used, so it doesn't need to be created.
+      // See also bug 1058977.
 
       SpecialPowers.wrap(input).value = file.path;
       checkValidity(input, true, apply);
 
-      file.remove(false);
       break;
     case 'date':
       // For date, the step is calulated on the timestamp since 1970-01-01
       // which mean that for all dates prior to the epoch, this timestamp is < 0
       // and the behavior might differ, therefore we have to test for these cases.
 
       // When step is invalid, every date is valid
       input.step = 0;
--- a/content/html/content/test/forms/test_submit_invalid_file.html
+++ b/content/html/content/test/forms/test_submit_invalid_file.html
@@ -1,24 +1,24 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=702949
 -->
 <head>
   <meta charset="utf-8">
   <title>Test invalid file submission</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=702949">Mozilla Bug 702949</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  <form action='submit_invalid_file.sjs' method='post' target='result'
+  <form action='http://mochi.test:8888/chrome/content/html/content/test/forms/submit_invalid_file.sjs' method='post' target='result'
         enctype='multipart/form-data'>
     <input type='file' name='file'>
   </form>
   <iframe name='result'></iframe>
 </div>
 <pre id="test">
 </pre>
 <script type="application/javascript">
--- a/content/html/content/test/test_bug592802.html
+++ b/content/html/content/test/test_bug592802.html
@@ -55,17 +55,17 @@ SimpleTest.waitForFocus(function() {
   b2.focus(); // Be sure the element is visible.
   document.getElementById('b2').addEventListener("change", function(aEvent) {
     aEvent.target.removeEventListener("change", arguments.callee, false);
     ok(false, "When cancel is received, change should not fire");
   }, false);
   b2.click();
 
   // Now, we can launch tests when file picker isn't canceled.
-  MockFilePicker.useAnyFile();
+  MockFilePicker.useBlobFile();
   MockFilePicker.returnValue = MockFilePicker.returnOK;
 
   var b = document.getElementById('b');
   b.focus(); // Be sure the element is visible.
 
   document.getElementById('a').addEventListener("change", function(aEvent) {
     ok(true, "change event correctly sent");
     ok(aEvent.bubbles, "change event should bubble");
new file mode 100644
--- /dev/null
+++ b/embedding/test/chrome.ini
@@ -0,0 +1,8 @@
+[DEFAULT]
+skip-if = buildapp == 'b2g'
+support-files =
+  320x240.ogv
+  bug449141_page.html
+
+[test_bug449141.html]
+skip-if = toolkit == 'android'
--- a/embedding/test/mochitest.ini
+++ b/embedding/test/mochitest.ini
@@ -1,18 +1,14 @@
 [DEFAULT]
 skip-if = buildapp == 'b2g'
 support-files =
-  320x240.ogv
   bug293834_form.html
-  bug449141_page.html
 
 [test_bug293834.html]
-[test_bug449141.html]
-skip-if = toolkit == 'android'
 [test_bug499115.html]
 [test_nsFind.html]
 [test_private_window_from_content.html]
 # Next two tests are disabled in e10s because of bug 989501.
 [test_window_open_position_constraint.html]
 skip-if = toolkit == 'android' || e10s
 [test_window_open_units.html]
 skip-if = toolkit == 'android' || e10s
--- a/embedding/test/moz.build
+++ b/embedding/test/moz.build
@@ -1,8 +1,8 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
-
+MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
--- a/embedding/test/test_bug449141.html
+++ b/embedding/test/test_bug449141.html
@@ -1,17 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=449141
 -->
 <head>
   <title>Test for Bug 449141</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=449141">Mozilla Bug 449141</a>
 <p id="display">
 
 </p>
 <pre id="results"></pre>
 <div id="content" style="display: none">