Bug 1407925 - Don't use application name but ID to determine Firefox. draft
authorHenrik Skupin <mail@hskupin.info>
Thu, 12 Oct 2017 13:21:17 +0200
changeset 679186 8bd9909eb1a43e8b6c7acd02996b852a060e68e9
parent 676550 8dba4037f395ce60309ce9e9b1675152f240ff98
child 735538 3108fb6f5fef929e8042e42c428792cd62045590
push id84150
push userbmo:hskupin@gmail.com
push dateThu, 12 Oct 2017 11:41:11 +0000
bugs1407925
milestone58.0a1
Bug 1407925 - Don't use application name but ID to determine Firefox. MozReview-Commit-ID: 9TZrs4nk31y
testing/marionette/assert.js
testing/marionette/driver.js
testing/marionette/modal.js
testing/marionette/server.js
--- a/testing/marionette/assert.js
+++ b/testing/marionette/assert.js
@@ -17,17 +17,18 @@ const {
   pprint,
   UnexpectedAlertOpenError,
   UnsupportedOperationError,
 } = Cu.import("chrome://marionette/content/error.js", {});
 
 this.EXPORTED_SYMBOLS = ["assert"];
 
 const isFennec = () => AppConstants.platform == "android";
-const isFirefox = () => Services.appinfo.name == "Firefox";
+const isFirefox = () =>
+    Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
 /**
  * Shorthands for common assertions made in Marionette.
  *
  * @namespace
  */
 this.assert = {};
 
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -48,16 +48,18 @@ Cu.import("chrome://marionette/content/p
 Cu.import("chrome://marionette/content/reftest.js");
 Cu.import("chrome://marionette/content/session.js");
 const {wait, TimedPromise} = Cu.import("chrome://marionette/content/wait.js", {});
 
 Cu.importGlobalProperties(["URL"]);
 
 this.EXPORTED_SYMBOLS = ["GeckoDriver", "Context"];
 
+const APP_ID_FIREFOX = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
+
 const FRAME_SCRIPT = "chrome://marionette/content/listener.js";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 const CLICK_TO_START_PREF = "marionette.debugging.clicktostart";
 const CONTENT_LISTENER_PREF = "marionette.contentListener";
 
 const SUPPORTED_STRATEGIES = new Set([
   element.Strategy.ClassName,
@@ -123,23 +125,23 @@ function* enumeratorIterator(enumerator)
  * browsing context's content frame message listener via ListenerProxy.
  *
  * Throughout this prototype, functions with the argument <var>cmd</var>'s
  * documentation refers to the contents of the <code>cmd.parameter</code>
  * object.
  *
  * @class GeckoDriver
  *
- * @param {string} appName
- *     Description of the product, for example "Firefox".
+ * @param {string} appId
+ *     Unique identifier of the application.
  * @param {MarionetteServer} server
  *     The instance of Marionette server.
  */
-this.GeckoDriver = function(appName, server) {
-  this.appName = appName;
+this.GeckoDriver = function(appId, server) {
+  this.appId = appId;
   this._server = server;
 
   this.sessionID = null;
   this.wins = new browser.Windows();
   this.browsers = {};
   // points to current browser
   this.curBrowser = null;
   // topmost chrome frame
@@ -580,17 +582,17 @@ GeckoDriver.prototype.registerBrowser = 
     this.curBrowser.frameManager.currentRemoteFrame.targetFrameId = id;
   }
 
   // We want to ignore frames that are XUL browsers that aren't in the "main"
   // tabbrowser, but accept things on Fennec (which doesn't have a
   // xul:tabbrowser), and accept HTML iframes (because tests depend on it),
   // as well as XUL frames. Ideally this should be cleaned up and we should
   // keep track of browsers a different way.
-  if (this.appName != "Firefox" || be.namespaceURI != XUL_NS ||
+  if (this.appId != APP_ID_FIREFOX || be.namespaceURI != XUL_NS ||
       be.nodeName != "browser" || be.getTabBrowser()) {
     // curBrowser holds all the registered frames in knownFrames
     this.curBrowser.register(id, be);
   }
 
   this.wins.set(id, listenerWindow);
   if (nullPrevious && (this.curBrowser.curFrameId !== null)) {
     this.sendAsync(
@@ -809,17 +811,17 @@ GeckoDriver.prototype.newSession = async
         Services.prompt.alert(win, "", "Click to start execution of marionette tests");
       }
       this.startBrowser(win, true);
     }
   };
 
   if (!Preferences.get(CONTENT_LISTENER_PREF)) {
     waitForWindow.call(this);
-  } else if (this.appName != "Firefox" && this.curBrowser === null) {
+  } else if (this.appId != APP_ID_FIREFOX && this.curBrowser === null) {
     // if there is a content listener, then we just wake it up
     let win = this.getCurrentWindow();
     this.addBrowser(win);
     this.whenBrowserStarted(win, false);
     this.mm.broadcastAsyncMessage("Marionette:restart", {});
   } else {
     throw new WebDriverError("Session already running");
   }
--- a/testing/marionette/modal.js
+++ b/testing/marionette/modal.js
@@ -7,17 +7,18 @@
 const {utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 
 this.EXPORTED_SYMBOLS = ["modal"];
 
 const COMMON_DIALOG = "chrome://global/content/commonDialog.xul";
 
-const isFirefox = () => Services.appinfo.name == "Firefox";
+const isFirefox = () =>
+    Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
 /** @namespace */
 this.modal = {
   COMMON_DIALOG_LOADED: "common-dialog-loaded",
   TABMODAL_DIALOG_LOADED: "tabmodal-dialog-loaded",
   handlers: {
     "common-dialog-loaded": new Set(),
     "tabmodal-dialog-loaded": new Set(),
--- a/testing/marionette/server.js
+++ b/testing/marionette/server.js
@@ -310,24 +310,24 @@ server.TCPListener = class {
     this.alive = false;
     this._acceptConnections = false;
     this.alteredPrefs = new Set();
   }
 
   /**
    * Function produces a GeckoDriver.
    *
-   * Determines application name to initialise the driver with.
+   * Determines the application to initialise the driver with.
    *
    * @return {GeckoDriver}
    *     A driver instance.
    */
   driverFactory() {
     Preferences.set(PREF_CONTENT_LISTENER, false);
-    return new GeckoDriver(Services.appinfo.name, this);
+    return new GeckoDriver(Services.appinfo.ID, this);
   }
 
   set acceptConnections(value) {
     if (!value) {
       logger.info("New connections will no longer be accepted");
     } else {
       logger.info("New connections are accepted again");
     }