Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame^] | 1 | # Running Web Platform Tests with run_wpt_tests.py |
| 2 | |
| 3 | `run_web_tests.py` runs web tests with content shell through [protocol mode]. See |
| 4 | [web_tests.md](./web_tests.md) for details. `run_wpt_tests.py` instead can run web |
| 5 | platform tests with Chrome, Chrome Android and WebView. This document explains how |
| 6 | to use `run_wpt_tests.py` in these scenarios. |
| 7 | |
| 8 | [TOC] |
| 9 | |
| 10 | ## Difference and Similarity with run_web_tests.py |
| 11 | |
| 12 | `run_wpt_tests.py` can run with different browsers. To specify which browser to |
| 13 | run tests with, you should use `--product` or `-p`. Supported parameters are `chrome`, |
| 14 | `chrome_android` (or `clank`), and `android_webview` (or `webview`). The default |
| 15 | value is `chrome` if not specified. |
| 16 | |
| 17 | The CLI is mostly kept the same between run_web_tests.py and run_wpt_tests.py. To |
| 18 | see a complete list of arguments supported in run_wpt_tests.py, run: |
| 19 | |
| 20 | ```bash |
| 21 | third_party/blink/tools/run_wpt_tests.py --help |
| 22 | ``` |
| 23 | |
| 24 | ## Running Web Platform Tests with Chrome |
| 25 | |
| 26 | ### Supported Platforms |
| 27 | |
| 28 | * Linux |
| 29 | |
| 30 | It is possible to run tests for Chrome on other platforms, but test expectations |
| 31 | and baselines are only actively maintained for Linux due to resource constraint. |
| 32 | |
| 33 | ### Initial Setup |
| 34 | |
| 35 | Before you can run the web platform tests, you need to build the `chrome_wpt_tests` |
| 36 | target to get `chrome`, `chromedriver` and all of the other needed binaries. |
| 37 | |
| 38 | ```bash |
| 39 | autoninja -C out/Default chrome_wpt_tests |
| 40 | ``` |
| 41 | |
| 42 | ### Running the Tests |
| 43 | |
| 44 | Once you have `chrome` and `chromedriver` built, running tests is very much similar |
| 45 | to how you run tests with `run_web_tests.py`. For example, to run tests in `external/wpt/html/dom`, |
| 46 | you should run: |
| 47 | |
| 48 | ```bash |
| 49 | third_party/blink/tools/run_wpt_tests.py --release -p chrome third_party/blink/web_tests/external/wpt/html/dom |
| 50 | ``` |
| 51 | |
| 52 | Note: consider using `-v` to get browser logs. It can be provided multiple times to |
| 53 | increase verbosity. |
| 54 | |
| 55 | ### Test expectations and Baselines |
| 56 | |
| 57 | The |
| 58 | [TestExpectations](../../third_party/blink/web_tests/TestExpectations) file (and related |
| 59 | files) contains the list of all known web test failures. A special tag `Chrome` is |
| 60 | introduced to specify chrome specific failures. See the |
| 61 | [Web Test Expectations documentation](./web_test_expectations.md) for more |
| 62 | on this. |
| 63 | |
| 64 | Chrome specific baselines reside at `third_party/blink/web_tests/platform/linux-chrome`, and |
| 65 | falls back to `third_party/blink/web_tests/platform/linux`. To update baselines for chrome, |
| 66 | you should trigger `linux-wpt-fyi-rel` and run [rebaseline tool](./web_test_expectations.md#How-to-rebaseline) after the results are ready. |
| 67 | |
| 68 | ## Running Web Platform Tests with Chrome Android |
| 69 | |
| 70 | To be updated. |
| 71 | |
| 72 | ## Running Web Platform Tests with WebView |
| 73 | |
| 74 | To be updated. |
| 75 | |
| 76 | ## Debugging Support |
| 77 | |
| 78 | ### Headful Mode |
| 79 | |
| 80 | Passing the `--no-headless` flag to `run_wpt_tests.py` will pause execution |
| 81 | after running each test headfully. |
| 82 | You can interact with the paused test page afterwards, including with DevTools: |
| 83 | |
| 84 |  |
| 85 | |
| 86 | Closing the tab or window will unpause the testharness and run the next test. |
| 87 | |
| 88 | ### Text-Based Debuggers |
| 89 | |
| 90 | To interactively debug WPTs, prefix the `run_wpt_tests.py` command with |
| 91 | [`debug_renderer`][debug renderer] to attach a debugger to a desired renderer. |
| 92 | |
| 93 | For other use cases, see [these debugging tips]. |
| 94 | |
| 95 | [these debugging tips]: /docs/linux/debugging.md |
| 96 | |
| 97 | ## Known Issues |
| 98 | |
| 99 | Please [file bugs and feature requests](https://crbug.com/new) against |
| 100 | [`Blink>Infra` with the `wptrunner` |
| 101 | label](https://bugs.chromium.org/p/chromium/issues/list?q=component%3ABlink%3EInfra%20label%3Awptrunner&can=2). |
| 102 | |
| 103 | [protocol mode]: /content/web_test/browser/test_info_extractor.h |
| 104 | [debug renderer]: /third_party/blink/tools/debug_renderer |