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.
Also lints the WPT New Session tests.
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,33 @@ 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";
+
+ case "Android":
+ case "Linux":
+ 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"));
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -523104,17 +523104,17 @@
"ab3c3d205e59df800ba5b4217245b83685521c31",
"reftest"
],
"css/css-scoping/shadow-host-with-before-after.html": [
"99af6e29e69b3131b59dbdc2b0eead52931123c2",
"reftest"
],
"css/css-scoping/shadow-link-rel-stylesheet-no-style-leak.html": [
- "76a54dabd8bd09f7155ab0331e3d17d1a0cae243",
+ "a46be006762a16c2deb3d1d3a760e3c4e348668c",
"reftest"
],
"css/css-scoping/shadow-link-rel-stylesheet.html": [
"07862ce7d2a954988bdbce882869a4c5f097089a",
"reftest"
],
"css/css-scoping/shadow-reassign-dynamic-001.html": [
"11ed4da2e6ce88d8a2b98a8f1c814417ef7770dd",
@@ -548596,17 +548596,17 @@
"cd3f0233cc0eaf9295e602ca25aef87fb68df851",
"support"
],
"css/mediaqueries/support/min-width-tables-001-iframe.html": [
"29e7fb34c94e2e8411514d1e71d09aca2ddb642e",
"support"
],
"css/mediaqueries/test_media_queries.html": [
- "a7d78b13e119f8cd1ffa8812a9af67e59280084d",
+ "cff3585932589f611a7101329d3b5b6ca27820aa",
"testharness"
],
"css/mediaqueries/viewport-script-dynamic-ref.html": [
"7d55c513e2de39c9b362fc864233a3008ca6ced2",
"support"
],
"css/mediaqueries/viewport-script-dynamic.html": [
"1c2ba1a9116942599804ed29553e85628afadb04",
@@ -559700,17 +559700,17 @@
"d1661ab1734f7d1a252030aeac7e9842a7a4cb3b",
"testharness"
],
"custom-elements/Document-createElement-svg.svg": [
"9af8f2dc7778feeea4fa8e557d7885b10d325dea",
"testharness"
],
"custom-elements/Document-createElement.html": [
- "46e64c9f412fb04582f8ec287e08783ac83cb933",
+ "0edab8da0f16d5d2239ffb21f446c371fe4c76c3",
"testharness"
],
"custom-elements/Document-createElementNS.html": [
"da90b2a1c13cf18fd5cade85dcae2dadef6243c9",
"testharness"
],
"custom-elements/HTMLElement-constructor.html": [
"4dc04a8b026538bddee52586f2df50206abc9334",
@@ -577844,17 +577844,17 @@
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
"html/resources/common.js": [
"0f18ee2c61b99893cfe2a3d1ff549b170a8d715d",
"support"
],
"html/scripting/the-noscript-element/non-html-noscript.html": [
- "c0c5453111f29e5a0206f988f4d127ec8ebc2f13",
+ "121760184777008c2ddeb598278216e40b34e367",
"testharness"
],
"html/semantics/.gitkeep": [
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
"html/semantics/OWNERS": [
"abd95839027a88741c4d351ff374d81b773c80fa",
@@ -619080,41 +619080,41 @@
"6274392529489518207961ed5e6b6bb3ff081572",
"wdspec"
],
"webdriver/tests/new_session/__init__.py": [
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
"webdriver/tests/new_session/conftest.py": [
- "d2df38e506cb9a3e501f03fe03e2a31af42d6f04",
+ "93d472d4653fb54dabad9917b764966009add676",
"support"
],
"webdriver/tests/new_session/create_alwaysMatch.py": [
- "84f8ad0908e9ec787f9db73ff66cbe193c2c9626",
+ "cf23ac1d3546917d4da9b78384e747356a1ca83f",
"wdspec"
],
"webdriver/tests/new_session/create_firstMatch.py": [
- "fbdabf1852c07db0f5df2d47954c1cd5d7285492",
+ "c3f825382c246d26af2adf6911f522ea7cfa43e5",
"wdspec"
],
"webdriver/tests/new_session/default_values.py": [
"92c26366f8fd0d37587457b9b5a630df4b19cc60",
"wdspec"
],
"webdriver/tests/new_session/invalid_capabilities.py": [
- "fcc36e5ca46cb8a9fb9927d5f618c7e9433a0260",
+ "440bcb7b7b5f316c9b239afc40f99e3deb94c759",
"wdspec"
],
"webdriver/tests/new_session/merge.py": [
- "000b28631bb6d862b654f1f998852f5f1a6b2e12",
+ "856d7c846766b3dd2bc6f23026aa23910407e23d",
"wdspec"
],
"webdriver/tests/new_session/response.py": [
- "5eabb99858b9c3051efb351096d7ba8dca8dbfce",
+ "3be8cfd44eb4c9908ec65e66dcdc6a9ea0e5241b",
"wdspec"
],
"webdriver/tests/new_session/support/__init__.py": [
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
"webdriver/tests/new_session/support/create.py": [
"4bfb99fd4ba44ab5b4e70e9246cbb200c098ae89",
--- a/testing/web-platform/tests/webdriver/tests/new_session/conftest.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/conftest.py
@@ -6,17 +6,17 @@ import webdriver
def product(a, b):
return [(a, item) for item in b]
def flatten(l):
return [item for x in l for item in x]
+
@pytest.fixture(scope="session")
def platform_name():
return {
"linux2": "linux",
"win32": "windows",
"cygwin": "windows",
"darwin": "mac"
}.get(sys.platform)
-
--- a/testing/web-platform/tests/webdriver/tests/new_session/create_alwaysMatch.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/create_alwaysMatch.py
@@ -1,13 +1,12 @@
-#META: timeout=long
+# META: timeout=long
import pytest
from conftest import product, flatten
from support.create import valid_data
@pytest.mark.parametrize("key,value", flatten(product(*item) for item in valid_data))
def test_valid(new_session, add_browser_capabilites, key, value):
resp = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({key: value})}})
-
--- a/testing/web-platform/tests/webdriver/tests/new_session/create_firstMatch.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/create_firstMatch.py
@@ -1,9 +1,9 @@
-#META: timeout=long
+# META: timeout=long
import pytest
from conftest import product, flatten
from support.create import valid_data
--- a/testing/web-platform/tests/webdriver/tests/new_session/invalid_capabilities.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/invalid_capabilities.py
@@ -1,9 +1,9 @@
-#META: timeout=long
+# META: timeout=long
import pytest
from webdriver import error
from conftest import product, flatten
@pytest.mark.parametrize("value", [None, 1, "{}", []])
@@ -90,9 +90,8 @@ invalid_extensions = [
def test_invalid_extensions(new_session, add_browser_capabilites, body, key):
capabilities = body(key, {})
if "alwaysMatch" in capabilities:
capabilities["alwaysMatch"] = add_browser_capabilites(capabilities["alwaysMatch"])
else:
capabilities["firstMatch"][0] = add_browser_capabilites(capabilities["firstMatch"][0])
with pytest.raises(error.InvalidArgumentException):
resp = new_session({"capabilities": capabilities})
-
--- a/testing/web-platform/tests/webdriver/tests/new_session/merge.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/merge.py
@@ -1,9 +1,9 @@
-#META: timeout=long
+# META: timeout=long
import pytest
from webdriver import error
from conftest import platform_name
@pytest.mark.skipif(platform_name() is None, reason="Unsupported platform")
@@ -72,10 +72,10 @@ def test_merge_browserName(new_session,
"pageLoadStrategy": "none"
},
{
"browserName": browser_settings["browserName"],
"pageLoadStrategy": "eager"
}
]}})
- assert resp["capabilities"]["browserName"] == browser_settings['browserName']
+ assert resp["capabilities"]["browserName"] == browser_settings["browserName"]
assert resp["capabilities"]["pageLoadStrategy"] == "eager"
--- a/testing/web-platform/tests/webdriver/tests/new_session/response.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/response.py
@@ -1,12 +1,13 @@
# META: timeout=long
import uuid
+
def test_resp_sessionid(new_session, add_browser_capabilites):
resp, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({})}})
assert isinstance(resp["sessionId"], unicode)
uuid.UUID(hex=resp["sessionId"])
def test_resp_capabilites(new_session, add_browser_capabilites):
resp, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({})}})
@@ -44,11 +45,12 @@ def test_resp_data(new_session, add_brow
def test_timeouts(new_session, add_browser_capabilites, platform_name):
resp, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"timeouts": {"implicit": 1000}})}})
assert resp["capabilities"]["timeouts"] == {
"implicit": 1000,
"pageLoad": 300000,
"script": 30000
}
+
def test_pageLoadStrategy(new_session, add_browser_capabilites, platform_name):
resp, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"pageLoadStrategy": "eager"})}})
assert resp["capabilities"]["pageLoadStrategy"] == "eager"