From e49fcdeffd67f9b800f97ab7be155eb73ffe0868 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 1 Oct 2025 15:25:07 +0200 Subject: [PATCH] servodriver: Use the `wpt-prefs.json` file when running servoshell (#39605) These preferences are necessary in order for tests to run properly in servodriver. Testing: This causes more tests to pass when WPT is run with `--product servodriver` Signed-off-by: Martin Robinson --- tests/wpt/meta/MANIFEST.json | 2 +- .../wptrunner/browsers/servodriver.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 9567c9094e7..188ee94a68e 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -529727,7 +529727,7 @@ [] ], "servodriver.py": [ - "c25aa9b3ecdcfe20c6ff0e8f98973d69c86d5209", + "a4bf5e7cd75bbcabce532930ee97bfd506e06fc4", [] ], "webkit.py": [ diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py b/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py index c25aa9b3ecd..a4bf5e7cd75 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py @@ -113,9 +113,13 @@ class ServoWebDriverBrowser(WebDriverBrowser): if headless: args += ["--headless"] + # Add the shared `wpt-prefs.json` file to the list of arguments. + args += ["--prefs-file", self.find_wpt_prefs(logger)] + super().__init__(logger, binary=binary, webdriver_binary=binary, webdriver_args=args, host=webdriver_host, env=env, supports_pac=False, **kwargs) + self.hosts_path = hosts_path def make_command(self): @@ -124,3 +128,17 @@ class ServoWebDriverBrowser(WebDriverBrowser): def cleanup(self): super().cleanup() os.remove(self.hosts_path) + + def find_wpt_prefs(self, logger): + default_path = os.path.join("resources", "wpt-prefs.json") + # The cwd is the servo repo for `./mach test-wpt`, but on WPT runners + # it is the WPT repo. The nightly tar is extracted inside the Python + # virtual environment within the repo. This means that on WPT runners, + # the cwd has the `_venv3/servo` directory inside which we find the + # binary and the 'resources' directory. + for dir in [".", "./_venv3/servo"]: + candidate = os.path.abspath(os.path.join(dir, default_path)) + if os.path.isfile(candidate): + return candidate + logger.error("Unable to find wpt-prefs.json") + return default_path