Bug 772823 - Focus the main test window before closing the newly opened window in order to work around an unknown focus manager bug; r=gavin
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 17 Apr 2014 10:59:10 -0400
changeset 197957 d80b56079e66317ec4fe36c0a615169ed4d20d08
parent 197955 c962bde5ac0b277dbcce06e071b7f0011e58a49b
child 197958 9e43ff213b6454ff835a6990aa0498e663914881
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs772823
milestone31.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 772823 - Focus the main test window before closing the newly opened window in order to work around an unknown focus manager bug; r=gavin
docshell/test/chrome/mozFrameType_window.xul
--- a/docshell/test/chrome/mozFrameType_window.xul
+++ b/docshell/test/chrome/mozFrameType_window.xul
@@ -28,27 +28,30 @@
       var typeContentFrame = document.getElementById("typeContentFrame");
 
       SimpleTest.is(getDocShellType(normalFrame), Ci.nsIDocShellTreeItem.typeChrome,
                     "normal iframe in chrome document is typeChrome");
       SimpleTest.is(getDocShellType(typeContentFrame), Ci.nsIDocShellTreeItem.typeContent,
                     "iframe with mozFrameType='content' in chrome document is typeContent");
 
       SimpleTest.executeSoon(function () {
-        // Wait for the window to be closed before finishing the test
-        let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                     .getService(Components.interfaces.nsIWindowWatcher);
-        ww.registerNotification(function windowObs(subject, topic, data) {
-          if (topic == "domwindowclosed") {
-            ww.unregisterNotification(windowObs);
+        // First focus the parent window and then close this one.
+        SimpleTest.waitForFocus(function() {
+          let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
+                       .getService(Components.interfaces.nsIWindowWatcher);
+          ww.registerNotification(function windowObs(subject, topic, data) {
+            if (topic == "domwindowclosed") {
+              ww.unregisterNotification(windowObs);
 
-            SimpleTest.waitForFocus(function() {
-              SimpleTest.finish();
-            }, opener);
-          }
-        });
+              // Don't start the next test synchronously!
+              SimpleTest.executeSoon(function() {
+                SimpleTest.finish();
+              });
+            }
+          });
 
-        window.close();
+          window.close();
+        }, opener);
       });
     }
   ]]></script>
 </window>