Skip to content

Conversation

@gsnedders
Copy link
Member

The goal here is for browser classes to be able to have the ability to get at data items specific to the current thread (e.g., with --processes=X, each of the X concurrently existing Browser objects should be able to get their own kwargs).

This avoids needing to hardcode specific browser settings in wptrunner.testrunner, which is a layering violation.

Adding a required argument to wptrunner.browsers.base.Browser obviously carries a risk, as shown by the number of browsers which needed modified to correctly pass through unknown keyword arguments to their parents, but I don't think there's a reasonable alternative to doing this.

The only other real alternative would be to add manager_number as an argument to get_browser_kwargs and get_executor_kwargs, and turn them into partials, and evaluate them close to when we actually need them — when we would actually know what thread we're running in, and can thus supply that data to the getter functions in general.

The biggest risk here is probably with wptrunner.browsers.chrome_android.ChromeAndroidBrowserBase and its subclasses, because that's neither tested in CI nor do I have an easy way to test that locally.

@wpt-pr-bot wpt-pr-bot added infra wptrunner The automated test runner, commonly called through ./wpt run labels May 10, 2025
@gsnedders gsnedders requested a review from jonathan-j-lee May 10, 2025 02:10
@gsnedders
Copy link
Member Author

…and I managed to break the tests while tidying this up to post as a PR, and clearly forgot to run them. Doh.

Copy link
Contributor

@jonathan-j-lee jonathan-j-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is at least an improvement.

To make this patch work for Chromium on Android, please apply jonathan-j-lee/wpt@44a7818, which I've tested downstream. Thanks!

disable_fission=False, stackfix_dir=None, leak_check=False,
asan=False, chaos_mode_flags=None, config=None,
browser_channel="nightly", headless=None, debug_test=None,
binary=None, package_name="org.mozilla.geckoview.test_runner", device_serial=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I take it we can remove the package_name="org.mozilla.geckoview.test_runner" default because it had no effect in practice? i.e., browser_kwargs always plumbs in wpt run --package-name, defaulting to None.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was gonna say Mozilla's own CI uses wptrunner as a library in its own right, not via wpt run.

But we invoke browser_kwargs itself, so maybe that's pointless.

@gsnedders
Copy link
Member Author

The TC infrastructure/ tests failure is #52502. This does mean that we have no test coverage of Firefox Android on this PR.

@jgraham do you want to test this manually, or can you please fix your regression (or I can revert your change)?

@jgraham jgraham closed this May 16, 2025
@jgraham jgraham reopened this May 16, 2025
Copy link
Contributor

@jgraham jgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying change here seems good.

I don't love using **kwargs in more places; it makes it harder to add types in the future (see also the use of **kwargs: Any in this patch), and also makes it less clear which arguments are actually required for the browser classes to work as expected, and affects the ability of tooling like LSPs to help by providing the function signature.

@gsnedders
Copy link
Member Author

gsnedders commented May 20, 2025

IMO, the broader problems about passing arguments to superclasses is a general problem with typing in Python, and explicitly listing what you believe to be all superclass arguments is endlessly fragile. There's no good solution, and it really need to be sorting at the Python typing level…

@gsnedders
Copy link
Member Author

Adding more logging shows firefox_android failing with:

WARNING Browser.__init__ kwargs: {'webdriver_binary': '/home/test/web-platform-tests/_venv3/bin/geckodriver', 'webdriver_args': [], 'binary': None, 'env_extras': {}}

A load of these only apply to FirefoxAndroidWdSpecBrowser, not FirefoxAndroidBrowser.

@gsnedders gsnedders force-pushed the manager_number branch 3 times, most recently from 79e65a0 to c6f4755 Compare May 20, 2025 21:18
The goal here is for browser classes to be able to have the ability to
get at data items specific to the current thread (e.g., with
--processes=X, each of the X concurrently existing Browser objects
should be able to get their own kwargs).

This avoids needing to hardcode specific browser settings in
wptrunner.testrunner, which is a layering violation.

Adding a required argument to wptrunner.browsers.base.Browser
obviously carries a risk, as shown by the number of browsers which
needed modified to correctly pass through unknown keyword arguments to
their parents, but I don't think there's a reasonable alternative to
doing this.

Co-authored-by: Jonathan Lee <jonathanjlee@google.com>
@gsnedders gsnedders merged commit 4e4d767 into web-platform-tests:master May 20, 2025
34 checks passed
@gsnedders gsnedders deleted the manager_number branch May 20, 2025 23:10
jonathan-j-lee added a commit to jonathan-j-lee/wpt that referenced this pull request May 30, 2025
1. The default subsuite is the empty string, which, when logged, looks
   incomplete (e.g., `INFO Restarting browser for new subsuite:`).
   Format with `repr()` to add quotation marks.
2. Don't pass `debug_info` as a `HeadlessShellBrowser` kwarg. It gets
   logged as `WARNING Browser.__init__ kwargs: {'debug_info': None}`
   because it's unused (see web-platform-tests#52455).
jonathan-j-lee added a commit to jonathan-j-lee/wpt that referenced this pull request May 30, 2025
... by using the `chrome` browser kwargs (the browser implementations
happen to be identical at this time). This also fixes an unused
`debug_info` kwarg, which after web-platform-tests#52455, gets logged as:

```
WARNING Browser.__init__ kwargs: {'debug_info': None}
```
jonathan-j-lee added a commit that referenced this pull request May 31, 2025
... by using the `chrome` browser kwargs (the browser implementations
happen to be identical at this time). This also fixes an unused
`debug_info` kwarg, which after #52455, gets logged as:

```
WARNING Browser.__init__ kwargs: {'debug_info': None}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra wptrunner The automated test runner, commonly called through ./wpt run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants