From 5d0579eca67c497d7c60fe69241346422f3a420a Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Mon, 29 Jan 2024 10:45:49 +0000 Subject: [PATCH] Bug 1872252 - [remote] Make mach puppeteer-test to use WebDriver BiDi by default r=webdriver-reviewers,whimboo Differential Revision: https://phabricator.services.mozilla.com/D199620 --- remote/doc/Testing.md | 7 ++++++ remote/mach_commands.py | 32 ++++++++++++------------ taskcluster/ci/source-test/puppeteer.yml | 4 +-- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/remote/doc/Testing.md b/remote/doc/Testing.md index 86e62b2cbcb3..d0db9dc159b3 100644 --- a/remote/doc/Testing.md +++ b/remote/doc/Testing.md @@ -133,6 +133,13 @@ You can also run them against Chrome as: % ./mach puppeteer-test --product=chrome ``` +By default, Puppeteer will be configured to use the WebDriver BiDi protocol. You +can also force Puppeteer to use the CDP protocol with the `--cdp` option: + +```shell +% ./mach puppeteer-test --cdp +``` + By default the mach command will automatically install Puppeteer but that's only needed for the very first time, or when a new Puppeteer release has been vendored in. To skip the install step use the `--no-install` option. diff --git a/remote/mach_commands.py b/remote/mach_commands.py index fb2923737aa8..c01dddace11b 100644 --- a/remote/mach_commands.py +++ b/remote/mach_commands.py @@ -384,11 +384,11 @@ class PuppeteerRunner(MozbuildObject): Possible optional test parameters: - `bidi`: - Boolean to indicate whether to test Firefox with BiDi protocol. `binary`: Path for the browser binary to use. Defaults to the local build. + `cdp`: + Boolean to indicate whether to test Firefox with CDP protocol. `headless`: Boolean to indicate whether to activate Firefox' headless mode. `extra_prefs`: @@ -399,7 +399,7 @@ class PuppeteerRunner(MozbuildObject): """ setup() - with_bidi = params.get("bidi", False) + with_cdp = params.get("cdp", False) binary = params.get("binary") or self.get_binary_path() product = params.get("product", "firefox") @@ -444,7 +444,7 @@ class PuppeteerRunner(MozbuildObject): ".cache", ) - if with_bidi is True: + if not with_cdp: test_command = test_command + ":bidi" elif env["HEADLESS"] == "True": test_command = test_command + ":headless" @@ -488,7 +488,7 @@ class PuppeteerRunner(MozbuildObject): expectation for expectation in expected_data if is_relevant_expectation( - expectation, product, with_bidi, env["HEADLESS"], expected_platform + expectation, product, with_cdp, env["HEADLESS"], expected_platform ) ] @@ -516,16 +516,16 @@ def create_parser_puppeteer(): p.add_argument( "--product", type=str, default="firefox", choices=["chrome", "firefox"] ) - p.add_argument( - "--bidi", - action="store_true", - help="Flag that indicates whether to test Firefox with BiDi protocol.", - ) p.add_argument( "--binary", type=str, help="Path to browser binary. Defaults to local Firefox build.", ) + p.add_argument( + "--cdp", + action="store_true", + help="Flag that indicates whether to test Firefox with the CDP protocol.", + ) p.add_argument( "--ci", action="store_true", @@ -575,7 +575,7 @@ def create_parser_puppeteer(): def is_relevant_expectation( - expectation, expected_product, with_bidi, is_headless, expected_platform + expectation, expected_product, with_cdp, is_headless, expected_platform ): parameters = expectation["parameters"] @@ -584,11 +584,11 @@ def is_relevant_expectation( else: is_expected_product = "firefox" not in parameters - if with_bidi is True: + if with_cdp: + is_expected_protocol = "webDriverBiDi" not in parameters + else: is_expected_protocol = "cdp" not in parameters is_headless = "True" - else: - is_expected_protocol = "webDriverBiDi" not in parameters if is_headless == "True": is_expected_mode = "headful" not in parameters @@ -620,8 +620,8 @@ def is_relevant_expectation( ) def puppeteer_test( command_context, - bidi=None, binary=None, + cdp=False, ci=False, disable_fission=False, enable_webrender=False, @@ -683,8 +683,8 @@ def puppeteer_test( install_puppeteer(command_context, product, ci) params = { - "bidi": bidi, "binary": binary, + "cdp": cdp, "headless": headless, "enable_webrender": enable_webrender, "extra_prefs": prefs, diff --git a/taskcluster/ci/source-test/puppeteer.yml b/taskcluster/ci/source-test/puppeteer.yml index b4bd898d1f6d..a2499e9d8789 100644 --- a/taskcluster/ci/source-test/puppeteer.yml +++ b/taskcluster/ci/source-test/puppeteer.yml @@ -38,7 +38,7 @@ puppeteer: command: > cd $GECKO_PATH/ && $MOZ_FETCHES_DIR/firefox/firefox --screenshot http://example.org && - ./mach puppeteer-test --ci -vv --binary $MOZ_FETCHES_DIR/firefox/firefox --headless --log-tbpl - --log-errorsummary /builds/worker/pup_errorsummary.json + ./mach puppeteer-test --ci -vv --binary $MOZ_FETCHES_DIR/firefox/firefox --cdp --headless --log-tbpl - --log-errorsummary /builds/worker/pup_errorsummary.json puppeteer-with-bidi: description: Puppeteer tests against Firefox Webdriver BiDi remote protocol @@ -49,4 +49,4 @@ puppeteer-with-bidi: command: > cd $GECKO_PATH/ && $MOZ_FETCHES_DIR/firefox/firefox --screenshot http://example.org && - ./mach puppeteer-test --ci -vv --binary $MOZ_FETCHES_DIR/firefox/firefox --bidi --log-tbpl - --log-errorsummary /builds/worker/pup_errorsummary.json + ./mach puppeteer-test --ci -vv --binary $MOZ_FETCHES_DIR/firefox/firefox --log-tbpl - --log-errorsummary /builds/worker/pup_errorsummary.json