Bug 610619: Wait for window to completely open before continuing browser_contentAreaClick.js. r=mak, a=tests
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 08 Mar 2011 09:48:45 -0800
changeset 63354 bf2db29072f48f8f267a929cba518ce37d76f0dc
parent 63353 3792abcada4a449ee4d2b10c039ee6ef4805e92d
child 63355 acdd32f121999b26e0554cfdef5f01c59ed4c269
push idunknown
push userunknown
push dateunknown
reviewersmak, tests
bugs610619
milestone2.0b13pre
Bug 610619: Wait for window to completely open before continuing browser_contentAreaClick.js. r=mak, a=tests
browser/base/content/test/browser_contentAreaClick.js
--- a/browser/base/content/test/browser_contentAreaClick.js
+++ b/browser/base/content/test/browser_contentAreaClick.js
@@ -179,26 +179,33 @@ let gInvokedMethods = [];
 
 // The test currently running.
 let gCurrentTest = null;
 
 function test() {
   waitForExplicitFinish();
 
   gTestWin = openDialog(location, "", "chrome,all,dialog=no", "about:blank");
-  gTestWin.addEventListener("load", function (event) {
-    info("Window loaded.");
-    gTestWin.removeEventListener("load", arguments.callee, false);
+  Services.obs.addObserver(function(aSubject, aTopic, aData) {
+    if (aSubject != gTestWin)
+      return;
+
+    Services.obs.removeObserver(arguments.callee, "browser-delayed-startup-finished");
+
+    info("Browser window opened");
     waitForFocus(function() {
-      info("Setting up browser...");
-      setupTestBrowserWindow();
-      info("Running tests...");
-      executeSoon(runNextTest);
-    }, gTestWin.content, true);
-  }, false);
+      info("Browser window focused");
+      waitForFocus(function() {
+        info("Setting up browser...");
+        setupTestBrowserWindow();
+        info("Running tests...");
+        executeSoon(runNextTest);
+      }, gTestWin.content, true);
+    }, gTestWin);
+  }, "browser-delayed-startup-finished", false);
 }
 
 // Click handler used to steal click events.
 let gClickHandler = {
   handleEvent: function (event) {
     let linkId = event.target.id;
     is(event.type, "click",
        gCurrentTest.desc + ":Handler received a click event on " + linkId);