Bug 802807 - Only listen for system-message-listener-ready for JS tests, r=mdas, DONTBUILD(NPOTB)
authorJonathan Griffin <jgriffin@mozilla.com>
Wed, 17 Oct 2012 15:14:51 -0700
changeset 110532 b08ec0a016196281d4aa02cbcfb433b6c8d04271
parent 110531 366998e4e1dcee7ed85e22011b07db8414b84c50
child 110533 214853a2917426fef4fa6a54c749b2dd4ba5ac46
push id23697
push userjgriffin@mozilla.com
push dateWed, 17 Oct 2012 22:15:01 +0000
treeherdermozilla-central@b08ec0a01619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas, DONTBUILD
bugs802807
milestone19.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 802807 - Only listen for system-message-listener-ready for JS tests, r=mdas, DONTBUILD(NPOTB)
testing/marionette/client/marionette/marionette_test.py
testing/marionette/marionette-actors.js
--- a/testing/marionette/client/marionette/marionette_test.py
+++ b/testing/marionette/client/marionette/marionette_test.py
@@ -154,16 +154,27 @@ class MarionetteJSTestCase(CommonTestCas
     @classmethod
     def add_tests_to_suite(cls, mod_name, filepath, suite, testloader, marionette):
         suite.addTest(cls(weakref.ref(marionette), jsFile=filepath))
 
     def runTest(self):
         if self.marionette.session is None:
             self.marionette.start_session()
         self.marionette.execute_script("log('TEST-START: %s');" % self.jsFile.replace('\\', '\\\\'))
+
+        self.marionette.set_context(self.marionette.CONTEXT_CHROME)
+        self.marionette.set_script_timeout(30000)
+        self.marionette.execute_async_script("""
+waitFor(
+    function() { marionetteScriptFinished(true); },
+    function() { return isSystemMessageListenerReady(); }
+);
+            """)
+        self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
+
         f = open(self.jsFile, 'r')
         js = f.read()
         args = []
 
         # if this is a browser_ test, prepend head.js to it
         if os.path.basename(self.jsFile).startswith('browser_'):
             local_head = open(os.path.join(os.path.dirname(__file__), 'tests', 'head.js'), 'r')
             js = local_head.read() + js
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -444,18 +444,17 @@ MarionetteDriverActor.prototype = {
    */
   newSession: function MDA_newSession() {
 
     function waitForWindow() {
       let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
       let win = this.getCurrentWindow();
       if (!win ||
           (appName == "Firefox" && !win.gBrowser) ||
-          (appName == "Fennec" && !win.BrowserApp) ||
-          (appName == "B2G" && !systemMessageListenerReady)) { 
+          (appName == "Fennec" && !win.BrowserApp)) { 
         checkTimer.initWithCallback(waitForWindow.bind(this), 100, Ci.nsITimer.TYPE_ONE_SHOT);
       }
       else {
         this.startBrowser(win, true);
       }
     }
 
     this.switchToGlobalMessageManager();
@@ -601,16 +600,19 @@ MarionetteDriverActor.prototype = {
       try {
         _chromeSandbox[fn] = marionette[fn].bind(marionette);
       }
       catch(e) {
         _chromeSandbox[fn] = marionette[fn];
       }
     });
 
+    _chromeSandbox.isSystemMessageListenerReady =
+        function() { return systemMessageListenerReady; }
+
     if (specialPowers == true) {
       loader.loadSubScript("chrome://specialpowers/content/specialpowersAPI.js",
                            _chromeSandbox);
       loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js",
                            _chromeSandbox);
       loader.loadSubScript("chrome://specialpowers/content/ChromePowers.js",
                            _chromeSandbox);
     }