Bug 675201 - Wait until the window opened by layout/generic/test/test_bug514732.html is closed before running the next test, hopefully fixing the intermittent orange in layout/generic/test/test_bug632379.xul; r=volkmar
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 18 Aug 2011 11:09:16 -0400
changeset 75498 e79dbde50f8e5b61a6b2586ce02b6de19136cdb5
parent 75497 46dc0fb0b1cb4b5b90bbb655f4e0d6d820e0aae6
child 75499 861e1307c43c06c74b623b9dd6af591f646ecd31
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersvolkmar
bugs675201, 514732, 632379
milestone9.0a1
Bug 675201 - Wait until the window opened by layout/generic/test/test_bug514732.html is closed before running the next test, hopefully fixing the intermittent orange in layout/generic/test/test_bug632379.xul; r=volkmar
docshell/test/chrome/docshell_helpers.js
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -318,18 +318,30 @@ function finish() {
   // enableBFCache(), then restore it now.
   if (typeof(gOrigMaxTotalViewers) != "undefined") {
     SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers",
       gOrigMaxTotalViewers);
   }
 
   // Close the test window and signal the framework that the test is done.
   let opener = window.opener;
+  let SimpleTest = opener.wrappedJSObject.SimpleTest;
+
+  // Wait for the window to be closed before finishing the test
+  let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher);
+  ww.registerNotification(function(subject, topic, data) {
+    if (topic == "domwindowclosed") {
+      ww.unregisterNotification(arguments.callee);
+      SimpleTest.waitForFocus(function() {
+        SimpleTest.finish();
+      }, opener);
+    }
+  });
+
   window.close();
-  opener.wrappedJSObject.SimpleTest.finish();
 }
 
 /**
  * Helper function which waits until another function returns true, or until a 
  * timeout occurs, and then notifies a callback.
  *
  * Parameters:
  *