Bug 850302 - B2G mochitests time out on tests using window.open. r=jlebar
authorMartijn Wargers <mwargers@mozilla.com>
Fri, 22 Mar 2013 08:41:07 -0700
changeset 128500 ed313842afecdb3df56769e7a9672f8e95e1427c
parent 128499 783f66376d6553f2d1510b039aaa198f480e1ff9
child 128501 29a5fd2889f3e703c07ac2241accadfbb0fb4059
push id24529
push userryanvm@gmail.com
push dateFri, 12 Apr 2013 11:51:36 +0000
treeherdermozilla-central@5bc732a49eae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs850302
milestone23.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 850302 - B2G mochitests time out on tests using window.open. r=jlebar
testing/mochitest/runtestsb2g.py
--- a/testing/mochitest/runtestsb2g.py
+++ b/testing/mochitest/runtestsb2g.py
@@ -54,19 +54,18 @@ class B2GMochitest(Mochitest):
         if self.OOP:
             OOP_script = """
 let specialpowers = {};
 let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
 loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js", specialpowers);
 let specialPowersObserver = new specialpowers.SpecialPowersObserver();
 specialPowersObserver.init();
 
-let fl = container.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
-fl.activateRemoteFrame();
-let mm = fl.messageManager;
+let mm = container.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
+container.focus();
 mm.addMessageListener("SPPrefService", specialPowersObserver);
 mm.addMessageListener("SPProcessCrashService", specialPowersObserver);
 mm.addMessageListener("SPPingService", specialPowersObserver);
 mm.addMessageListener("SpecialPowers.Quit", specialPowersObserver);
 mm.addMessageListener("SPPermissionManager", specialPowersObserver);
 
 mm.loadFrameScript(CHILD_LOGGER_SCRIPT, true);
 mm.loadFrameScript(CHILD_SCRIPT_API, true);
@@ -80,18 +79,37 @@ specialPowersObserver._isFrameScriptLoad
         # the test-container apps's iframe to the mochitest URL.
         self.automation.test_script = """
 const CHILD_SCRIPT = "chrome://specialpowers/content/specialpowers.js";
 const CHILD_SCRIPT_API = "chrome://specialpowers/content/specialpowersAPI.js";
 const CHILD_LOGGER_SCRIPT = "chrome://specialpowers/content/MozillaLogger.js";
 
 let homescreen = document.getElementById('homescreen');
 let container = homescreen.contentWindow.document.getElementById('test-container');
-container.setAttribute('mozapp', 'http://mochi.test:8888/manifest.webapp');
+
+function openWindow(aEvent) {
+  var popupIframe = aEvent.detail.frameElement;
+  popupIframe.setAttribute('style', 'position: absolute; left: 0; top: 300px; background: white; ');
+
+  popupIframe.addEventListener('mozbrowserclose', function(e) {
+    container.parentNode.removeChild(popupIframe);
+    container.focus();
+  });
 
+  // yes, the popup can call window.open too!
+  popupIframe.addEventListener('mozbrowseropenwindow', openWindow);
+
+  popupIframe.addEventListener('mozbrowserloadstart', function(e) {
+    popupIframe.focus();
+  });
+
+  container.parentNode.appendChild(popupIframe);
+}
+
+container.addEventListener('mozbrowseropenwindow', openWindow);
 %s
 
 container.src = '%s';
 """ % (OOP_script, testURL)
 
     def buildProfile(self, options):
         # preferences
         prefs = {}