From 20f2b59ecfb9775155ea15bcd6521e033012099f Mon Sep 17 00:00:00 2001 From: Jonathan Griffin Date: Thu, 10 May 2012 11:42:54 -0700 Subject: [PATCH] Bug 753273 - Wait for window and browser at the start of newSession, r=mdas, a=test-only, DONTBUILD because NPOTB --- testing/marionette/marionette-actors.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/testing/marionette/marionette-actors.js b/testing/marionette/marionette-actors.js index e229b2c8ffc..e323065722a 100644 --- a/testing/marionette/marionette-actors.js +++ b/testing/marionette/marionette-actors.js @@ -336,8 +336,21 @@ 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 != "B2G" && !win.gBrowser)) { + checkTimer.initWithCallback(waitForWindow.bind(this), 100, Ci.nsITimer.TYPE_ONE_SHOT); + } + else { + this.startBrowser(win, true); + } + } + if (!prefs.getBoolPref("marionette.contentListener")) { - this.startBrowser(this.getCurrentWindow(), true); + waitForWindow.call(this); } else if ((appName == "B2G") && (this.curBrowser == null)) { //if there is a content listener, then we just wake it up