Bug 1103196 - Add acceptInsecureCerts capability; r=automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 01 Nov 2016 18:07:24 +0000
changeset 444159 5ba2870f3ba2399bb1a175bb09dcd413cada2b0f
parent 444158 a5f1137dadfc08200f3cc104505a1c191aa41d78
child 444160 f05a99f3f3cf50698fd7854a759171b98e9562fe
push id37208
push userbmo:ato@mozilla.com
push dateSat, 26 Nov 2016 15:03:07 +0000
reviewersautomatedtester
bugs1103196
milestone53.0a1
Bug 1103196 - Add acceptInsecureCerts capability; r=automatedtester Reads the `acceptInsecureCerts` capability and sets the session state. MozReview-Commit-ID: KVErmdxwXQB
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -120,16 +120,20 @@ this.GeckoDriver = function(appName, ser
   this.observing = null;
   this._browserIds = new WeakMap();
 
   // user-defined timeouts
   this.scriptTimeout = 30000;  // 30 seconds
   this.searchTimeout = null;
   this.pageTimeout = 300000;  // five minutes
 
+  // Unsigned or invalid TLS certificates will be ignored if secureTLS
+  // is set to false.
+  this.secureTLS = true;
+
   // The curent context decides if commands should affect chrome- or
   // content space.
   this.context = Context.CONTENT;
 
   this.importedScripts = new evaluate.ScriptStorageService(
       [Context.CHROME, Context.CONTENT]);
   this.sandboxes = new Sandboxes(() => this.getCurrentWindow());
   this.actions = new action.Chain();
@@ -141,16 +145,17 @@ this.GeckoDriver = function(appName, ser
   this.testName = null;
 
   this.sessionCapabilities = {
     // mandated capabilities
     "browserName": Services.appinfo.name.toLowerCase(),
     "browserVersion": Services.appinfo.version,
     "platformName": Services.sysinfo.getProperty("name").toLowerCase(),
     "platformVersion": Services.sysinfo.getProperty("version"),
+    "acceptInsecureCerts": !this.secureTLS,
 
     // supported features
     "raisesAccessibilityExceptions": false,
     "rotatable": this.appName == "B2G",
     "acceptSslCerts": false,
     "proxy": {},
 
     // proprietary extensions
@@ -644,16 +649,24 @@ GeckoDriver.prototype.setSessionCapabili
     throw new SessionNotCreatedError(
         `Not all requiredCapabilities could be met: ${JSON.stringify(errors)}`);
   };
 
   // clone, overwrite, and set
   let caps = copy(this.sessionCapabilities);
   caps = copy(newCaps, caps);
   logger.config("Changing capabilities: " + JSON.stringify(caps));
+
+  // update session state
+  this.secureTLS = !caps.acceptInsecureCerts;
+  if (!this.secureTLS) {
+    logger.warn("Invalid or self-signed TLS certificates " +
+        "will be discarded for this session");
+  }
+
   this.sessionCapabilities = caps;
 };
 
 GeckoDriver.prototype.setUpProxy = function(proxy) {
   logger.config("User-provided proxy settings: " + JSON.stringify(proxy));
 
   assert.object(proxy);
   if (!proxy.hasOwnProperty("proxyType")) {