From bdf6e5f009f60a8a7bb423a831e8aaeb427edb99 Mon Sep 17 00:00:00 2001 From: Maksim Sadym Date: Wed, 13 Nov 2024 15:13:11 +0100 Subject: [PATCH] Add testdriver_features and use in Chrome * Add testdriver_features * Update doc * Enable bidi in Chrome based on `testdriver_features` containing `bidi` * Enable `infrastructure/webdriver/bidi/subscription.html` for chrome * Enable `infrastructure/testdriver/bidi/permissions/set_permission.https.html` for chrome * Enable `infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html` for Chrome --- .../testdriver-extension-tutorial.md | 12 +++- docs/writing-tests/testdriver.md | 14 +++++ .../bluetooth/simulate_adapter.https.html.ini | 3 +- .../permissions/set_permission.https.html.ini | 3 +- .../webdriver/bidi/subscription.html.ini | 3 +- .../webdriver/bidi/subscription.window.js.ini | 2 + .../bluetooth/simulate_adapter.https.html | 2 +- .../permissions/set_permission.https.html | 2 +- .../webdriver/bidi/subscription.html | 4 +- .../webdriver/bidi/subscription.window.js | 22 ++++++++ lint.ignore | 1 + resources/testdriver.js | 24 ++++++++ tools/lint/lint.py | 28 +++++++--- tools/manifest/item.py | 6 ++ tools/manifest/sourcefile.py | 56 ++++++++++++++++++- tools/manifest/tests/test_manifest.py | 10 +++- tools/manifest/tests/test_sourcefile.py | 53 ++++++++++++++++++ tools/wptrunner/wptrunner/browsers/chrome.py | 19 ++++++- .../wptrunner/executors/executorchrome.py | 32 ++++++++++- tools/wptrunner/wptrunner/wpttest.py | 11 +++- 20 files changed, 280 insertions(+), 27 deletions(-) create mode 100644 infrastructure/metadata/infrastructure/webdriver/bidi/subscription.window.js.ini create mode 100644 infrastructure/webdriver/bidi/subscription.window.js diff --git a/docs/writing-tests/testdriver-extension-tutorial.md b/docs/writing-tests/testdriver-extension-tutorial.md index ca867c392da70e..6a1da4e0077de1 100644 --- a/docs/writing-tests/testdriver-extension-tutorial.md +++ b/docs/writing-tests/testdriver-extension-tutorial.md @@ -90,8 +90,16 @@ We will leave this unimplemented and override it in another file. Lets do that n #### WebDriver BiDi -For commands using WebDriver BiDi, add the methods to `window.test_driver.bidi`. Parameters are passed as a single object `params`. - +For commands using WebDriver BiDi, add the methods to `test_driver.bidi`. Parameters are passed as a single object `params`. For example [`test_driver.bidi.permissions.set_permission`](https://github.com/web-platform-tests/wpt/blob/5ec8ba6d68f27d49a056cbf940e3bc9a8324c538/resources/testdriver.js#L183). + +Before calling `test_driver_internal` method, assert the `bidi` testdriver feature is enabled. +```javascript +set_permission: function (params) { + assertBidiIsEnabled(); + return window.test_driver_internal.bidi.permissions.set_permission( + params); +} +``` ### [tools/wptrunner/wptrunner/testdriver-extra.js](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/testdriver-extra.js) diff --git a/docs/writing-tests/testdriver.md b/docs/writing-tests/testdriver.md index 462c7b85503cb9..42a862fbe1e139 100644 --- a/docs/writing-tests/testdriver.md +++ b/docs/writing-tests/testdriver.md @@ -32,6 +32,20 @@ document when using testdriver from a different context): The api in `test_driver.bidi` provides access to the [WebDriver BiDi](https://w3c.github.io/webdriver-bidi) protocol. +### Markup ### + +To use WebDriver BiDi, enable the `bidi` feature in `testdriver.js` by adding +`feature=bidi` query string parameter. Details are in [RFC 214: Add testdriver features](https://github.com/web-platform-tests/rfcs/blob/master/rfcs/testdriver-features.md). +```html + +``` + +```javascript +// META: script=/resources/testdriver.js?feature=bidi +``` + +[Example](https://github.com/web-platform-tests/wpt/blob/aae46926b1fdccd460e1c6eaaf01ca20b941fbce/infrastructure/webdriver/bidi/subscription.html#L6). + ### Context ### A WebDriver BiDi "browsing context" is equivalent to an diff --git a/infrastructure/metadata/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html.ini b/infrastructure/metadata/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html.ini index 7c3127d167a740..a40a56bcdb9bd8 100644 --- a/infrastructure/metadata/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html.ini +++ b/infrastructure/metadata/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html.ini @@ -1 +1,2 @@ -disabled: https://github.com/web-platform-tests/wpt/issues/47544 +disabled : + if product != "chrome": @True diff --git a/infrastructure/metadata/infrastructure/testdriver/bidi/permissions/set_permission.https.html.ini b/infrastructure/metadata/infrastructure/testdriver/bidi/permissions/set_permission.https.html.ini index 7c3127d167a740..1a5ac47c67d942 100644 --- a/infrastructure/metadata/infrastructure/testdriver/bidi/permissions/set_permission.https.html.ini +++ b/infrastructure/metadata/infrastructure/testdriver/bidi/permissions/set_permission.https.html.ini @@ -1 +1,2 @@ -disabled: https://github.com/web-platform-tests/wpt/issues/47544 +disabled: + if product != "chrome": @True diff --git a/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.html.ini b/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.html.ini index 7c3127d167a740..1a5ac47c67d942 100644 --- a/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.html.ini +++ b/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.html.ini @@ -1 +1,2 @@ -disabled: https://github.com/web-platform-tests/wpt/issues/47544 +disabled: + if product != "chrome": @True diff --git a/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.window.js.ini b/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.window.js.ini new file mode 100644 index 00000000000000..1a5ac47c67d942 --- /dev/null +++ b/infrastructure/metadata/infrastructure/webdriver/bidi/subscription.window.js.ini @@ -0,0 +1,2 @@ +disabled: + if product != "chrome": @True diff --git a/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html b/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html index 3850fa26974a32..ed60285c41fabe 100644 --- a/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html +++ b/infrastructure/testdriver/bidi/bluetooth/simulate_adapter.https.html @@ -3,7 +3,7 @@ TestDriver bidi.bluetooth.simulate_adapter method - + - + - + + + """.encode("utf-8") + + s = create("html/test.html", contents=contents) + s.testdriver_features == None + + +@pytest.mark.parametrize("features", + [[], ['feature_1'], ['feature_1', 'feature_2']]) +def test_html_testdriver_features(features): + contents = f""" +