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 75496 e79dbde50f8e5b61a6b2586ce02b6de19136cdb5
parent 75495 46dc0fb0b1cb4b5b90bbb655f4e0d6d820e0aae6
child 75497 861e1307c43c06c74b623b9dd6af591f646ecd31
push id21031
push usermak77@bonardo.net
push dateFri, 19 Aug 2011 09:40:40 +0000
treeherdermozilla-central@1881f9b5f8b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvolkmar
bugs675201, 514732, 632379
milestone9.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 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:
  *