blob: e1e09351a1c0484bb63def1860f767a8610c9f87 [file] [log] [blame] [view]
Weizhong Xiabe863d722023-11-01 22:36:151# Running Web Platform Tests with run_wpt_tests.py
2
Jonathan Lee748f9032024-08-28 19:07:343`run_web_tests.py` runs web tests with content shell through [protocol mode].
4See [web_tests.md](web_tests.md) for details.
5`run_wpt_tests.py` is a WebDriver-based alternative that can run [web platform
6tests] with [Chrome], [headless shell], Chrome Android, and WebView.
7This document explains how to use `run_wpt_tests.py` in these scenarios.
8
9[web platform tests]: web_platform_tests.md
10[Chrome]: /chrome
11[headless shell]: /headless
Weizhong Xiabe863d722023-11-01 22:36:1512
13[TOC]
14
Jonathan Lee748f9032024-08-28 19:07:3415## Running Web Platform Tests for Desktop Platforms
Weizhong Xiabe863d722023-11-01 22:36:1516
Jonathan Lee748f9032024-08-28 19:07:3417On Linux, macOS, and Windows, `run_wpt_tests.py` supports testing with [Chrome]
18or [headless shell].
19Chrome is closer to the binary Google ships to end users, but is generally
20slower.
21Headless shell is a lightweight alternative that suffices for testing features
22implemented entirely in Blink.
Weizhong Xiabe863d722023-11-01 22:36:1523
Jonathan Lee748f9032024-08-28 19:07:3424### Running Tests Locally
25
Weizhong Xia0895abfa2025-01-08 23:55:3826First, you will need to build the `blink_tests` target as you were running web tests
27before. This will build `headless_shell`, `chrome`, `chromedriver`, `content_shell`
28and all other needed binaries to run web tests and WPTs.
Weizhong Xiabe863d722023-11-01 22:36:1529
30```bash
Weizhong Xia0895abfa2025-01-08 23:55:3831autoninja -C out/Default blink_tests
Weizhong Xiabe863d722023-11-01 22:36:1532```
33
Jonathan Lee748f9032024-08-28 19:07:3434Once the build is done, running tests is very similar to how you would run
35tests with `run_web_tests.py`.
36For example, to run all tests under `external/wpt/html/dom`, run:
Weizhong Xiabe863d722023-11-01 22:36:1537
38```bash
Jonathan Lee748f9032024-08-28 19:07:3439third_party/blink/tools/run_wpt_tests.py --target=Default --product=headless_shell external/wpt/html/dom
Weizhong Xiabe863d722023-11-01 22:36:1540```
41
Jonathan Lee748f9032024-08-28 19:07:3442`--product` (or `-p`) selects which browser to test with.
43Supported values are:
Weizhong Xiabe863d722023-11-01 22:36:1544
Jonathan Lee748f9032024-08-28 19:07:3445* `headless_shell` (default if `--product` is not specified)
46* `chrome`
47* `chrome_android` (aliased as `clank`; see
An Sunge607bc42024-10-03 20:56:4248 [additional instructions](#Running-Web-Platform-Tests-on-Android))
Jonathan Lee748f9032024-08-28 19:07:3449* `android_webview` (aliased as `webview`; see
An Sunge607bc42024-10-03 20:56:4250 [additional instructions](#Running-Web-Platform-Tests-on-Android))
Weizhong Xiabe863d722023-11-01 22:36:1551
Jonathan Lee748f9032024-08-28 19:07:3452Also, consider using `-v` to get browser logs.
53It can be provided multiple times to increase verbosity.
Weizhong Xiabe863d722023-11-01 22:36:1554
Jonathan Lee748f9032024-08-28 19:07:3455`run_wpt_tests.py --help` shows a full description of `run_wpt_tests.py`'s CLI,
56which resembles that of `run_web_tests.py`.
Weizhong Xiabe863d722023-11-01 22:36:1557
Jonathan Lee748f9032024-08-28 19:07:3458### Running Tests in CQ/CI
59
60To satisfy different testing requirements, WPT coverage in CQ/CI is partitioned
61between suites that target different `//content` embedders:
62
63Suite Name | Browser Under Test | Harness | Tests Run
64--- | --- | --- | ---
Weizhong Xia89577452025-01-10 04:14:3665`headless_shell_wpt_tests` | `headless_shell` | `run_wpt_tests.py` | The default test suite for WPTs if not specified otherwise.
Jonathan Lee748f9032024-08-28 19:07:3466`chrome_wpt_tests` | `chrome --headless=new` | `run_wpt_tests.py` | Tests that depend on the `//chrome` layer. Can be slow, so prefer `headless_shell` testing if possible.
Weizhong Xia89577452025-01-10 04:14:3667`blink_wpt_tests` | `content_shell --run-web-tests` | `run_web_tests.py` | Tests under [internal WPTs] plus any public WPTs not migrated yet.
Jonathan Lee748f9032024-08-28 19:07:3468
69To avoid redundant coverage, each WPT should run in exactly one suite listed
70above.
71The [`chrome.filter`][1] file lists tests that `chrome_wpt_tests` should run,
72and that `headless_shell_wpt_tests` and `blink_wpt_tests` should skip.
Weizhong Xia89577452025-01-10 04:14:3673[`content_shell.filter`][2] file lists tests that currently run in `blink_wpt_tests`,
74and will be removed once it only contains tests under `wpt_internal`. Tests
75not listed in either file run in `headless_shell_wpt_tests` by default.
Jonathan Lee748f9032024-08-28 19:07:3476
77*** note
78Running tests in `blink_wpt_tests` is discouraged because `run_web_tests.py`
79doesn't drive tests through standard WebDriver endpoints.
80This can cause `blink_wpt_tests` results to diverge from the Chrome results
Weizhong Xia89577452025-01-10 04:14:3681published to [wpt.fyi]. We should generally not add new tests to
82content_shell.filter.
Jonathan Lee748f9032024-08-28 19:07:3483***
84
85[internal WPTs]: /third_party/blink/web_tests/wpt_internal
86
87### Test Expectations and Baselines
Weizhong Xiabe863d722023-11-01 22:36:1588
Jonathan Lee27f7f19c2024-08-08 17:09:5689To suppress failures, `run_wpt_tests.py` uses the [same `*-expected.txt` and
90TestExpectations files](web_test_expectations.md) that `run_web_tests.py` uses.
Weizhong Xiabe863d722023-11-01 22:36:1591
Weizhong Xiac326c312023-11-02 22:10:4292### Running webdriver tests with Chrome
93
Jonathan Lee748f9032024-08-28 19:07:3494[wdspec tests] are a subset of WPT that verifies conformance to the WebDriver
95specification.
96`run_wpt_tests.py` can run wdspec tests like any other WPT:
Weizhong Xiac326c312023-11-02 22:10:4297
98```bash
Jonathan Lee748f9032024-08-28 19:07:3499third_party/blink/tools/run_wpt_tests.py -t Default -p chrome \
100 external/wpt/webdriver/tests/classic/find_element/find.py
Weizhong Xiac326c312023-11-02 22:10:42101```
102
Jonathan Lee748f9032024-08-28 19:07:34103On the bots, the `webdriver_wpt_tests` suite runs wdspec tests separately from
104the other WPT types.
105The `linux-blink-rel` builder can provide results for rebaselining.
106
107[wdspec tests]: https://web-platform-tests.org/writing-tests/wdspec.html
Weizhong Xiac326c312023-11-02 22:10:42108
An Sunge607bc42024-10-03 20:56:42109## Running Web Platform Tests on Android
Weizhong Xiabe863d722023-11-01 22:36:15110
An Sunge607bc42024-10-03 20:56:42111See [here](./run_web_platform_tests_on_android.md) for Android specific instructions.
Weizhong Xiabe863d722023-11-01 22:36:15112
113## Debugging Support
114
Weizhong Xiabe863d722023-11-01 22:36:15115### Text-Based Debuggers
116
117To interactively debug WPTs, prefix the `run_wpt_tests.py` command with
118[`debug_renderer`][debug renderer] to attach a debugger to a desired renderer.
119
120For other use cases, see [these debugging tips].
121
122[these debugging tips]: /docs/linux/debugging.md
123
Jonathan Lee2763d208522024-09-11 16:21:23124## FAQ
125
126* Do headless shell and Chrome support MojoJS bindings?
127 * Yes.
128 `run_wpt_tests.py` enables the `MojoJS` and `MojoJSTest` features and
129 serves `//out/<target>/gen/` as `/gen/` in wptserve.
Rick Byersf5c5878e2024-11-08 23:10:01130 However, in the public WPT suite, testdriver.js APIs must be backed by
131 fully-specified testing APIs (preferably implemented with WebDriver or
132 alternatively with MojoJS). Tests that rely on unspecified testing APIs
133 cannot be put in WPT, but may live in chromium's own wpt_internal.
Jonathan Lee2763d208522024-09-11 16:21:23134 See https://github.com/web-platform-tests/rfcs/issues/172 for additional
135 discussion.
136
Weizhong Xiabe863d722023-11-01 22:36:15137## Known Issues
138
Jonathan Lee2763d208522024-09-11 16:21:23139The [`wptrunner-migration`
140hostlist](https://issues.chromium.org/hotlists/6224346) tracks test results
141where headless shell and content shell differ.
142For runner bugs and feature requests, please file [an issue against
143`Blink>Infra`](https://issues.chromium.org/issues/new?component=1456928&template=1923166).
Weizhong Xiabe863d722023-11-01 22:36:15144
145[protocol mode]: /content/web_test/browser/test_info_extractor.h
146[debug renderer]: /third_party/blink/tools/debug_renderer
Jonathan Lee9b39e422024-01-26 06:39:40147[wpt.fyi]: https://wpt.fyi/results/?label=experimental&label=master&aligned
148
Jonathan Lee748f9032024-08-28 19:07:34149[1]: /third_party/blink/web_tests/TestLists/chrome.filter
Weizhong Xia89577452025-01-10 04:14:36150[2]: /third_party/blink/web_tests/TestLists/content_shell.filter
Jonathan Lee748f9032024-08-28 19:07:34151[3]: writing_web_tests.md#Relying-on-Blink_Specific-Testing-APIs