Bug 1456050 - Add marionette.debugging.clicktostart to MarionettePrefs. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 23 Apr 2018 07:17:44 +0100
changeset 786406 b62f3aea32b945aecd3edee040dbe42aac6be1e2
parent 786343 378a8a64401f765bfd0706ff678a4f5db7c05385
child 786407 cde304647e7343b36f60bcd7230dc382acef3e5f
push id107448
push userbmo:ato@sny.no
push dateMon, 23 Apr 2018 06:34:28 +0000
reviewerswhimboo
bugs1456050
milestone61.0a1
Bug 1456050 - Add marionette.debugging.clicktostart to MarionettePrefs. r?whimboo MozReview-Commit-ID: BAxcJFcv1uD
testing/marionette/driver.js
testing/marionette/prefs.js
testing/marionette/prefs/marionette.js
testing/marionette/test/unit/test_prefs.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -41,16 +41,17 @@ const {
   WebDriverError,
 } = ChromeUtils.import("chrome://marionette/content/error.js", {});
 ChromeUtils.import("chrome://marionette/content/evaluate.js");
 const {pprint} = ChromeUtils.import("chrome://marionette/content/format.js", {});
 ChromeUtils.import("chrome://marionette/content/interaction.js");
 ChromeUtils.import("chrome://marionette/content/l10n.js");
 ChromeUtils.import("chrome://marionette/content/legacyaction.js");
 ChromeUtils.import("chrome://marionette/content/modal.js");
+const {MarionettePrefs} = ChromeUtils.import("chrome://marionette/content/prefs.js", {});
 ChromeUtils.import("chrome://marionette/content/proxy.js");
 ChromeUtils.import("chrome://marionette/content/reftest.js");
 ChromeUtils.import("chrome://marionette/content/session.js");
 const {
   PollPromise,
   TimedPromise,
 } = ChromeUtils.import("chrome://marionette/content/sync.js", {});
 
@@ -58,17 +59,16 @@ Cu.importGlobalProperties(["URL"]);
 
 this.EXPORTED_SYMBOLS = ["GeckoDriver"];
 
 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,
   element.Strategy.Selector,
   element.Strategy.ID,
   element.Strategy.TagName,
   element.Strategy.XPath,
@@ -728,18 +728,17 @@ GeckoDriver.prototype.newSession = async
         if (ev.target != win.document) {
           return;
         }
         win.removeEventListener("load", listener);
         waitForWindow.call(this);
       };
       win.addEventListener("load", listener, true);
     } else {
-      let clickToStart = Preferences.get(CLICK_TO_START_PREF);
-      if (clickToStart) {
+      if (MarionettePrefs.clickToStart) {
         Services.prompt.alert(win, "", "Click to start execution of marionette tests");
       }
       this.startBrowser(win, true);
     }
   };
 
   if (!Preferences.get(CONTENT_LISTENER_PREF)) {
     waitForWindow.call(this);
--- a/testing/marionette/prefs.js
+++ b/testing/marionette/prefs.js
@@ -150,16 +150,27 @@ class MarionetteBranch extends Branch {
     return this.get("enabled", false);
   }
 
   set enabled(isEnabled) {
     this.set("enabled", isEnabled);
   }
 
   /**
+   * The `marionette.debugging.clicktostart` preference delays
+   * server startup until a modal dialogue has been clicked to allow
+   * time for user to set breakpoints in the Browser Toolbox.
+   *
+   * @return {boolean}
+   */
+  get clickToStart() {
+    return this.get("debugging.clicktostart", false);
+  }
+
+  /**
    * The `marionette.port` preference, detailing which port
    * the TCP server should listen on.
    *
    * @return {number}
    */
   get port() {
     return this.get("port", 2828);
   }
--- a/testing/marionette/prefs/marionette.js
+++ b/testing/marionette/prefs/marionette.js
@@ -6,17 +6,17 @@
 
 // Marionette is the remote protocol that lets OOP programs
 // communicate with, instrument, and control Gecko.
 
 // Starts and stops the Marionette server.
 pref("marionette.enabled", false);
 
 // Delay server startup until a modal dialogue has been clicked to
-// allow time for user to set breakpoints in Browser Toolbox.
+// allow time for user to set breakpoints in the Browser Toolbox.
 pref("marionette.debugging.clicktostart", false);
 
 // Marionette logging verbosity.  Allowed values are "fatal", "error",
 // "warn", "info", "config", "debug", and "trace".
 pref("marionette.log.level", "info");
 
 // Port to start Marionette server on.
 pref("marionette.port", 2828);
--- a/testing/marionette/test/unit/test_prefs.js
+++ b/testing/marionette/test/unit/test_prefs.js
@@ -98,16 +98,17 @@ add_test(function test_EnvironmentPrefs_
     env.set("FOO", null);
   }
 
   run_next_test();
 });
 
 add_test(function test_MarionettePrefs_getters() {
   equal(false, MarionettePrefs.enabled);
+  equal(false, MarionettePrefs.clickToStart);
   equal(2828, MarionettePrefs.port);
   equal(Log.Level.Info, MarionettePrefs.logLevel);
   equal(true, MarionettePrefs.recommendedPrefs);
 
   run_next_test();
 });
 
 add_test(function test_MarionettePrefs_setters() {