Bug 885324 - Try to fix intermittent failure in test_bug529119-2.html. r=mayhemer, a=test-only
authorMartijn Wargers <mwargers@mozilla.com>
Mon, 21 Jul 2014 15:10:50 +0200
changeset 217649 c665d9c7682d4d1026cc0585a6edb97170b47610
parent 217648 36adbb8b0b8386e11d1c9df823c1a8413d1d6a2d
child 217650 aedf42b6ead30cbe957009d35afaf94e53b97015
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer, test-only
bugs885324, 529119
milestone33.0a2
Bug 885324 - Try to fix intermittent failure in test_bug529119-2.html. r=mayhemer, a=test-only
docshell/test/test_bug529119-2.html
--- a/docshell/test/test_bug529119-2.html
+++ b/docshell/test/test_bug529119-2.html
@@ -9,16 +9,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 var workingURL = "http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
 var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
 
 var w = null;
 var phase = 0;
+var isWindowLoaded = false;
 
 function pollForPage(expectErrorPage, f, w)
 {
   // Start with polling after a delay, we might mistakenly take the current page
   // as an expected one.
   window.setTimeout(function() {
     var iterationsLeft = 200;
     var int = window.setInterval(function() {
@@ -37,16 +38,22 @@ function pollForPage(expectErrorPage, f,
         f(iterationsLeft > 0);
       }
     }, 100);
   }, 1000);
 }
 
 function windowLoaded()
 {
+  // The code under here should only be run once
+  // The test popup window workingURL was already opened
+  if (isWindowLoaded)
+    return;
+  isWindowLoaded = true;
+
   /* 2. We have successfully loaded a page, now go to a faulty URL */
   // XXX The test fails when we change the location synchronously 
   window.setTimeout(function() {
     w.location.href = faultyURL;
   }, 0);
 
   pollForPage(true, function(succeeded) {
     ok(succeeded, "Waiting for error page succeeded");