Bug 787545: Allow Marionette on fennec to return a session; r=jgriffin
authorDavid Burns <dburns@mozilla.com>
Tue, 18 Sep 2012 01:08:55 -0700
changeset 107516 eacd4f900b5632dccb50c91d76e13ca9d7960742
parent 107515 dbd4f12bebc071ed9451f27b78912706e7e41640
child 107517 81b2a9d689799669d2635daff3ede4fccdd512a6
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersjgriffin
bugs787545
milestone18.0a1
Bug 787545: Allow Marionette on fennec to return a session; r=jgriffin
testing/marionette/marionette-actors.js
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -364,28 +364,28 @@ MarionetteDriverActor.prototype = {
    * the client to test in.
    *
    */
   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)) { 
+      if (!win || (appName == "Firefox" && !win.gBrowser) || (appName == "Fennec" && !win.BrowserApp)) { 
         checkTimer.initWithCallback(waitForWindow.bind(this), 100, Ci.nsITimer.TYPE_ONE_SHOT);
       }
       else {
         this.startBrowser(win, true);
       }
     }
 
     if (!Services.prefs.getBoolPref("marionette.contentListener")) {
       waitForWindow.call(this);
     }
-    else if ((appName == "B2G") && (this.curBrowser == null)) {
+    else if ((appName != "Firefox") && (this.curBrowser == null)) {
       //if there is a content listener, then we just wake it up
       this.addBrowser(this.getCurrentWindow());
       this.curBrowser.startSession(false, this.getCurrentWindow(), this.whenBrowserStarted);
       this.messageManager.broadcastAsyncMessage("Marionette:restart", {});
     }
     else {
       this.sendError("Session already running", 500, null);
     }
@@ -1555,33 +1555,38 @@ function BrowserObj(win) {
 BrowserObj.prototype = {
   /**
    * Set the browser if the application is not B2G
    *
    * @param nsIDOMWindow win
    *        current window reference
    */
   setBrowser: function BO_setBrowser(win) {
-    if (appName != "B2G") {
-      this.browser = win.gBrowser; 
+    switch (appName) {
+      case "Firefox":
+        this.browser = win.gBrowser;
+        break;
+      case "Fennec":
+        this.browser = win.BrowserApp;
+        break;
     }
   },
   /**
    * Called when we start a session with this browser.
    *
    * In a desktop environment, if newTab is true, it will start 
    * a new 'about:blank' tab and change focus to this tab.
    *
    * This will also set the active messagemanager for this object
    *
    * @param boolean newTab
    *        If true, create new tab
    */
   startSession: function BO_startSession(newTab, win, callback) {
-    if (appName == "B2G") {
+    if (appName != "Firefox") {
       callback(win, newTab);
     }
     else if (newTab) {
       this.addTab(this.startPage);
       //if we have a new tab, make it the selected tab
       this.browser.selectedTab = this.tab;
       let newTabBrowser = this.browser.getBrowserForTab(this.tab);
       // wait for tab to be loaded
@@ -1640,17 +1645,17 @@ BrowserObj.prototype = {
    * @param string id
    *        frame id
    * @param string href
    *        frame's href 
    */
   register: function BO_register(id, href) {
     let uid = id + ((appName == "B2G") ? '-b2g' : '');
     if (this.curFrameId == null) {
-      if ((!this.newSession) || (this.newSession && ((appName == "B2G") || href.indexOf(this.startPage) > -1))) {
+      if ((!this.newSession) || (this.newSession && ((appName != "Firefox") || href.indexOf(this.startPage) > -1))) {
         this.curFrameId = uid;
         this.mainContentId = uid;
       }
     }
     this.knownFrames.push(uid); //used to deletesessions
     return uid;
   },
 }