Bug 1470646 - Return platformName as recommended by WebDriver. r?whimboo
The WebDriver standard recommends that we return one of "windows",
"mac", or "linux". Additionally Marionette supports Fennec, for
which we return "android": this is fine because the specification
does not yet cover mobile browsers.
MozReview-Commit-ID: EgZ9UKrbsrd
--- a/testing/marionette/capabilities.js
+++ b/testing/marionette/capabilities.js
@@ -360,17 +360,17 @@ class Proxy {
/** WebDriver session capabilities representation. */
class Capabilities extends Map {
/** @class */
constructor() {
super([
// webdriver
["browserName", appinfo.name],
["browserVersion", appinfo.version],
- ["platformName", Services.sysinfo.getProperty("name").toLowerCase()],
+ ["platformName", getWebDriverPlatformName()],
["platformVersion", Services.sysinfo.getProperty("version")],
["pageLoadStrategy", PageLoadStrategy.Normal],
["acceptInsecureCerts", false],
["timeouts", new Timeouts()],
["proxy", new Proxy()],
// features
["rotatable", appinfo.name == "B2G"],
@@ -494,16 +494,31 @@ class Capabilities extends Map {
}
}
this.Capabilities = Capabilities;
this.PageLoadStrategy = PageLoadStrategy;
this.Proxy = Proxy;
this.Timeouts = Timeouts;
+function getWebDriverPlatformName() {
+ let name = Services.sysinfo.getProperty("name");
+
+ switch (name) {
+ case "Windows_NT":
+ return "windows";
+
+ case "Darwin":
+ return "mac";
+
+ default:
+ return name.toLowerCase();
+ }
+}
+
// Specialisation of |JSON.stringify| that produces JSON-safe object
// literals, dropping empty objects and entries which values are undefined
// or null. Objects are allowed to produce their own JSON representations
// by implementing a |toJSON| function.
function marshal(obj) {
let rv = Object.create(null);
function* iter(mapOrObject) {
--- a/testing/marionette/test/unit/test_capabilities.js
+++ b/testing/marionette/test/unit/test_capabilities.js
@@ -366,16 +366,17 @@ add_test(function test_Proxy_fromJSON()
run_next_test();
});
add_test(function test_Capabilities_ctor() {
let caps = new Capabilities();
ok(caps.has("browserName"));
ok(caps.has("browserVersion"));
ok(caps.has("platformName"));
+ ok(["linux", "mac", "windows", "android"].includes(caps.get("platformName")));
ok(caps.has("platformVersion"));
equal(PageLoadStrategy.Normal, caps.get("pageLoadStrategy"));
equal(false, caps.get("acceptInsecureCerts"));
ok(caps.get("timeouts") instanceof Timeouts);
ok(caps.get("proxy") instanceof Proxy);
ok(caps.has("rotatable"));