Skip to content

Commit 7c062fb

Browse files
[wptrunner] Replace content_shell with headless_shell (#46658)
Chromium CI plans to replace `content_shell` [0] with `headless_shell` [1] for running most WPTs. Replace the product accordingly, which is mostly a `chrome` clone. [0]: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/web_tests_in_content_shell.md [1]: https://chromium.googlesource.com/chromium/src/+/HEAD/headless/README.md
1 parent 3bd9ff9 commit 7c062fb

File tree

5 files changed

+90
-153
lines changed

5 files changed

+90
-153
lines changed

tools/wpt/browser.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from abc import ABCMeta, abstractmethod
1010
from datetime import datetime, timedelta, timezone
1111
from shutil import which
12+
from typing import Optional
1213
from urllib.parse import urlsplit
1314

1415
import html5lib
@@ -583,7 +584,7 @@ class ChromeChromiumBase(Browser):
583584
see https://web-platform-tests.org/running-tests/chrome-chromium-installation-detection.html
584585
"""
585586

586-
requirements = "requirements_chromium.txt"
587+
requirements: Optional[str] = "requirements_chromium.txt"
587588
platform = {
588589
"Linux": "Linux",
589590
"Windows": "Win",
@@ -1392,14 +1393,17 @@ def webdriver_version(self, webdriver_binary):
13921393
return m.group(1)
13931394

13941395

1395-
class ContentShell(Browser):
1396-
"""Interface for the Chromium content shell.
1396+
class HeadlessShell(ChromeChromiumBase):
1397+
"""Interface for the Chromium headless shell [0].
1398+
1399+
[0]: https://chromium.googlesource.com/chromium/src/+/HEAD/headless/README.md
13971400
"""
13981401

1399-
product = "content_shell"
1402+
product = "headless_shell"
14001403
requirements = None
14011404

14021405
def download(self, dest=None, channel=None, rename=None):
1406+
# TODO(crbug.com/344669542): Download binaries via CfT.
14031407
raise NotImplementedError
14041408

14051409
def install(self, dest=None, channel=None):
@@ -1409,17 +1413,16 @@ def install_webdriver(self, dest=None, channel=None, browser_binary=None):
14091413
raise NotImplementedError
14101414

14111415
def find_binary(self, venv_path=None, channel=None):
1412-
if uname[0] == "Darwin":
1413-
return which("Content Shell.app/Contents/MacOS/Content Shell")
1414-
return which("content_shell") # .exe is added automatically for Windows
1415-
1416-
def find_webdriver(self, venv_path=None, channel=None):
1417-
return None
1416+
# `which()` adds `.exe` extension automatically for Windows.
1417+
# Chromium builds an executable named `headless_shell`, whereas CfT
1418+
# ships under the name `chrome-headless-shell`.
1419+
return which("headless_shell") or which("chrome-headless-shell")
14181420

14191421
def version(self, binary=None, webdriver_binary=None):
1420-
# content_shell does not return version information.
1422+
# TODO(crbug.com/327767951): Support `headless_shell --version`.
14211423
return "N/A"
14221424

1425+
14231426
class ChromeAndroidBase(Browser):
14241427
"""A base class for ChromeAndroid and AndroidWebView.
14251428

tools/wpt/run.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def set_if_none(name, value):
112112

113113
def check_environ(product):
114114
if product not in ("android_webview", "chrome", "chrome_android", "chrome_ios",
115-
"content_shell", "edge", "firefox", "firefox_android",
115+
"edge", "firefox", "firefox_android", "headless_shell",
116116
"ladybird", "servo", "wktr"):
117117
config_builder = serve.build_config(os.path.join(wpt_root, "config.json"))
118118
# Override the ports to avoid looking for free ports
@@ -521,9 +521,9 @@ def setup_kwargs(self, kwargs):
521521
kwargs["binary_args"].append("--no-sandbox")
522522

523523

524-
class ContentShell(BrowserSetup):
525-
name = "content_shell"
526-
browser_cls = browser.ContentShell
524+
class HeadlessShell(BrowserSetup):
525+
name = "headless_shell"
526+
browser_cls = browser.HeadlessShell
527527
experimental_channels = ("dev", "canary", "nightly")
528528

529529
def setup_kwargs(self, kwargs):
@@ -533,7 +533,7 @@ def setup_kwargs(self, kwargs):
533533
if binary:
534534
kwargs["binary"] = binary
535535
else:
536-
raise WptrunError(f"Unable to locate {self.name.capitalize()} binary")
536+
raise WptrunError(f"Unable to locate {self.name!r} binary")
537537

538538
if kwargs["mojojs_path"]:
539539
kwargs["enable_mojojs"] = True
@@ -544,7 +544,13 @@ def setup_kwargs(self, kwargs):
544544
"Provide '--mojojs-path' explicitly instead.")
545545
logger.warning("MojoJS is disabled for this run.")
546546

547-
kwargs["enable_webtransport_h3"] = True
547+
# Never pause after test, since headless shell is not interactive.
548+
kwargs["pause_after_test"] = False
549+
# Don't add a `--headless` switch.
550+
kwargs["headless"] = False
551+
552+
if kwargs["enable_webtransport_h3"] is None:
553+
kwargs["enable_webtransport_h3"] = True
548554

549555

550556
class Chromium(Chrome):
@@ -867,8 +873,8 @@ def setup_kwargs(self, kwargs):
867873
"chrome_android": ChromeAndroid,
868874
"chrome_ios": ChromeiOS,
869875
"chromium": Chromium,
870-
"content_shell": ContentShell,
871876
"edge": Edge,
877+
"headless_shell": HeadlessShell,
872878
"safari": Safari,
873879
"servo": Servo,
874880
"servodriver": ServoWebDriver,

tools/wptrunner/wptrunner/browsers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"chrome_android",
2828
"chrome_ios",
2929
"chromium",
30-
"content_shell",
3130
"edge",
3231
"firefox",
3332
"firefox_android",
33+
"headless_shell",
3434
"safari",
3535
"sauce",
3636
"servo",

tools/wptrunner/wptrunner/browsers/content_shell.py

-134
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# mypy: allow-untyped-defs
2+
3+
from .base import cmd_arg, require_arg
4+
from .base import get_timeout_multiplier # noqa: F401
5+
from .chrome import ChromeBrowser, debug_args, executor_kwargs # noqa: F401
6+
from ..executors.base import WdspecExecutor # noqa: F401
7+
from ..executors.executorchrome import ( # noqa: F401
8+
ChromeDriverCrashTestExecutor,
9+
ChromeDriverPrintRefTestExecutor,
10+
ChromeDriverRefTestExecutor,
11+
ChromeDriverTestharnessExecutor,
12+
)
13+
14+
15+
__wptrunner__ = {"product": "headless_shell",
16+
"check_args": "check_args",
17+
"browser": "HeadlessShellBrowser",
18+
"executor": {
19+
"crashtest": "ChromeDriverCrashTestExecutor",
20+
"print-reftest": "ChromeDriverPrintRefTestExecutor",
21+
"reftest": "ChromeDriverRefTestExecutor",
22+
"testharness": "ChromeDriverTestharnessExecutor",
23+
"wdspec": "WdspecExecutor",
24+
},
25+
"browser_kwargs": "browser_kwargs",
26+
"executor_kwargs": "executor_kwargs",
27+
"env_extras": "env_extras",
28+
"env_options": "env_options",
29+
"update_properties": "update_properties",
30+
"timeout_multiplier": "get_timeout_multiplier",}
31+
32+
33+
def check_args(**kwargs):
34+
require_arg(kwargs, "webdriver_binary")
35+
36+
37+
def browser_kwargs(logger, test_type, run_info_data, config, **kwargs):
38+
return {"binary": kwargs["binary"],
39+
"webdriver_binary": kwargs["webdriver_binary"],
40+
"webdriver_args": kwargs.get("webdriver_args"),
41+
"debug_info": kwargs["debug_info"]}
42+
43+
44+
def env_extras(**kwargs):
45+
return []
46+
47+
48+
def env_options():
49+
return {"server_host": "127.0.0.1",
50+
"supports_debugger": True}
51+
52+
53+
def update_properties():
54+
return (["debug", "os", "processor"], {"os": ["version"], "processor": ["bits"]})
55+
56+
57+
class HeadlessShellBrowser(ChromeBrowser):
58+
def make_command(self):
59+
return [self.webdriver_binary,
60+
cmd_arg("port", str(self.port)),
61+
cmd_arg("url-base", self.base_path),
62+
cmd_arg("enable-chrome-logs")] + self.webdriver_args

0 commit comments

Comments
 (0)