Bug 883164 - More tests for <input type='file'>.click(). r=smaug
☠☠ backed out by 6e84744ffa9a ☠ ☠
authorMounir Lamouri <mounir.lamouri@gmail.com>
Mon, 17 Jun 2013 11:58:47 +0200
changeset 146777 eff8e7fefffdfa451c57e7011883d91766316e37
parent 146776 4b01f6cc761c40788b9a4534bf02ff13e619c939
child 146778 b40f8cdc7279611b36849069e9d77d1f85587b37
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs883164
milestone24.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 883164 - More tests for <input type='file'>.click(). r=smaug
content/html/content/test/forms/test_input_file_picker.html
--- a/content/html/content/test/forms/test_input_file_picker.html
+++ b/content/html/content/test/forms/test_input_file_picker.html
@@ -18,36 +18,38 @@
   <input id='c' type='file' accept="video/*">
   <input id='d' type='file' accept="image/*, audio/* ">
   <input id='e' type='file' accept=" image/*,video/*">
   <input id='f' type='file' accept="audio/*,video/*">
   <input id='g' type='file' accept="image/*, audio/* ,video/*">
   <input id='h' type='file' accept="foo/baz,image/*,bogus/duh">
   <input id='i' type='file' accept="mime/type;parameter,video/*">
   <input id='j' type='file' accept="audio/*, audio/*, audio/*">
-  <input id='k' type="file" accept="image/gif,image/png" />
-  <input id='l' type="file" accept="image/*,image/gif,image/png" />
-  <input id='m' type="file" accept="image/gif,image/gif" />
-  <input id='n' type="file" accept="" />
+  <input id='k' type="file" accept="image/gif,image/png">
+  <input id='l' type="file" accept="image/*,image/gif,image/png">
+  <input id='m' type="file" accept="image/gif,image/gif">
+  <input id='n' type="file" accept="">
   <input id='z' type='file' accept="i/am,a,pathological,;,,,,test/case">
   <input id='hidden' hidden type='file'>
   <input id='untrusted-click' type='file'>
   <input id='prevent-default' type='file'>
   <input id='prevent-default-false' type='file'>
   <input id='right-click' type='file'>
   <input id='middle-click' type='file'>
   <input id='left-click' type='file'>
   <label id='label-1'>foo<input type='file'></label>
   <label id='label-2' for='labeled-2'>foo</label><input id='labeled-2' type='file'></label>
   <label id='label-3'>foo<input type='file'></label>
   <label id='label-4' for='labeled-4'>foo</label><input id='labeled-4' type='file'></label>
   <input id='by-button' type='file'>
   <button id='button-click' onclick="document.getElementById('by-button').click();">foo</button>
   <button id='button-down' onclick="document.getElementById('by-button').click();">foo</button>
   <button id='button-up' onclick="document.getElementById('by-button').click();">foo</button>
+  <div id='div-click' onclick="document.getElementById('by-button').click();">foo</div>
+  <div id='div-click-on-demand' onclick="var i=document.createElement('input'); i.type='file'; i.click();">foo</div>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /**
  * This test checks various scenarios and make sure that a file picker is being
  * shown in all of them (minus a few exceptions).
  * |testData| defines the tests to do and |launchNextTest| can be used to have
@@ -89,16 +91,18 @@ var testData = [["a", 1, MockFilePicker.
                 ["left-click", 0, undefined, 0],
                 ["label-1", 0, undefined, 0],
                 ["label-2", 0, undefined, 0],
                 ["label-3", 0, undefined, 0],
                 ["label-4", 0, undefined, 0],
                 ["button-click", 0, undefined, 0],
                 ["button-down", 0, undefined, 0],
                 ["button-up", 0, undefined, 0],
+                ["div-click", 0, undefined, 0],
+                ["div-click-on-demand", 0, undefined, 0],
                ];
 
 var currentTest = 0;
 var filterAllAdded;
 var filters;
 var filterIndex;
 
 // disable popups to make sure that the popup blocker does not interfere
@@ -149,17 +153,19 @@ function launchNextTest() {
       ++currentTest;
       launchNextTest();
     }, 500);
   } else if (testData[currentTest][0] == 'label-3' ||
              testData[currentTest][0] == 'label-4') {
     synthesizeMouse(document.getElementById(testData[currentTest][0]), 5, 5, {});
   } else if (testData[currentTest][0] == 'button-click' ||
              testData[currentTest][0] == 'button-down' ||
-             testData[currentTest][0] == 'button-up') {
+             testData[currentTest][0] == 'button-up' ||
+             testData[currentTest][0] == 'div-click' ||
+             testData[currentTest][0] == 'div-click-on-demand') {
     synthesizeMouseAtCenter(document.getElementById(testData[currentTest][0]), {});
   } else {
     document.getElementById(testData[currentTest][0]).click();
   }
 }
 
 function runTests() {
   MockFilePicker.appendFilterCallback = function(filepicker, title, val) {
@@ -188,36 +194,23 @@ function runTests() {
       is(filters.length, testData[currentTest][1],
          "appendFilters not called as often as expected (" + testName + ")");
       is(filters[0], testData[currentTest][2],
          "Correct filters should have been added (" + testName + ")");
       is(filterIndex, testData[currentTest][3],
          "File picker should show the correct filter index (" + testName + ")");
 
       if (++currentTest == testData.length) {
-        setTimeout(testDisconnectedElement, 0);
+        MockFilePicker.cleanup();
+        SimpleTest.finish();
       } else {
         launchNextTest();
       }
     });
   };
 
   launchNextTest();
 }
 
-function testDisconnectedElement() {
-  MockFilePicker.shown = false;
-  MockFilePicker.showCallback = function(filepicker) {
-    ok(MockFilePicker.shown, "FilePicker should be open!");
-    MockFilePicker.shown = false;
-    MockFilePicker.cleanup();
-    SimpleTest.finish();
-  }
-  var f = document.createElement("input");
-  f.setAttribute("type", "file");
-  f.click();
-  ok(!MockFilePicker.shown, "FilePicker should open asynchronously!");
-}
-
 </script>
 </pre>
 </body>
 </html>