foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 1 | # web-platform-tests |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 2 | |
rbyers | 6299b913 | 2017-02-10 18:06:57 | [diff] [blame] | 3 | Interoperability between browsers is |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 4 | [critical](https://www.chromium.org/blink/platform-predictability) to Chromium's |
| 5 | mission of improving the web. We believe that leveraging and contributing to a |
| 6 | shared test suite is one of the most important tools in achieving |
| 7 | interoperability between browsers. The [web-platform-tests |
Philip Jägenstedt | 3a3d5b8 | 2018-05-31 15:25:35 | [diff] [blame] | 8 | repository](https://github.com/web-platform-tests/wpt) is the primary shared |
Quinten Yearsley | fab627a | 2017-03-29 22:30:18 | [diff] [blame] | 9 | test suite where all browser engines are collaborating. |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 10 | |
Jeff Carpenter | abd1360 | 2017-03-29 22:49:59 | [diff] [blame] | 11 | Chromium has a 2-way import/export process with the upstream web-platform-tests |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 12 | repository, where tests are imported into |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 13 | [web_tests/external/wpt](../../third_party/blink/web_tests/external/wpt) |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 14 | and any changes to the imported tests are also exported to web-platform-tests. |
| 15 | |
Philip Jägenstedt | 3a3d5b8 | 2018-05-31 15:25:35 | [diff] [blame] | 16 | See https://web-platform-tests.org/ for general documentation on |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 17 | web-platform-tests, including tips for writing and reviewing tests. |
| 18 | |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 19 | [TOC] |
| 20 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 21 | ## Writing tests |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 22 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 23 | To contribute changes to web-platform-tests, just commit your changes directly |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 24 | to [web_tests/external/wpt](../../third_party/blink/web_tests/external/wpt) |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 25 | and the changes will be automatically upstreamed within 24 hours. |
| 26 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 27 | Changes involving adding, removing or modifying tests can all be upstreamed. |
| 28 | Any changes outside of |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 29 | [external/wpt](../../third_party/blink/web_tests/external/wpt) will not be |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 30 | upstreamed, and any changes `*-expected.txt`, `OWNERS`, and `MANIFEST.json`, |
| 31 | will also not be upstreamed. |
rbyers | 6299b913 | 2017-02-10 18:06:57 | [diff] [blame] | 32 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 33 | Running the web tests will automatically regenerate MANIFEST.json to pick up |
Jeff Carpenter | eb1ff6b | 2017-03-02 23:21:58 | [diff] [blame] | 34 | any local modifications. |
foolip | 2f19855 | 2017-02-24 16:42:35 | [diff] [blame] | 35 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 36 | Most tests are written using testharness.js, see |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 37 | [Writing Web Tests](./writing_web_tests.md) and |
| 38 | [Web Tests Tips](./web_tests_tips.md) for general guidelines. |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 39 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 40 | ### Write tests against specifications |
| 41 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 42 | Tests in web-platform-tests are expected to match behavior defined by the |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 43 | relevant specification. In other words, all assertions that a test makes |
| 44 | should be derived from a specification's normative requirements, and not go |
| 45 | beyond them. It is often necessary to change the specification to clarify what |
| 46 | is and isn't required. |
| 47 | |
Philip Jägenstedt | 8bb32fa | 2018-01-27 14:39:26 | [diff] [blame] | 48 | When implementation experience is needed to inform the specification work, |
Philip Jägenstedt | 3a3d5b8 | 2018-05-31 15:25:35 | [diff] [blame] | 49 | [tentative tests](https://web-platform-tests.org/writing-tests/file-names.html) |
Philip Jägenstedt | 8bb32fa | 2018-01-27 14:39:26 | [diff] [blame] | 50 | can be appropriate. It should be apparent in context why the test is tentative |
| 51 | and what needs to be resolved to make it non-tentative. |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 52 | |
| 53 | ### Tests that require testing APIs |
| 54 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 55 | #### `testdriver.js` |
| 56 | |
Philip Jägenstedt | 3a3d5b8 | 2018-05-31 15:25:35 | [diff] [blame] | 57 | [testdriver.js](https://web-platform-tests.org/writing-tests/testdriver.html) |
Philip Jägenstedt | 8bb32fa | 2018-01-27 14:39:26 | [diff] [blame] | 58 | provides a means to automate tests that cannot be written purely using web |
| 59 | platform APIs, similar to `internals.*` and `eventSender.*` in regular Blink |
Maksim Sadym | 8e2731f | 2025-03-11 16:14:53 | [diff] [blame] | 60 | web tests. It uses either [WebDriver Classic](https://www.w3.org/TR/webdriver/), |
| 61 | or [WebDriver BiDi](https://www.w3.org/TR/webdriver-bidi/) protocols. |
Philip Jägenstedt | 8bb32fa | 2018-01-27 14:39:26 | [diff] [blame] | 62 | |
Maksim Sadym | 8e2731f | 2025-03-11 16:14:53 | [diff] [blame] | 63 | [WPT Test Automation for Chromium](https://docs.google.com/document/d/18BpD41vyX1cFZ77CE0a_DJYlGpdvyLlx3pwXVRxUzvI/edit?usp=sharing) overview. |
| 64 | |
| 65 | The recommended way to extend `testdriver.js` is by adding extending |
| 66 | [WebDriver BiDi](https://www.w3.org/TR/webdriver-bidi/) protocol. |
| 67 | |
| 68 | ##### WebDriver BiDi Specification |
| 69 | |
| 70 | The WebDriver BiDi protocol was designed to support cross-browser testing. It is |
| 71 | extensible by design, and can be extended by a separate specification. |
| 72 | |
| 73 | ###### Example |
| 74 | |
| 75 | The [WebDriver BiDi extension module](https://www.w3.org/TR/webdriver-bidi/#protocol-modules) `permissions` is outlined in an external specification: https://www.w3.org/TR/permissions/#automation-webdriver-bidi. |
| 76 | |
| 77 | ##### WPT wdspec tests |
| 78 | |
| 79 | The specification part should be accompanied by WPT wdspec tests. These tests |
| 80 | allow for implementations to verify they implement the BiDi extension properly. |
| 81 | The process is described here: https://web-platform-tests.org/writing-tests/wdspec.html#extending-webdriver-bidi. |
| 82 | |
| 83 | ###### Example |
| 84 | |
| 85 | WPT tests for permissions.setPermission command: webdriver/tests/bidi/external/permissions/set_permission. |
| 86 | |
| 87 | ##### Implement the required endpoints in CDP |
| 88 | |
| 89 | Under the hood, Chromium is controlled by Chrome Devtools Protocol |
| 90 | (https://chromedevtools.github.io/devtools-protocol/). This means that in order |
| 91 | to implement the WebDriver BiDi commands, the corresponding commands should be |
| 92 | added to CDP. |
| 93 | |
| 94 | ##### Implement WebDriver BiDi commands using CDP |
| 95 | |
| 96 | The [BiDi-CDP Mapper](https://github.com/GoogleChromeLabs/chromium-bidi) is an |
| 97 | implementation of WebDriver BiDi in Chromium, and is used by ChromeDriver. It |
| 98 | translates WebDriver BiDi commands into Chrome DevTools Protocol (CDP) commands. |
| 99 | |
| 100 | [How to add the new commands to BiDi-CDP Mapper and roll it in ChromeDriver](https://github.com/GoogleChromeLabs/chromium-bidi#adding-new-command). |
| 101 | |
| 102 | ###### Example |
| 103 | |
| 104 | [Implement ”permissions.setPermission”](https://github.com/GoogleChromeLabs/chromium-bidi/pull/1645). |
| 105 | |
| 106 | ##### Extend `testdriver.js` |
| 107 | |
| 108 | In order to expose the new method to WPT tests, `testdriver.js` should be |
| 109 | updated with the new method. This process is described in the [“Testdriver extension tutorial”](https://web-platform-tests.org/writing-tests/testdriver-extension-tutorial.html), referred to in “WebDriver BiDi” sections. |
| 110 | |
| 111 | ###### Example |
| 112 | |
| 113 | [Add `test_driver.bidi.permissions.set_permission`](https://github.com/web-platform-tests/wpt/pull/49170). |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 114 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 115 | #### MojoJS |
| 116 | |
| 117 | Some specs may define testing APIs (e.g. |
| 118 | [WebUSB](https://wicg.github.io/webusb/test/)), which may be polyfilled with |
| 119 | internal API like [MojoJS](../../mojo/public/js/README.md). MojoJS is only |
| 120 | allowed in WPT for this purpose. Please reach out to |
Raphael Kubo da Costa | fec70fa | 2023-03-02 18:36:44 | [diff] [blame] | 121 | blink-dev@chromium.org before following the process below for adding a new |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 122 | test-only API: |
| 123 | |
Ken Rockot | 6355f09 | 2021-02-02 19:42:58 | [diff] [blame] | 124 | 1. Create a full list of `*.mojom.m.js` files that you need, including all |
| 125 | dependencies. Generated modules load dependencies recursively by default, |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 126 | so you can check the network panel of DevTools to see the full list of |
| 127 | dependencies it loads. |
Raphael Kubo da Costa | fec70fa | 2023-03-02 18:36:44 | [diff] [blame] | 128 | 2. Check [linux-archive-rel.json](../../infra/archive_config/linux-archive-rel.json) and add any |
Ken Rockot | 6355f09 | 2021-02-02 19:42:58 | [diff] [blame] | 129 | missing `*.mojom.m.js` files to the `mojojs.zip` archive. Globs are |
| 130 | supported in `filename`. Do not copy Mojom bindings into WPT. |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 131 | 3. Meanwhile in Chromium, you can create a helper for your WPT tests to do |
| 132 | browser-specific setup using |
| 133 | [test-only-api.js](../../third_party/blink/web_tests/external/wpt/resources/test-only-api.js). |
| 134 | See |
| 135 | [webxr_util.js](../../third_party/blink/web_tests/external/wpt/webxr/resources/webxr_util.js) |
| 136 | as an example. You can write tests using this helper right away, but they |
| 137 | will not work upstream (i.e. on https://wpt.fyi ) until your change in step |
| 138 | 2 is included in official channels, as `mojojs.zip` is built alongside with |
| 139 | Chrome. |
| 140 | |
| 141 | #### `wpt_automation` |
| 142 | |
| 143 | An alternative to the above options is to write manual tests that are automated |
| 144 | with scripts from |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 145 | [wpt_automation](../../third_party/blink/web_tests/external/wpt_automation). |
Quinten Yearsley | e577029f | 2017-07-06 00:21:03 | [diff] [blame] | 146 | Injection of JS in manual tests is determined by `loadAutomationScript` in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 147 | [testharnessreport.js](../../third_party/blink/web_tests/resources/testharnessreport.js). |
Quinten Yearsley | e577029f | 2017-07-06 00:21:03 | [diff] [blame] | 148 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 149 | Such tests still require case-by-case automation to run for other browser |
| 150 | engines, but are more valuable than purely manual tests. |
| 151 | |
Quinten Yearsley | e577029f | 2017-07-06 00:21:03 | [diff] [blame] | 152 | Manual tests that have no automation are still imported, but skipped in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 153 | [NeverFixTests](../../third_party/blink/web_tests/NeverFixTests); see |
Quinten Yearsley | e577029f | 2017-07-06 00:21:03 | [diff] [blame] | 154 | [issue 738489](https://crbug.com/738489). |
| 155 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 156 | ### Contribution process |
| 157 | |
| 158 | Changes made in |
| 159 | [web_tests/external/wpt](../../third_party/blink/web_tests/external/wpt) are |
| 160 | [automatically exported to GitHub](#exporting-tests). |
| 161 | |
| 162 | It's still possible to make direct pull requests to web-platform-tests, see |
| 163 | https://web-platform-tests.org/writing-tests/github-intro.html. |
| 164 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 165 | ### Adding new top-level directories |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 166 | |
| 167 | Entirely new top-level directories should generally be added upstream, since |
| 168 | that's the only way to add an OWNERS file upstream. After adding a new top-level |
| 169 | directory upstream, you should add a line for it in `W3CImportExpectations`. |
| 170 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 171 | Adding the new directory (and `W3CImportExpectations` entry) in Chromium and |
| 172 | later adding an OWNERS file upstream also works. |
| 173 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 174 | ### `wpt_internal` |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 175 | |
| 176 | It is sometimes desirable to write WPT tests that either test Chromium-specific |
| 177 | behaviors, or that cannot yet be upstreamed to WPT (e.g. because the spec is |
| 178 | very nascent). For these cases, we maintain a separate directory, |
Chris Mumford | bbe6b8e | 2021-09-09 21:06:18 | [diff] [blame] | 179 | [wpt_internal](../../third_party/blink/web_tests/wpt_internal) that runs under the |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 180 | WPT testing infrastructure (e.g. uses wptserve, etc), but which is not |
| 181 | upstreamed to WPT. |
| 182 | |
| 183 | Please see the `wpt_internal` |
sisidovski | 805efc2 | 2021-09-10 23:40:44 | [diff] [blame] | 184 | [README](../../third_party/blink/web_tests/wpt_internal/README.md) for more details. |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 185 | |
| 186 | **Note**: A significant downside of `wpt_internal` is that your tests may be |
| 187 | broken by upstream changes to the resources scripts (e.g. `testharness.js`), as |
| 188 | `wpt_internal` does not use the forked version of `testharness.js` used by all |
Robert Ma | a23460e7 | 2020-12-20 12:39:27 | [diff] [blame] | 189 | other non-`external/wpt` tests. Use of [new failure |
| 190 | notifications](#new-failure-notifications) is recommended to ensure you are |
| 191 | notified of breakages. |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 192 | |
Jeff Carpenter | 11b548b | 2017-11-03 23:05:22 | [diff] [blame] | 193 | ## Running tests |
| 194 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 195 | Same as Blink web tests, you can use |
Weizhong Xia | c994d2c7 | 2023-11-17 16:13:13 | [diff] [blame] | 196 | [`run_web_tests.py`](web_tests.md#running-the-tests) to run any WPT test. This |
| 197 | will run WPT tests in Content Shell. You can also run [`run_wpt_tests.py`](run_web_platform_tests.md) to |
| 198 | run WPT tests with Chrome. |
Jonathan Lee | 1124233e | 2023-07-24 18:20:41 | [diff] [blame] | 199 | |
Jeff Carpenter | 11b548b | 2017-11-03 23:05:22 | [diff] [blame] | 200 | One thing to note is that glob patterns for WPT tests are not yet supported. |
| 201 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 202 | See [Running WPT tests in Content Shell](web_tests_in_content_shell.md#Running-WPT-Tests-in-Content-Shell) |
| 203 | for debugging etc. |
| 204 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 205 | ## Reviewing tests |
| 206 | |
| 207 | Anyone who can review code and tests in Chromium can also review changes in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 208 | [external/wpt](../../third_party/blink/web_tests/external/wpt) |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 209 | that will be automatically upstreamed. There will be no additional review in |
| 210 | web-platform-tests as part of the export process. |
| 211 | |
| 212 | If upstream reviewers have feedback on the changes, discuss on the pull request |
| 213 | created during export, and if necessary work on a new pull request to iterate |
| 214 | until everyone is satisfied. |
| 215 | |
| 216 | When reviewing tests, check that they match the relevant specification, which |
| 217 | may not fully match the implementation. See also |
| 218 | [Write tests against specifications](#Write-tests-against-specifications). |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 219 | |
| 220 | ## Importing tests |
| 221 | |
| 222 | Chromium has a [mirror](https://chromium.googlesource.com/external/w3c/web-platform-tests/) |
| 223 | of the GitHub repo and periodically imports a subset of the tests to |
| 224 | run as part of the regular Blink web test testing process. |
| 225 | |
| 226 | The goals of this process are to be able to run web-platform-tests unmodified |
| 227 | locally just as easily as we can run the Blink tests, and ensure that we are |
| 228 | tracking tip-of-tree in the web-platform-tests repository as closely as |
| 229 | possible, and running as many of the tests as possible. |
| 230 | |
| 231 | ### Automatic import process |
| 232 | |
| 233 | There is an automatic process for updating the Chromium copy of |
| 234 | web-platform-tests. The import is done by the builder [wpt-importer |
| 235 | builder][wpt-importer]. |
| 236 | |
| 237 | The easiest way to check the status of recent imports is to look at: |
| 238 | |
| 239 | - Recent logs on LUCI for [wpt-importer builder][wpt-importer] |
| 240 | - Recent CLs created by [WPT |
| 241 | Autoroller](https://chromium-review.googlesource.com/q/owner:wpt-autoroller%2540chops-service-accounts.iam.gserviceaccount.com). |
| 242 | |
| 243 | The import jobs will generally be green if either there was nothing to do, |
| 244 | or a CL was successfully submitted. |
| 245 | |
| 246 | For maintainers: |
| 247 | |
| 248 | - The source lives in |
| 249 | [third_party/blink/tools/wpt_import.py](../../third_party/blink/tools/wpt_import.py). |
| 250 | - If the importer starts misbehaving, it can be disabled by landing a |
| 251 | [CL to skip the update step](https://crrev.com/c/1961906/). |
| 252 | |
Robert Ma | a23460e7 | 2020-12-20 12:39:27 | [diff] [blame] | 253 | ### New failure notifications |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 254 | |
An Sung | 183d2ac | 2023-08-24 00:05:08 | [diff] [blame] | 255 | The importer automatically file bugs against a component when imported changes |
| 256 | introduce failures as long as test owners did not choose to opt-out the failure |
| 257 | notification mechanism. This includes new tests that fail in Chromium, as well |
| 258 | as new failures introduced to an existing test. Test owners are encouraged to |
| 259 | create an `DIR_METADATA` file in the appropriate `external/wpt/` subdirectory |
Jonathan Lee | 61fc7285 | 2024-02-05 19:55:49 | [diff] [blame] | 260 | that contains at least the `buganizer_public.component_id` field, which the |
| 261 | importer will use to file bugs. |
An Sung | 183d2ac | 2023-08-24 00:05:08 | [diff] [blame] | 262 | For example, `external/wpt/css/css-grid/DIR_METADATA` looks like: |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 263 | |
| 264 | ``` |
nihardamar | 3afa556 | 2023-09-28 21:41:21 | [diff] [blame] | 265 | buganizer_public { |
| 266 | component_id: 1415957 |
| 267 | } |
Robert Ma | a23460e7 | 2020-12-20 12:39:27 | [diff] [blame] | 268 | team_email: "[email protected]" |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 269 | ``` |
| 270 | |
Jonathan Lee | aafbd5e | 2023-07-11 01:52:39 | [diff] [blame] | 271 | When tests under `external/wpt/css/css-grid/` newly fail in a WPT import, the |
Jonathan Lee | 61fc7285 | 2024-02-05 19:55:49 | [diff] [blame] | 272 | importer will automatically file a bug against the `Chromium>Blink>Layout>Grid` |
| 273 | component in [issues.chromium.org](https://issues.chromium.org/issues), with |
| 274 | details of which tests failed and the outputs. |
Jonathan Lee | aafbd5e | 2023-07-11 01:52:39 | [diff] [blame] | 275 | The importer will also copy `[email protected]` (the `team_email`) and any |
| 276 | `external/wpt/css/css-grid/OWNERS` on the bug. |
| 277 | |
| 278 | Failing tests are grouped according to the most specific `DIR_METADATA` that |
| 279 | they roll up to. |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 280 | |
An Sung | 183d2ac | 2023-08-24 00:05:08 | [diff] [blame] | 281 | To opt-out of this notification, add `wpt.notify` field set to `NO` to the |
| 282 | corresponding `DIR_METADATA`. |
| 283 | For example, the following `DIR_METADATA` will suppress notification from tests |
| 284 | under the located directory: |
| 285 | |
| 286 | ``` |
Jonathan Lee | 61fc7285 | 2024-02-05 19:55:49 | [diff] [blame] | 287 | buganizer_public { |
| 288 | component_id: 1415957 |
An Sung | 183d2ac | 2023-08-24 00:05:08 | [diff] [blame] | 289 | } |
| 290 | team_email: "[email protected]" |
| 291 | wpt { |
| 292 | notify: NO |
| 293 | } |
| 294 | ``` |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 295 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 296 | ### Skipped tests (and how to re-enable them) |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 297 | |
| 298 | We control which tests are imported via a file called |
| 299 | [W3CImportExpectations](../../third_party/blink/web_tests/W3CImportExpectations), |
| 300 | which has a list of directories to skip while importing. |
| 301 | |
| 302 | In addition to the directories and tests explicitly skipped there, tests may |
| 303 | also be skipped for a couple other reasons, e.g. if the file path is too long |
| 304 | for Windows. To check what files are skipped in import, check the recent logs |
| 305 | for [wpt-importer builder][wpt-importer]. |
| 306 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 307 | If you wish to un-skip some of the directories currently skipped in |
| 308 | `W3CImportExpectations`, you can modify that file locally and commit it, and on |
| 309 | the next auto-import, the new tests should be imported. |
| 310 | |
| 311 | If you want to import immediately (in order to try the tests out locally, etc) |
| 312 | you can also run `wpt-import`, but this is not required. |
| 313 | |
| 314 | Remember your import might fail due to GitHub's limit for unauthenticated |
| 315 | requests, so consider [passing your GitHub credentials](#GitHub-credentials) to |
| 316 | the script. |
| 317 | |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 318 | ### Waterfall failures caused by automatic imports. |
| 319 | |
| 320 | If there are new test failures that start after an auto-import, |
| 321 | there are several possible causes, including: |
| 322 | |
| 323 | 1. New baselines for flaky tests were added (https://crbug.com/701234). |
| 324 | 2. Modified tests should have new results for non-Release builds but they weren't added (https://crbug.com/725160). |
| 325 | 3. New baselines were added for tests with non-deterministic test results (https://crbug.com/705125). |
| 326 | |
| 327 | Because these tests are imported from the Web Platform tests, it is better |
| 328 | to have them in the repository (and marked failing) than not, so prefer to |
| 329 | [add test expectations](web_test_expectations.md) rather than reverting. |
| 330 | However, if a huge number of tests are failing, please revert the CL so we |
| 331 | can fix it manually. |
| 332 | |
| 333 | [wpt-importer]: https://ci.chromium.org/p/infra/builders/luci.infra.cron/wpt-importer |
| 334 | |
| 335 | ## Exporting tests |
| 336 | |
| 337 | If you upload a CL with any changes in |
| 338 | [third_party/blink/web_tests/external/wpt](../../third_party/blink/web_tests/external/wpt), |
Weizhong Xia | 55d9df52 | 2024-06-03 16:35:00 | [diff] [blame] | 339 | once your CL is ready to submit the exporter will create a provisional pull request with |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 340 | those changes in the [upstream WPT GitHub repository](https://github.com/web-platform-tests/wpt/). |
| 341 | The exporter runs on [wpt-exporter builder][wpt-exporter]. |
| 342 | |
| 343 | Once you're ready to land your CL, please follow the link posted by the bot and |
| 344 | check the status of the required checks of the GitHub PR. If it's green, go |
| 345 | ahead landing your CL and the exporter will automatically merge the PR. |
| 346 | |
| 347 | If GitHub status is red on the PR, please try to resolve the failures before |
| 348 | merging. If you run into any issues, or if you have a CL with WPT changes that |
Raphael Kubo da Costa | fec70fa | 2023-03-02 18:36:44 | [diff] [blame] | 349 | the exporter did not pick up, please reach out to blink-dev@chromium.org. |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 350 | |
| 351 | Additional things to note: |
| 352 | |
| 353 | - CLs that change over 1000 files will not be exported. |
| 354 | - All PRs use the |
| 355 | [`chromium-export`](https://github.com/web-platform-tests/wpt/pulls?utf8=%E2%9C%93&q=is%3Apr%20label%3Achromium-export) label. |
| 356 | - All PRs for CLs that haven't yet been landed in Chromium also use the |
| 357 | [`do not merge yet`](https://github.com/web-platform-tests/wpt/pulls?q=is%3Apr+is%3Aopen+label%3A%22do+not+merge+yet%22) label. |
| 358 | - The exporter cannot create upstream PRs for in-flight CLs with binary files |
| 359 | (e.g. webm files). An export PR will still be made after the CL lands. |
| 360 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 361 | ### Will the exported commits be linked to my GitHub profile? |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 362 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 363 | The email you commit with in Chromium will be the author of the commit on |
| 364 | GitHub. You can [add it as a secondary address on your GitHub |
| 365 | account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/) |
| 366 | to link your exported commits to your GitHub profile. |
| 367 | |
| 368 | If you are a Googler, you can also register your GitHub account at go/github, |
| 369 | making it easier for other Googlers to find you. |
| 370 | |
| 371 | ### What if there are conflicts? |
| 372 | |
| 373 | This cannot be avoided entirely as the two repositories are independent, but |
| 374 | should be rare with frequent imports and exports. When it does happen, manual |
| 375 | intervention will be needed and in non-trivial cases you may be asked to help |
| 376 | resolve the conflict. |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 377 | |
| 378 | [wpt-exporter]: https://ci.chromium.org/p/infra/builders/luci.infra.cron/wpt-exporter |
| 379 | |
| 380 | ## Notes for WPT infra maintainers |
| 381 | |
Stephen McGruer | ba2aa52 | 2021-02-26 21:27:43 | [diff] [blame] | 382 | ### Importer |
| 383 | |
| 384 | #### Rubber-Stamper bot |
| 385 | |
| 386 | To allow the importer to land CLs without human intervention, it utilizes the |
| 387 | [Rubber-Stamper |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 388 | bot](https://chromium.googlesource.com/infra/infra/+/refs/heads/main/go/src/infra/appengine/rubber-stamper/README.md) |
Stephen McGruer | ba2aa52 | 2021-02-26 21:27:43 | [diff] [blame] | 389 | to approve import CLs. |
| 390 | |
| 391 | Adding the Rubber-Stamper as a reviewer is one of the last steps the importer |
| 392 | takes, once tests have been rebaselined and the CQ passes. If the Rubber-Stamper |
| 393 | cannot approve a CL, it will leave a comment on the CL explaining why - this |
| 394 | will also cause the importer to go red. |
| 395 | |
| 396 |  |
| 397 | |
| 398 | There are two possibilities when the Rubber-Stamper rejects an import: either it |
| 399 | is a valid rejection, because the import changes code files (`.py`, `.bat`, |
| 400 | `.sh`), or it is invalid and we're missing an allowlist rule for a file the |
| 401 | importer is allowed to modify. |
| 402 | |
| 403 | For valid rejections, it is the job of the rotation sheriff to land the CL |
| 404 | manually. You need to un-abandon the import, `CR+1` it yourself, and `CQ+2` it. |
| 405 | If you don't have permission to do that (e.g. are not a committer), contact |
Raphael Kubo da Costa | fec70fa | 2023-03-02 18:36:44 | [diff] [blame] | 406 | [email protected]. |
Stephen McGruer | ba2aa52 | 2021-02-26 21:27:43 | [diff] [blame] | 407 | |
Raphael Kubo da Costa | fec70fa | 2023-03-02 18:36:44 | [diff] [blame] | 408 | For invalid rejections, message [email protected] or add an exception |
Stephen McGruer | ba2aa52 | 2021-02-26 21:27:43 | [diff] [blame] | 409 | rule yourself. [This is an example |
| 410 | CL](https://chrome-internal-review.googlesource.com/c/infradata/config/+/3608170) |
| 411 | that adds an exception rule. (Note that you need internal access to access this |
| 412 | repository). |
| 413 | |
| 414 | #### Manual import |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 415 | |
| 416 | To pull the latest versions of the tests that are currently being imported, you |
| 417 | can also directly invoke the |
| 418 | [wpt-import](../../third_party/blink/tools/wpt_import.py) script. |
| 419 | |
| 420 | That script will pull the latest version of the tests from our mirrors of the |
| 421 | upstream repositories. If any new versions of tests are found, they will be |
| 422 | committed locally to your local repository. You may then upload the changes. |
| 423 | |
| 424 | Remember your import might fail due to GitHub's limit for unauthenticated |
| 425 | requests, so consider [passing your GitHub credentials](#GitHub-credentials) to |
| 426 | the script. |
| 427 | |
Robert Ma | 4f6eff1 | 2020-08-18 22:44:45 | [diff] [blame] | 428 | ### Exporter |
| 429 | |
| 430 | - The source lives in |
| 431 | [third_party/blink/tools/wpt_export.py](../../third_party/blink/tools/wpt_export.py). |
| 432 | - If the exporter starts misbehaving (for example, creating the same PR over |
| 433 | and over again), put it in "dry run" mode by landing [this |
| 434 | CL](https://crrev.com/c/462381/). |
| 435 | |
Stephen McGruer | a12b34f8 | 2020-07-10 16:00:42 | [diff] [blame] | 436 | ### GitHub credentials |
| 437 | |
| 438 | When manually running the `wpt-import` and `wpt-export` scripts, several |
| 439 | requests are made to GitHub to query the status of pull requests, look for |
| 440 | existing exported commits etc. GitHub has a [fairly |
| 441 | low](https://developer.github.com/v3/#rate-limiting) request limit for |
| 442 | unauthenticated requests, so it is recommended that you let `wpt-export` and |
| 443 | `wpt-import` use your GitHub credentials when sending requests: |
| 444 | |
| 445 | 1. Generate a new [personal access token](https://github.com/settings/tokens) |
| 446 | 1. Set up your credentials by either: |
| 447 | * Setting the `GH_USER` environment variable to your GitHub user name |
| 448 | and the `GH_TOKEN` environment variable to the access token you have |
| 449 | just created **or** |
| 450 | * Creating a JSON file with two keys: `GH_USER`, your GitHub user name, |
| 451 | and `GH_TOKEN`, the access token you have just generated. After that, |
| 452 | pass `--credentials-json <path-to-json>` to `wpt-export` and |
| 453 | `wpt-import`. |
Yoshisato Yanagisawa | 638e2ee0 | 2021-12-09 05:52:08 | [diff] [blame] | 454 | |
| 455 | ### Debugging failed web platform tests |
| 456 | |
| 457 | This section explains the way to debug web platform tests. |
| 458 | Please build `blink_tests` before running commands below. |
| 459 | It is explained in [Running Web Tests](./web_tests.md#running-web-tests). |
| 460 | |
| 461 | #### Running test(s) |
| 462 | |
| 463 | The way to run web tests is explained in [Running the |
| 464 | Tests](./web_tests.md#running-the-tests). |
| 465 | |
| 466 | Assume that you are writing the test named `wpt_internal/fake/foobar.html`. |
| 467 | You may want to run only the tests and you do not want to run all tests under |
| 468 | `wpt_internal/fake`. The following command narrows down the test to only |
| 469 | `wpt_internal/fake/foobar.html`. |
| 470 | |
| 471 | ```bash |
| 472 | third_party/blink/tools/run_web_tests.py -t Default \ |
| 473 | third_party/blink/web_tests/wpt_internal/fake/foobar.html |
| 474 | ``` |
| 475 | |
| 476 | #### Logging |
| 477 | |
| 478 | During the debug, you may want to log what happens during the test. |
| 479 | You can use `console.log` in JavaScript to log arbitrary strings. |
| 480 | |
| 481 | ``` |
| 482 | e.g. |
| 483 | console.log('fake has been executed.'); |
| 484 | console.log('foo=' + foo); |
| 485 | ``` |
| 486 | |
| 487 | Logs are written under `$root_build_dir/layout-test-results`. |
| 488 | If you have tested `wpt_internal/fake/foobar.html`, the log will be stored in |
| 489 | `$root_build_dir/layout-test-results/wpt_internal/fake/foobar-stderr.txt`. |
| 490 | You can change output directory with `--results-directory=<output directory>`. |
| 491 | |
| 492 | #### Checking HTTP servers |
| 493 | |
| 494 | For some test cases, you may use .headers file to set arbitrary HTTP headers. |
| 495 | To verify what is set to headers, you can run an HTTP server used for WPT |
| 496 | by yourself. The following command starts the HTTP server for you: |
| 497 | |
| 498 | ```bash |
| 499 | third_party/blink/tools/run_blink_wptserve.py |
| 500 | ``` |
| 501 | |
| 502 | To see headers returned by the server, you can use `curl -v`. |
| 503 | `curl` will show headers in stderr. You may want to use `|& less` to |
| 504 | see output if it is too long. |
| 505 | |
| 506 | ```bash |
| 507 | curl -v http://localhost:8081/wpt_internal/fake/foobar.html |& less |
| 508 | ``` |
Takahiro | 961b242 | 2022-01-19 00:14:29 | [diff] [blame] | 509 | |
| 510 | #### Debugging with a debugger |
| 511 | |
| 512 | You are able to debug the inside of Chromium with a debugger for particular |
| 513 | WPT tests. Refer to [Running web tests using the content shell](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/testing/web_tests_in_content_shell.md) |
| 514 | for details. |