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 <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-10-01 15:25:07 +02:00 committed by GitHub
parent cfa9e711c5
commit e49fcdeffd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -529727,7 +529727,7 @@
[]
],
"servodriver.py": [
"c25aa9b3ecdcfe20c6ff0e8f98973d69c86d5209",
"a4bf5e7cd75bbcabce532930ee97bfd506e06fc4",
[]
],
"webkit.py": [

View file

@ -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