Bug 883164 - More tests for <input type='file'>.click(). r=smaug
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 02 Jul 2013 16:34:20 +0100
changeset 137166 3e6afe9129c367d7a5d3a615c71c89fbb0bd68df
parent 137165 aa7e63e100aed69d3e88bbc309bec8518f3a9325
child 137167 da9d61adaed29284c020f787d846dab72268793a
push id1822
push userryanvm@gmail.com
push dateTue, 02 Jul 2013 19:17:36 +0000
treeherderfx-team@7469440b076b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs883164
milestone25.0a1
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();" tabindex='1'>foo</div>
+  <div id='div-click-on-demand' onclick="var i=document.createElement('input'); i.type='file'; i.click();" tabindex='1'>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>