Skip to content

Commit 0ac912c

Browse files
authored
wpt: Properly process the --headless argument (servo#40289)
Instead of ignoring the `--headless` argument to the WPT test runner, properly use it to turno on headless mode in Servo when its provided. Additionally, when more than a single test is run, turn on headless mode automatically to preserve existing behavior. Although this change is for the legacy test driver, this will allow the WebDriver test runner to run properly without providing the `--headless` argument. Testing: This modifies the way the test harness works, but the test harness is untested. Signed-off-by: Martin Robinson <[email protected]>
1 parent 2111a12 commit 0ac912c

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

python/wpt/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def run_tests(default_binary_path: str, **kwargs: Any) -> int:
110110
file_ext = os.path.splitext(kwargs["test_list"][0])[1].lower()
111111
if file_ext in [".htm", ".html", ".js", ".xhtml", ".xht", ".py"]:
112112
use_mach_logging = True
113+
else:
114+
kwargs["headless"] = True
113115

114116
if use_mach_logging:
115117
logger = wptrunner.setup_logging(kwargs, {"mach": sys.stdout})

tests/wpt/meta/MANIFEST.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533229,7 +533229,7 @@
533229533229
]
533230533230
},
533231533231
"servo.py": [
533232-
"2928ffb7f1d483cff60dd17ffd92a53c9b1c3148",
533232+
"b8cfd54ef61e5cdde9bef4e3673e508759adc566",
533233533233
[]
533234533234
],
533235533235
"servodriver.py": [
@@ -533295,7 +533295,7 @@
533295533295
[]
533296533296
],
533297533297
"executorservo.py": [
533298-
"d983cf048ed6dfe1c07fdcac4f3465f116a00c58",
533298+
"9571b4d6e379ff08aefd2025c42245c6819ac50a",
533299533299
[]
533300533300
],
533301533301
"executorservodriver.py": [

tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def executor_kwargs(logger, test_type, test_environment, run_info_data,
5151
**kwargs):
5252
rv = base_executor_kwargs(test_type, test_environment, run_info_data, **kwargs)
5353
rv["pause_after_test"] = kwargs["pause_after_test"]
54+
rv["headless"] = kwargs.get("headless", False)
5455
if test_type == "wdspec":
5556
rv["capabilities"] = {}
5657
return rv

tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929

3030
class ServoExecutor(ProcessTestExecutor):
31-
def __init__(self, logger, browser, server_config, timeout_multiplier, debug_info,
31+
def __init__(self, logger, browser, server_config, headless: bool,
32+
timeout_multiplier, debug_info,
3233
pause_after_test, reftest_screenshot="unexpected"):
3334
ProcessTestExecutor.__init__(self, logger, browser, server_config,
3435
timeout_multiplier=timeout_multiplier,
@@ -37,6 +38,7 @@ def __init__(self, logger, browser, server_config, timeout_multiplier, debug_inf
3738
self.pause_after_test = pause_after_test
3839
self.environment = {}
3940
self.protocol = ConnectionlessProtocol(self, browser)
41+
self.headless = headless
4042

4143
self.wpt_prefs_path = self.find_wpt_prefs()
4244

@@ -87,8 +89,10 @@ def build_servo_command(self, test, extra_args=None):
8789
# For some reason rustls does not like the certificate generated by the WPT tooling.
8890
"--ignore-certificate-errors",
8991
"--enable-experimental-web-platform-features",
90-
"-z", self.test_url(test),
92+
self.test_url(test),
9193
]
94+
if self.headless:
95+
args += ["-z"]
9296
for stylesheet in self.browser.user_stylesheets:
9397
args += ["--user-stylesheet", stylesheet]
9498
for pref, value in self.environment.get('prefs', {}).items():
@@ -100,17 +104,16 @@ def build_servo_command(self, test, extra_args=None):
100104
args += extra_args
101105
args += self.browser.binary_args
102106
debug_args, command = browser_command(self.binary, args, self.debug_info)
103-
if self.pause_after_test:
104-
command.remove("-z")
105107
return debug_args + command
106108

107109

108110
class ServoTestharnessExecutor(ServoExecutor):
109111
convert_result = testharness_result_converter
110112

111-
def __init__(self, logger, browser, server_config, timeout_multiplier=1, debug_info=None,
113+
def __init__(self, logger, browser, server_config, headless,
114+
timeout_multiplier=1, debug_info=None,
112115
pause_after_test=False, **kwargs):
113-
ServoExecutor.__init__(self, logger, browser, server_config,
116+
ServoExecutor.__init__(self, logger, browser, server_config, headless,
114117
timeout_multiplier=timeout_multiplier,
115118
debug_info=debug_info,
116119
pause_after_test=pause_after_test)
@@ -211,6 +214,7 @@ def __init__(self, logger, browser, server_config, binary=None, timeout_multipli
211214
logger,
212215
browser,
213216
server_config,
217+
headless=True,
214218
timeout_multiplier=timeout_multiplier,
215219
debug_info=debug_info,
216220
reftest_screenshot=reftest_screenshot,
@@ -300,13 +304,14 @@ def set_timeout(self):
300304
class ServoCrashtestExecutor(ServoExecutor):
301305
convert_result = crashtest_result_converter
302306

303-
def __init__(self, logger, browser, server_config, binary=None, timeout_multiplier=1,
304-
screenshot_cache=None, debug_info=None, pause_after_test=False,
305-
**kwargs):
307+
def __init__(self, logger, browser, server_config, headless,
308+
binary=None, timeout_multiplier=1, screenshot_cache=None,
309+
debug_info=None, pause_after_test=False):
306310
ServoExecutor.__init__(self,
307311
logger,
308312
browser,
309313
server_config,
314+
headless,
310315
timeout_multiplier=timeout_multiplier,
311316
debug_info=debug_info,
312317
pause_after_test=pause_after_test)

0 commit comments

Comments
 (0)