Bug 1407925 - Don't use application name but ID to determine Firefox. r=ato, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Thu, 12 Oct 2017 13:21:17 +0200
changeset 434882 13bdb1a613e51ec8f1ad9ae3c53e30f2903b4325
parent 434881 860c47bcfc10f6c7162dc48587ba5fb60f8e861f
child 434883 f7fd0e6a425aca3d5b523a5a22416d1de7905a50
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, test-only
bugs1407925
milestone57.0
Bug 1407925 - Don't use application name but ID to determine Firefox. r=ato, a=test-only 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
@@ -52,16 +52,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,
@@ -127,23 +129,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
@@ -584,17 +586,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(
@@ -813,17 +815,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
@@ -304,24 +304,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");
     }