Additional test for Bug 666604, r=volkmar
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 06 Jul 2011 16:02:26 +0300
changeset 72416 eb4d059af819237e9d02da62dd2f013a6c6be773
parent 72415 4e151ddc06c0cbbcc421ee2adedf1c6a7b300bfd
child 72417 709b5696199b5c146f81f7a981598ad2d93cf0df
child 72420 28578aeaf8b383fe673374ccf5a9a95a171ada7d
child 72523 091f9b61d32634d261ddfaa76a0f970a708b69e0
push id20714
push useropettay@mozilla.com
push dateWed, 06 Jul 2011 13:59:21 +0000
treeherdermozilla-central@eb4d059af819 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvolkmar
bugs666604
milestone8.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
Additional test for Bug 666604, r=volkmar
content/base/test/test_bug666604.html
--- a/content/base/test/test_bug666604.html
+++ b/content/base/test/test_bug666604.html
@@ -18,16 +18,28 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a href="javascript:activationListener()" id="testlink">test</a>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 666604 **/
 
 SimpleTest.waitForExplicitFinish();
 
+function hitEventLoop(times, next)
+{
+  if (times == 0) {
+     next();
+     return;
+   }
+ 
+  SimpleTest.executeSoon(function() {
+    hitEventLoop(times - 1, next);
+  });
+}
+
 var activationListener;
 
 function dispatchClick(target, ctrl) {
   var e = document.createEvent("MouseEvent");
   e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, 
                    ctrl, false, false, false, 0, null);
   target.dispatchEvent(e);
 }
@@ -66,27 +78,27 @@ function test2() {
 
 function test3() {
   activationListener =
   function() {
     ok(false, "Untrusted click+ctrl should not activate a link");
     test4();
   }
   dispatchClick(testlink, true);
-  setTimeout(test4, 1000);
+  hitEventLoop(10, test4);
 }
 
 function test4() {
   activationListener =
     function() {
       ok(false, "Untrusted return keypress+ctrl should not activate a link");
       test5();
     }
   dispatchReturn(testlink, true);
-  setTimeout(test5, 1000);
+  hitEventLoop(10, test5);
 }
 
 function test5() {
   activationListener =
     function() {
       ok(true, "click() should activate a link");
       test6();
     }
@@ -97,28 +109,46 @@ function test6() {
   activationListener =
     function() {
       ok(true, "Untrusted DOMActivate should activate a link");
       test7();
     }
   dispatchDOMActivate(testlink);
 }
 
+var oldPref;
 function test7() {
+  oldPref = SpecialPowers.getBoolPref("dom.disable_open_during_load");
+  SpecialPowers.setBoolPref("dom.disable_open_during_load", false);
   testlink.href = "javascript:opener.activationListener(); window.close();";
   testlink.target = "_blank";
   activationListener =
     function() {
       ok(true, "Click() should activate a link");
-      setTimeout(test9, 0);
+      setTimeout(test8, 0);
     }
   testlink.click();
 }
 
+function test8() {
+  SpecialPowers.setBoolPref("dom.disable_open_during_load", true);
+  testlink.href = "javascript:opener.activationListener(); window.close();";
+  testlink.target = "_blank";
+  activationListener =
+    function() {
+      ok(false, "Click() should not activate a link");
+      setTimeout(test9, 0);
+    }
+  testlink.click();  
+  hitEventLoop(10, test9);
+} 
+
+
 function test9() {
+  SpecialPowers.setBoolPref("dom.disable_open_during_load", oldPref);
   SimpleTest.finish();
 }
 
 addLoadEvent(test1);
 
 </script>
 </pre>
 </body>