Bug 908878 - Fix for intermittent browser_webconsole_bug_595350_multiple_windows_and_tabs.js | Timed out while waiting for: 4 web consoles {opened|closed}; r=me
authorMihai Sucan <mihai.sucan@gmail.com>
Fri, 20 Sep 2013 15:42:42 +0300
changeset 148154 e9c56a9b76d9ce1e119753ce24e9848d32e66bb5
parent 148153 3ca60aa3a003f64c9b73b0db4d2851a6bfa7a21f
child 148155 f38cdc45bd504f7c3ec1fdfbfdf4d3c632248a5c
push id34129
push userryanvm@gmail.com
push dateFri, 20 Sep 2013 22:16:47 +0000
treeherdermozilla-inbound@15b2fe123070 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs908878
milestone27.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 908878 - Fix for intermittent browser_webconsole_bug_595350_multiple_windows_and_tabs.js | Timed out while waiting for: 4 web consoles {opened|closed}; r=me
browser/devtools/webconsole/test/browser_webconsole_bug_595350_multiple_windows_and_tabs.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_595350_multiple_windows_and_tabs.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_595350_multiple_windows_and_tabs.js
@@ -14,17 +14,17 @@
 
 const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 595350";
 
 let win1 = window, win2;
 let openTabs = [];
 let loadedTabCount = 0;
 
 function test() {
-  requestLongerTimeout(2);
+  requestLongerTimeout(3);
 
   // Add two tabs in the main window.
   addTabs(win1);
 
   // Open a new window.
   win2 = OpenBrowserWindow();
   win2.addEventListener("load", onWindowLoad, true);
 }
@@ -40,16 +40,17 @@ function addTabs(aWindow) {
   for (let i = 0; i < 2; i++) {
     let tab = aWindow.gBrowser.addTab(TEST_URI);
     openTabs.push(tab);
 
     tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) {
       tab.linkedBrowser.removeEventListener(aEvent.type, onLoad, true);
 
       loadedTabCount++;
+      info("tabs loaded: " + loadedTabCount);
       if (loadedTabCount >= 4) {
         executeSoon(openConsoles);
       }
     }, true);
   }
 }
 
 function openConsoles() {
@@ -57,58 +58,44 @@ function openConsoles() {
   let consolesOpen = 0;
   for (let i = 0; i < openTabs.length; i++) {
     let tab = openTabs[i];
     openConsole(tab, function(index, hud) {
       ok(hud, "HUD is open for tab " + index);
       let window = hud.target.tab.linkedBrowser.contentWindow;
       window.console.log("message for tab " + index);
       consolesOpen++;
+      if (consolesOpen == 4) {
+        // Use executeSoon() to allow the promise to resolve.
+        executeSoon(closeConsoles);
+      }
     }.bind(null, i));
   }
-
-  waitForSuccess({
-    timeout: 15000,
-    name: "4 web consoles opened",
-    validatorFn: function()
-    {
-      return consolesOpen == 4;
-    },
-    successFn: closeConsoles,
-    failureFn: closeConsoles,
-  });
 }
 
 function closeConsoles() {
   let consolesClosed = 0;
 
   function onWebConsoleClose(aSubject, aTopic) {
     if (aTopic == "web-console-destroyed") {
       consolesClosed++;
+      info("consoles destroyed: " + consolesClosed);
+      if (consolesClosed == 4) {
+        // Use executeSoon() to allow all the observers to execute.
+        executeSoon(finishTest);
+      }
     }
   }
 
   Services.obs.addObserver(onWebConsoleClose, "web-console-destroyed", false);
 
+  registerCleanupFunction(() => {
+    Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
+  });
+
   win2.close();
 
   win1.gBrowser.removeTab(openTabs[0]);
   win1.gBrowser.removeTab(openTabs[1]);
 
   openTabs = win1 = win2 = null;
-
-  function onTimeout() {
-    Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
-    executeSoon(finishTest);
-  }
-
-  waitForSuccess({
-    timeout: 10000,
-    name: "4 web consoles closed",
-    validatorFn: function()
-    {
-      return consolesClosed == 4;
-    },
-    successFn: onTimeout,
-    failureFn: onTimeout,
-  });
 }