blob: c8bb0e474bef1bc100d4f85087eeca8bac628415 [file] [log] [blame] [view]
foolipeda32ab2017-02-16 19:21:581# web-platform-tests
qyearsley4f0acca42017-01-30 08:18:432
rbyers6299b9132017-02-10 18:06:573Interoperability between browsers is
qyearsley9c9781a2017-02-11 00:08:394[critical](https://www.chromium.org/blink/platform-predictability) to Chromium's
5mission of improving the web. We believe that leveraging and contributing to a
6shared test suite is one of the most important tools in achieving
7interoperability between browsers. The [web-platform-tests
rbyers6299b9132017-02-10 18:06:578repository](https://github.com/w3c/web-platform-tests) is the primary shared
Quinten Yearsleyfab627a2017-03-29 22:30:189test suite where all browser engines are collaborating.
qyearsley4f0acca42017-01-30 08:18:4310
Jeff Carpenterabd13602017-03-29 22:49:5911Chromium has a 2-way import/export process with the upstream web-platform-tests
foolipdf2a8632017-02-15 15:03:1612repository, where tests are imported into
13[LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
14and any changes to the imported tests are also exported to web-platform-tests.
15
foolipeda32ab2017-02-16 19:21:5816See http://web-platform-tests.org/ for general documentation on
17web-platform-tests, including tips for writing and reviewing tests.
18
qyearsley4f0acca42017-01-30 08:18:4319[TOC]
20
foolipdf2a8632017-02-15 15:03:1621## Importing tests
qyearsley4f0acca42017-01-30 08:18:4322
Jeff Carpenterd66c6892017-11-03 00:13:5323Chromium has a [mirror](https://chromium.googlesource.com/external/w3c/web-platform-tests/)
24of the GitHub repo and periodically imports a subset of the tests to
qyearsley4f0acca42017-01-30 08:18:4325run as part of the regular Blink layout test testing process.
26
raphael.kubo.da.costa21ed71a2017-04-12 10:50:4427The goals of this process are to be able to run web-platform-tests unmodified
qyearsley4f0acca42017-01-30 08:18:4328locally just as easily as we can run the Blink tests, and ensure that we are
foolipeda32ab2017-02-16 19:21:5829tracking tip-of-tree in the web-platform-tests repository as closely as
qyearsley4f0acca42017-01-30 08:18:4330possible, and running as many of the tests as possible.
31
32### Automatic import process
33
foolipeda32ab2017-02-16 19:21:5834There is an automatic process for updating the Chromium copy of
Quinten Yearsleyfab627a2017-03-29 22:30:1835web-platform-tests. The import is done by the builder [wpt-importer
36builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer).
qyearsley4f0acca42017-01-30 08:18:4337
38The easiest way to check the status of recent imports is to look at:
39
Quinten Yearsleyfab627a2017-03-29 22:30:1840- Recent logs on Buildbot for [wpt-importer
41 builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer)
qyearsley4f0acca42017-01-30 08:18:4342- Recent CLs created by
Quinten Yearsley52f29762017-07-12 23:02:2543 [blink-w3c-test-autoroller@chromium.org](https://chromium-review.googlesource.com/q/owner:blink-w3c-test-autoroller%40chromium.org).
qyearsley4f0acca42017-01-30 08:18:4344
Quinten Yearsley95fa3232017-08-18 16:10:5545The import jobs will generally be green if either there was nothing to do,
46or a CL was successfully submitted.
47
48If the importer starts misbehaving, it could be disabled by turning off the
49auto-import mode by landing [this CL](https://crrev.com/c/617479/).
foolipdf2a8632017-02-15 15:03:1650
Quinten Yearsley12a15b72017-06-05 21:51:2351### Failures caused by automatic imports.
52
53If there are new test failures that start after an auto-import,
54there are several possible causes, including:
55
56 1. New baselines for flaky tests were added (http://crbug.com/701234).
57 2. Modified tests should have new results for non-Release builds but they weren't added (http://crbug.com/725160).
58 3. New baselines were added for tests with non-deterministic test results (http://crbug.com/705125).
59
60Because these tests are imported from the Web Platform tests, it is better
61to have them in the repository (and marked failing) than not, so prefer to
62[add test expectations](layout_test_expectations.md) rather than reverting.
63However, if a huge number of tests are failing, please revert the CL so we
64can fix it manually.
65
Jeff Carpenterabd13602017-03-29 22:49:5966### Automatic export process
67
Jeff Carpenter4562d242017-07-14 22:10:4368If you upload a CL with any changes in
69[third_party/WebKit/LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt),
70once you add reviewers the exporter will create a provisional pull request with
71those changes in the [upstream WPT GitHub repository](https://github.com/w3c/web-platform-tests/).
Jeff Carpenterabd13602017-03-29 22:49:5972
Jeff Carpenter4562d242017-07-14 22:10:4373Once you're ready to land your CL, please check the Travis CI status on the
74upstream PR (link at the bottom of the page). If it's green, go ahead and land your CL
75and the exporter will automatically remove the "do not merge yet" label and merge the PR.
76
77If Travis CI is red on the upstream PR, please try to resolve the failures before
78merging. If you run into Travis CI issues, or if you have a CL with WPT changes that
79the exporter did not pick up, please reach out to [email protected].
80
81Additional things to note:
82
83- CLs that change over 1000 files will not be exported.
84- All PRs use the
85 [`chromium-export`](https://github.com/w3c/web-platform-tests/pulls?utf8=%E2%9C%93&q=is%3Apr%20label%3Achromium-export) label.
86- All PRs for CLs that haven't yet been landed in Chromium also use the
87 [`do not merge yet`](https://github.com/w3c/web-platform-tests/pulls?q=is%3Apr+is%3Aopen+label%3A%22do+not+merge+yet%22) label.
88- The exporter cannot create upstream PRs for in-flight CLs with binary files (e.g. webm files).
89 An export PR will still be made after the CL lands.
90
91For maintainers:
92
93- The exporter runs continuously under the
94 [chromium.infra.cron master](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-exporter).
95- The source lives in
Philip Jägenstedt8d4218a32017-09-19 12:30:4296 [third_party/WebKit/Tools/Scripts/wpt-export](../../third_party/WebKit/Tools/Scripts/wpt-export).
Jeff Carpenter4562d242017-07-14 22:10:4397- If the exporter starts misbehaving
98 (for example, creating the same PR over and over again)
99 put it in "dry run" mode by landing [this CL](https://crrev.com/c/462381/).
Jeff Carpenterabd13602017-03-29 22:49:59100
qyearsley4f0acca42017-01-30 08:18:43101### Skipped tests
102
103We control which tests are imported via a file called
104[W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations),
105which has a list of directories to skip while importing.
106
107In addition to the directories and tests explicitly skipped there, tests may
108also be skipped for a couple other reasons, e.g. if the file path is too long
109for Windows. To check what files are skipped in import, check the recent logs
Quinten Yearsleyfab627a2017-03-29 22:30:18110for [wpt-importer
111builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer).
qyearsley4f0acca42017-01-30 08:18:43112
113### Manual import
114
115To pull the latest versions of the tests that are currently being imported, you
116can also directly invoke the
117[wpt-import](../../third_party/WebKit/Tools/Scripts/wpt-import) script.
118
119That script will pull the latest version of the tests from our mirrors of the
120upstream repositories. If any new versions of tests are found, they will be
121committed locally to your local repository. You may then upload the changes.
122
qyearsley9c9781a2017-02-11 00:08:39123### Enabling import for a new directory
124
qyearsley4f0acca42017-01-30 08:18:43125If you wish to add more tests (by un-skipping some of the directories currently
126skipped in `W3CImportExpectations`), you can modify that file locally and commit
qyearsley9c9781a2017-02-11 00:08:39127it, and on the next auto-import, the new tests should be imported.
128
129If you want to import immediately (in order to try the tests out locally, etc)
130you can also run `wpt-import --allow-local-commits`, but this is not required.
qyearsley4f0acca42017-01-30 08:18:43131
foolipdf2a8632017-02-15 15:03:16132## Writing tests
qyearsley4f0acca42017-01-30 08:18:43133
foolipeda32ab2017-02-16 19:21:58134To contribute changes to web-platform-tests, just commit your changes directly
foolipdf2a8632017-02-15 15:03:16135to [LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
qyearsley4f0acca42017-01-30 08:18:43136and the changes will be automatically upstreamed within 24 hours.
137
foolipdf2a8632017-02-15 15:03:16138Changes involving adding, removing or modifying tests can all be upstreamed.
139Any changes outside of
140[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) will not be
141upstreamed, and any changes `*-expected.txt`, `OWNERS`, and `MANIFEST.json`,
142will also not be upstreamed.
rbyers6299b9132017-02-10 18:06:57143
Jeff Carpentereb1ff6b2017-03-02 23:21:58144Running the layout tests will automatically regenerate MANIFEST.json to pick up
145any local modifications.
foolip2f198552017-02-24 16:42:35146
foolipdf2a8632017-02-15 15:03:16147Most tests are written using testharness.js, see
148[Writing Layout Tests](./writing_layout_tests.md) and
149[Layout Tests Tips](./layout_tests_tips.md) for general guidelines.
qyearsley9c9781a2017-02-11 00:08:39150
foolipdf2a8632017-02-15 15:03:16151### Write tests against specifications
152
foolipeda32ab2017-02-16 19:21:58153Tests in web-platform-tests are expected to match behavior defined by the
foolipdf2a8632017-02-15 15:03:16154relevant specification. In other words, all assertions that a test makes
155should be derived from a specification's normative requirements, and not go
156beyond them. It is often necessary to change the specification to clarify what
157is and isn't required.
158
Philip Jägenstedt8bb32fa2018-01-27 14:39:26159When implementation experience is needed to inform the specification work,
160[tentative tests](http://web-platform-tests.org/writing-tests/file-names.html)
161can be appropriate. It should be apparent in context why the test is tentative
162and what needs to be resolved to make it non-tentative.
foolipdf2a8632017-02-15 15:03:16163
164### Tests that require testing APIs
165
Philip Jägenstedt8bb32fa2018-01-27 14:39:26166[testdriver.js](http://web-platform-tests.org/writing-tests/testdriver.html)
167provides a means to automate tests that cannot be written purely using web
168platform APIs, similar to `internals.*` and `eventSender.*` in regular Blink
169layout tests.
170
171If no testdriver.js API exists, check if it's a
172[known issue](https://github.com/w3c/web-platform-tests/labels/testdriver.js)
173and otherwise consider filing a new issue.
foolipdf2a8632017-02-15 15:03:16174
175An alternative is to write manual tests that are automated with scripts from
176[wpt_automation](../../third_party/WebKit/LayoutTests/external/wpt_automation).
Quinten Yearsleye577029f2017-07-06 00:21:03177Injection of JS in manual tests is determined by `loadAutomationScript` in
178[testharnessreport.js](../../third_party/WebKit/LayoutTests/resources/testharnessreport.js).
179
foolipdf2a8632017-02-15 15:03:16180Such tests still require case-by-case automation to run for other browser
181engines, but are more valuable than purely manual tests.
182
Quinten Yearsleye577029f2017-07-06 00:21:03183Manual tests that have no automation are still imported, but skipped in
184[NeverFixTests](../../third_party/WebKit/LayoutTests/NeverFixTests); see
185[issue 738489](https://crbug.com/738489).
186
foolipdf2a8632017-02-15 15:03:16187### Adding new top-level directories
qyearsley9c9781a2017-02-11 00:08:39188
189Entirely new top-level directories should generally be added upstream, since
190that's the only way to add an OWNERS file upstream. After adding a new top-level
191directory upstream, you should add a line for it in `W3CImportExpectations`.
192
foolipdf2a8632017-02-15 15:03:16193Adding the new directory (and `W3CImportExpectations` entry) in Chromium and
194later adding an OWNERS file upstream also works.
195
qyearsley4f0acca42017-01-30 08:18:43196### Will the exported commits be linked to my GitHub profile?
197
198The email you commit with in Chromium will be the author of the commit on
199GitHub. You can [add it as a secondary address on your GitHub
200account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/)
201to link your exported commits to your GitHub profile.
202
Philip Jägenstedtf7e99cf2018-01-22 15:54:29203If you are a Googler, you can also register your GitHub account at go/github,
204making it easier for other Googlers to find you.
205
qyearsley4f0acca42017-01-30 08:18:43206### What if there are conflicts?
207
208This cannot be avoided entirely as the two repositories are independent, but
209should be rare with frequent imports and exports. When it does happen, manual
210intervention will be needed and in non-trivial cases you may be asked to help
211resolve the conflict.
212
213### Direct pull requests
214
foolipeda32ab2017-02-16 19:21:58215It's still possible to make direct pull requests to web-platform-tests, see
216http://web-platform-tests.org/appendix/github-intro.html.
foolipdf2a8632017-02-15 15:03:16217
Jeff Carpenter11b548b2017-11-03 23:05:22218## Running tests
219
220Same as Blink layout tests, you can use
221[`run-webkit-tests`](layout_tests.md#running-the-tests) to run any WPT test.
222
223One thing to note is that glob patterns for WPT tests are not yet supported.
224
foolipdf2a8632017-02-15 15:03:16225## Reviewing tests
226
227Anyone who can review code and tests in Chromium can also review changes in
228[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
229that will be automatically upstreamed. There will be no additional review in
230web-platform-tests as part of the export process.
231
232If upstream reviewers have feedback on the changes, discuss on the pull request
233created during export, and if necessary work on a new pull request to iterate
234until everyone is satisfied.
235
236When reviewing tests, check that they match the relevant specification, which
237may not fully match the implementation. See also
238[Write tests against specifications](#Write-tests-against-specifications).