Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 1 | # Running Web Platform Tests with run_wpt_tests.py |
| 2 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 3 | `run_web_tests.py` runs web tests with content shell through [protocol mode]. |
| 4 | See [web_tests.md](web_tests.md) for details. |
| 5 | `run_wpt_tests.py` is a WebDriver-based alternative that can run [web platform |
| 6 | tests] with [Chrome], [headless shell], Chrome Android, and WebView. |
| 7 | This 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 Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 12 | |
| 13 | [TOC] |
| 14 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 15 | ## Running Web Platform Tests for Desktop Platforms |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 16 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 17 | On Linux, macOS, and Windows, `run_wpt_tests.py` supports testing with [Chrome] |
| 18 | or [headless shell]. |
| 19 | Chrome is closer to the binary Google ships to end users, but is generally |
| 20 | slower. |
| 21 | Headless shell is a lightweight alternative that suffices for testing features |
| 22 | implemented entirely in Blink. |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 23 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 24 | ### Running Tests Locally |
| 25 | |
Weizhong Xia | 0895abfa | 2025-01-08 23:55:38 | [diff] [blame] | 26 | First, you will need to build the `blink_tests` target as you were running web tests |
| 27 | before. This will build `headless_shell`, `chrome`, `chromedriver`, `content_shell` |
| 28 | and all other needed binaries to run web tests and WPTs. |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 29 | |
| 30 | ```bash |
Weizhong Xia | 0895abfa | 2025-01-08 23:55:38 | [diff] [blame] | 31 | autoninja -C out/Default blink_tests |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 32 | ``` |
| 33 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 34 | Once the build is done, running tests is very similar to how you would run |
| 35 | tests with `run_web_tests.py`. |
| 36 | For example, to run all tests under `external/wpt/html/dom`, run: |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 37 | |
| 38 | ```bash |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 39 | third_party/blink/tools/run_wpt_tests.py --target=Default --product=headless_shell external/wpt/html/dom |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 40 | ``` |
| 41 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 42 | `--product` (or `-p`) selects which browser to test with. |
| 43 | Supported values are: |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 44 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 45 | * `headless_shell` (default if `--product` is not specified) |
| 46 | * `chrome` |
| 47 | * `chrome_android` (aliased as `clank`; see |
An Sung | e607bc4 | 2024-10-03 20:56:42 | [diff] [blame] | 48 | [additional instructions](#Running-Web-Platform-Tests-on-Android)) |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 49 | * `android_webview` (aliased as `webview`; see |
An Sung | e607bc4 | 2024-10-03 20:56:42 | [diff] [blame] | 50 | [additional instructions](#Running-Web-Platform-Tests-on-Android)) |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 51 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 52 | Also, consider using `-v` to get browser logs. |
| 53 | It can be provided multiple times to increase verbosity. |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 54 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 55 | `run_wpt_tests.py --help` shows a full description of `run_wpt_tests.py`'s CLI, |
| 56 | which resembles that of `run_web_tests.py`. |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 57 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 58 | ### Running Tests in CQ/CI |
| 59 | |
| 60 | To satisfy different testing requirements, WPT coverage in CQ/CI is partitioned |
| 61 | between suites that target different `//content` embedders: |
| 62 | |
| 63 | Suite Name | Browser Under Test | Harness | Tests Run |
| 64 | --- | --- | --- | --- |
Weizhong Xia | 8957745 | 2025-01-10 04:14:36 | [diff] [blame] | 65 | `headless_shell_wpt_tests` | `headless_shell` | `run_wpt_tests.py` | The default test suite for WPTs if not specified otherwise. |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 66 | `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 Xia | 8957745 | 2025-01-10 04:14:36 | [diff] [blame] | 67 | `blink_wpt_tests` | `content_shell --run-web-tests` | `run_web_tests.py` | Tests under [internal WPTs] plus any public WPTs not migrated yet. |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 68 | |
| 69 | To avoid redundant coverage, each WPT should run in exactly one suite listed |
| 70 | above. |
| 71 | The [`chrome.filter`][1] file lists tests that `chrome_wpt_tests` should run, |
| 72 | and that `headless_shell_wpt_tests` and `blink_wpt_tests` should skip. |
Weizhong Xia | 8957745 | 2025-01-10 04:14:36 | [diff] [blame] | 73 | [`content_shell.filter`][2] file lists tests that currently run in `blink_wpt_tests`, |
| 74 | and will be removed once it only contains tests under `wpt_internal`. Tests |
| 75 | not listed in either file run in `headless_shell_wpt_tests` by default. |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 76 | |
| 77 | *** note |
| 78 | Running tests in `blink_wpt_tests` is discouraged because `run_web_tests.py` |
| 79 | doesn't drive tests through standard WebDriver endpoints. |
| 80 | This can cause `blink_wpt_tests` results to diverge from the Chrome results |
Weizhong Xia | 8957745 | 2025-01-10 04:14:36 | [diff] [blame] | 81 | published to [wpt.fyi]. We should generally not add new tests to |
| 82 | content_shell.filter. |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 83 | *** |
| 84 | |
| 85 | [internal WPTs]: /third_party/blink/web_tests/wpt_internal |
| 86 | |
| 87 | ### Test Expectations and Baselines |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 88 | |
Jonathan Lee | 27f7f19c | 2024-08-08 17:09:56 | [diff] [blame] | 89 | To suppress failures, `run_wpt_tests.py` uses the [same `*-expected.txt` and |
| 90 | TestExpectations files](web_test_expectations.md) that `run_web_tests.py` uses. |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 91 | |
Weizhong Xia | c326c31 | 2023-11-02 22:10:42 | [diff] [blame] | 92 | ### Running webdriver tests with Chrome |
| 93 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 94 | [wdspec tests] are a subset of WPT that verifies conformance to the WebDriver |
| 95 | specification. |
| 96 | `run_wpt_tests.py` can run wdspec tests like any other WPT: |
Weizhong Xia | c326c31 | 2023-11-02 22:10:42 | [diff] [blame] | 97 | |
| 98 | ```bash |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 99 | third_party/blink/tools/run_wpt_tests.py -t Default -p chrome \ |
| 100 | external/wpt/webdriver/tests/classic/find_element/find.py |
Weizhong Xia | c326c31 | 2023-11-02 22:10:42 | [diff] [blame] | 101 | ``` |
| 102 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 103 | On the bots, the `webdriver_wpt_tests` suite runs wdspec tests separately from |
| 104 | the other WPT types. |
| 105 | The `linux-blink-rel` builder can provide results for rebaselining. |
| 106 | |
| 107 | [wdspec tests]: https://web-platform-tests.org/writing-tests/wdspec.html |
Weizhong Xia | c326c31 | 2023-11-02 22:10:42 | [diff] [blame] | 108 | |
An Sung | e607bc4 | 2024-10-03 20:56:42 | [diff] [blame] | 109 | ## Running Web Platform Tests on Android |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 110 | |
An Sung | e607bc4 | 2024-10-03 20:56:42 | [diff] [blame] | 111 | See [here](./run_web_platform_tests_on_android.md) for Android specific instructions. |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 112 | |
| 113 | ## Debugging Support |
| 114 | |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 115 | ### Text-Based Debuggers |
| 116 | |
| 117 | To 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 | |
| 120 | For other use cases, see [these debugging tips]. |
| 121 | |
| 122 | [these debugging tips]: /docs/linux/debugging.md |
| 123 | |
Jonathan Lee | 2763d20852 | 2024-09-11 16:21:23 | [diff] [blame] | 124 | ## 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 Byers | f5c5878e | 2024-11-08 23:10:01 | [diff] [blame] | 130 | 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 Lee | 2763d20852 | 2024-09-11 16:21:23 | [diff] [blame] | 134 | See https://github.com/web-platform-tests/rfcs/issues/172 for additional |
| 135 | discussion. |
| 136 | |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 137 | ## Known Issues |
| 138 | |
Jonathan Lee | 2763d20852 | 2024-09-11 16:21:23 | [diff] [blame] | 139 | The [`wptrunner-migration` |
| 140 | hostlist](https://issues.chromium.org/hotlists/6224346) tracks test results |
| 141 | where headless shell and content shell differ. |
| 142 | For runner bugs and feature requests, please file [an issue against |
| 143 | `Blink>Infra`](https://issues.chromium.org/issues/new?component=1456928&template=1923166). |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 144 | |
| 145 | [protocol mode]: /content/web_test/browser/test_info_extractor.h |
| 146 | [debug renderer]: /third_party/blink/tools/debug_renderer |
Jonathan Lee | 9b39e42 | 2024-01-26 06:39:40 | [diff] [blame] | 147 | [wpt.fyi]: https://wpt.fyi/results/?label=experimental&label=master&aligned |
| 148 | |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 149 | [1]: /third_party/blink/web_tests/TestLists/chrome.filter |
Weizhong Xia | 8957745 | 2025-01-10 04:14:36 | [diff] [blame] | 150 | [2]: /third_party/blink/web_tests/TestLists/content_shell.filter |
Jonathan Lee | 748f903 | 2024-08-28 19:07:34 | [diff] [blame] | 151 | [3]: writing_web_tests.md#Relying-on-Blink_Specific-Testing-APIs |