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 179866 d80b56079e66317ec4fe36c0a615169ed4d20d08
parent 179865 c962bde5ac0b277dbcce06e071b7f0011e58a49b
child 179867 9e43ff213b6454ff835a6990aa0498e663914881
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersgavin
bugs772823
milestone31.0a1
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>