--- a/testing/marionette/session.js
+++ b/testing/marionette/session.js
@@ -52,31 +52,34 @@ session.Timeouts = class {
return {
implicit: this.implicit,
pageLoad: this.pageLoad,
script: this.script,
};
}
static fromJSON(json) {
- assert.object(json);
+ assert.object(json, pprint `Expected a session.Timeouts object, got ${json}`);
let t = new session.Timeouts();
for (let [typ, ms] of Object.entries(json)) {
switch (typ) {
case "implicit":
- t.implicit = assert.positiveInteger(ms);
+ t.implicit = assert.positiveInteger(ms,
+ pprint `Expected entry for "implicit" to be a positive integer, got ${ms}`);
break;
case "script":
- t.script = assert.positiveInteger(ms);
+ t.script = assert.positiveInteger(ms,
+ pprint `Expected entry for "script" to be a positive integer, got ${ms}`);
break;
case "pageLoad":
- t.pageLoad = assert.positiveInteger(ms);
+ t.pageLoad = assert.positiveInteger(ms,
+ pprint `Expected entry for "pageLoad" to be a positive integer, got ${ms}`);
break;
default:
throw new InvalidArgumentError("Unrecognised timeout: " + typ);
}
}
return t;
@@ -285,17 +288,18 @@ session.Proxy = class {
if (typeof json.httpProxy != "undefined") {
[p.httpProxy, p.httpProxyPort] = fromHost("http", json.httpProxy);
}
if (typeof json.sslProxy != "undefined") {
[p.sslProxy, p.sslProxyPort] = fromHost("https", json.sslProxy);
}
if (typeof json.socksProxy != "undefined") {
[p.socksProxy, p.socksProxyPort] = fromHost("socks", json.socksProxy);
- p.socksVersion = assert.positiveInteger(json.socksVersion);
+ p.socksVersion = assert.positiveInteger(json.socksVersion,
+ pprint `Expected "socksVersion" to be a positive integer, got ${json.socksVersion}`);
}
if (typeof json.noProxy != "undefined") {
let entries = assert.array(json.noProxy,
pprint`Expected "noProxy" to be an array, got ${json.noProxy}`);
p.noProxy = entries.map(entry => {
assert.string(entry,
pprint`Expected "noProxy" entry to be a string, got ${entry}`);
return stripBracketsFromIpv6Hostname(entry);
@@ -418,37 +422,39 @@ session.Capabilities = class extends Map
*
* @return {session.Capabilities}
* Internal representation of WebDriver capabilities.
*/
static fromJSON(json) {
if (typeof json == "undefined" || json === null) {
json = {};
}
- assert.object(json);
+ assert.object(json, pprint `Expected a session.Capabilities object, got ${json}`);
return session.Capabilities.match_(json);
}
// Matches capabilities as described by WebDriver.
static match_(json = {}) {
let matched = new session.Capabilities();
for (let [k, v] of Object.entries(json)) {
switch (k) {
case "acceptInsecureCerts":
- assert.boolean(v);
+ assert.boolean(v,
+ pprint `Expected "${k}" to be boolean, got ${v}`);
matched.set("acceptInsecureCerts", v);
break;
case "pageLoadStrategy":
if (v === null) {
matched.set("pageLoadStrategy", session.PageLoadStrategy.Normal);
} else {
- assert.string(v);
+ assert.string(v,
+ pprint `Expected "${k}" to be a string, got ${v}`);
if (Object.values(session.PageLoadStrategy).includes(v)) {
matched.set("pageLoadStrategy", v);
} else {
throw new InvalidArgumentError(
"Unknown page load strategy: " + v);
}
}
@@ -461,22 +467,24 @@ session.Capabilities = class extends Map
break;
case "timeouts":
let timeouts = session.Timeouts.fromJSON(v);
matched.set("timeouts", timeouts);
break;
case "moz:webdriverClick":
- assert.boolean(v);
+ assert.boolean(v,
+ pprint `Expected "${k}" to be boolean, got ${v}`);
matched.set("moz:webdriverClick", v);
break;
case "moz:accessibilityChecks":
- assert.boolean(v);
+ assert.boolean(v,
+ pprint `Expected "${k}" to be boolean, got ${v}`);
matched.set("moz:accessibilityChecks", v);
break;
}
}
return matched;
}
};