Skip to content

Commit

Permalink
[wptrunner] Grant background-sync permission by default
Browse files Browse the repository at this point in the history
This is necessary for reporting API tests to work in headless shell
(i.e., `chrome --headless=old`). See https://crbug.com/338470458.
  • Loading branch information
jonathan-j-lee committed May 6, 2024
1 parent 05203cd commit 4d7801a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/wptrunner/wptrunner/executors/executorchrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,24 @@ def __init__(self, *args, reuse_window=False, **kwargs):
super().__init__(*args, **kwargs)
self.protocol.reuse_window = reuse_window

def setup(self, runner):
super().setup(runner)
# Chromium requires the `background-sync` permission for reporting APIs
# to work. Not all embedders (notably, `chrome --headless=old`) grant
# `background-sync` by default, so this CDP call ensures the permission
# is granted for all origins, in line with the background sync spec's
# recommendation [0].
#
# WebDriver's "Set Permission" command can only act on the test's
# origin, which may be too limited.
#
# [0]: https://wicg.github.io/background-sync/spec/#permission
params = {
"permission": {"name": "background-sync"},
"setting": "granted",
}
self.protocol.cdp.execute_cdp_command("Browser.setPermission", params)


class ChromeDriverPrintRefTestExecutor(ChromeDriverRefTestExecutor):
protocol_cls = ChromeDriverProtocol
Expand Down

0 comments on commit 4d7801a

Please sign in to comment.