Bug 36619 - Add a test checking that we can call .click() to show the filepicker if the originating element is a regular click (thus passing the popup blocker check). r=sicking a2.0=blocking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 01 Sep 2010 08:09:28 +0200
changeset 51825 126e91feeb53afc3fee235105e24ced2eb665746
parent 51824 e9e0fe038a5afe6d27e544009eda8b2d24af31ae
child 51826 5676d91f4d1cbdf9cc6646ce34ba8460bf9c0b6f
push id15440
push usermlamouri@mozilla.com
push dateWed, 01 Sep 2010 06:03:55 +0000
treeherdermozilla-central@126e91feeb53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs36619
milestone2.0b6pre
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 36619 - Add a test checking that we can call .click() to show the filepicker if the originating element is a regular click (thus passing the popup blocker check). r=sicking a2.0=blocking
layout/forms/test/test_bug36619.html
--- a/layout/forms/test/test_bug36619.html
+++ b/layout/forms/test/test_bug36619.html
@@ -5,22 +5,23 @@ https://bugzilla.mozilla.org/show_bug.cg
 -->
 <head>
   <title>Test for Bug 36619</title>
   <script type="application/javascript" src="/MochiKit/packed.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
-<body onload="runTests();">
+<body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=36619">Mozilla Bug 36619</a>
 <p id="display"></p>
-<div id="content">
+<div id="content" style="display:none;">
   <input id='a' type='file'>
 </div>
+<button id='b' onclick="document.getElementById('a').click();">Show Filepicker</button>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 36619 **/
 
 SimpleTest.waitForExplicitFinish();
 
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
@@ -72,49 +73,48 @@ MockFilePicker.prototype = {
 };
 
 var mockFilePickerRegisterer =
   new MockObjectRegisterer("@mozilla.org/filepicker;1",MockFilePicker);
 
 mockFilePickerRegisterer.register();
 
 // enable popups the first time
-var pbi = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2);
-var oldAllow = pbi.getBoolPref("dom.disable_open_during_load");
-var oldShowBar = pbi.getBoolPref("privacy.popups.showBrowserMessage");
+var pbi = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2);
+var oldAllow = pbi.getBoolPref("dom.disable_open_during_load");
+var oldShowBar = pbi.getBoolPref("privacy.popups.showBrowserMessage");
 pbi.setBoolPref("dom.disable_open_during_load", true);
 pbi.setBoolPref("privacy.popups.showBrowserMessage", false);
 
 var shown = false;
 
 function checkFirst()
 {
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-  todo(shown,
-     "File picker show method should have been called");
+  ok(shown, "File picker show method should have been called");
   shown = false;
   document.getElementById("a").click();
   setTimeout(finishTest, 1000);
 }
 
 function finishTest()
 {
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-  ok(!shown,
-    "File picker show method should not have been called");
-    
+  ok(!shown, "File picker show method should not have been called");
+
   mockFilePickerRegisterer.unregister();
-                                 
+
   pbi.setBoolPref("dom.disable_open_during_load", oldAllow);
   pbi.setBoolPref("privacy.popups.showBrowserMessage", oldShowBar);
   SimpleTest.finish();
 }
-  
-function runTests()
-{
-  document.getElementById("a").click();
+
+SimpleTest.waitForFocus(function() {
+  var b = document.getElementById('b');
+  b.focus(); // Be sure the element is visible.
+  synthesizeMouse(b, 2, 2, {});
   SimpleTest.executeSoon(checkFirst);
-}
+});
 
 </script>
 </pre>
 </body>
 </html>