blob: d3bc52247759a2512621f476ae07840050893f48 [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
Quinten Yearsleyfab627a2017-03-29 22:30:1823Chromium has a mirror
24([web-platform-tests](https://chromium.googlesource.com/external/w3c/web-platform-tests/)
25of the
qyearsley4f0acca42017-01-30 08:18:4326GitHub repos, and periodically imports a subset of the tests so that they are
27run as part of the regular Blink layout test testing process.
28
raphael.kubo.da.costa21ed71a2017-04-12 10:50:4429The goals of this process are to be able to run web-platform-tests unmodified
qyearsley4f0acca42017-01-30 08:18:4330locally just as easily as we can run the Blink tests, and ensure that we are
foolipeda32ab2017-02-16 19:21:5831tracking tip-of-tree in the web-platform-tests repository as closely as
qyearsley4f0acca42017-01-30 08:18:4332possible, and running as many of the tests as possible.
33
34### Automatic import process
35
foolipeda32ab2017-02-16 19:21:5836There is an automatic process for updating the Chromium copy of
Quinten Yearsleyfab627a2017-03-29 22:30:1837web-platform-tests. The import is done by the builder [wpt-importer
38builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer).
qyearsley4f0acca42017-01-30 08:18:4339
40The easiest way to check the status of recent imports is to look at:
41
Quinten Yearsleyfab627a2017-03-29 22:30:1842- Recent logs on Buildbot for [wpt-importer
43 builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer)
qyearsley4f0acca42017-01-30 08:18:4344- Recent CLs created by
45 [[email protected]](https://codereview.chromium.org/search?owner=blink-w3c-test-autoroller%40chromium.org).
46
foolipdf2a8632017-02-15 15:03:1647Automatic imports are intended to run at least once every 24 hours.
48
Quinten Yearsley12a15b72017-06-05 21:51:2349### Failures caused by automatic imports.
50
51If there are new test failures that start after an auto-import,
52there are several possible causes, including:
53
54 1. New baselines for flaky tests were added (http://crbug.com/701234).
55 2. Modified tests should have new results for non-Release builds but they weren't added (http://crbug.com/725160).
56 3. New baselines were added for tests with non-deterministic test results (http://crbug.com/705125).
57
58Because these tests are imported from the Web Platform tests, it is better
59to have them in the repository (and marked failing) than not, so prefer to
60[add test expectations](layout_test_expectations.md) rather than reverting.
61However, if a huge number of tests are failing, please revert the CL so we
62can fix it manually.
63
Jeff Carpenterabd13602017-03-29 22:49:5964### Automatic export process
65
66If a commit to Chromium master changes any files in the
67[third_party/WebKit/LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
68directory, the WPT Exporter will create a Pull Request on GitHub for it.
69All PRs use the `chromium-export` label: see
70[all of them here](https://github.com/w3c/web-platform-tests/pulls?utf8=%E2%9C%93&q=is%3Apr%20label%3Achromium-export).
71The exporter runs continuously under the chromium.infra.cron master:
72see [all recent builds](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-exporter).
73The source for the exporter lives in
74[third_party/WebKit/Tools/Scripts/wpt-exporter](../../third_party/WebKit/Tools/Scripts/wpt-exporter).
75
76In the unlikely event that the exporter starts misbehaving -- for example,
77creating the same PR over and over again -- **all you need to do to disable the
78exporter is [land this CL](https://chromium-review.googlesource.com/c/462381/)**,
79which will put it in "dry run" mode.
80
qyearsley4f0acca42017-01-30 08:18:4381### Skipped tests
82
83We control which tests are imported via a file called
84[W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations),
85which has a list of directories to skip while importing.
86
87In addition to the directories and tests explicitly skipped there, tests may
88also be skipped for a couple other reasons, e.g. if the file path is too long
89for Windows. To check what files are skipped in import, check the recent logs
Quinten Yearsleyfab627a2017-03-29 22:30:1890for [wpt-importer
91builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer).
qyearsley4f0acca42017-01-30 08:18:4392
93### Manual import
94
95To pull the latest versions of the tests that are currently being imported, you
96can also directly invoke the
97[wpt-import](../../third_party/WebKit/Tools/Scripts/wpt-import) script.
98
99That script will pull the latest version of the tests from our mirrors of the
100upstream repositories. If any new versions of tests are found, they will be
101committed locally to your local repository. You may then upload the changes.
102
qyearsley9c9781a2017-02-11 00:08:39103### Enabling import for a new directory
104
qyearsley4f0acca42017-01-30 08:18:43105If you wish to add more tests (by un-skipping some of the directories currently
106skipped in `W3CImportExpectations`), you can modify that file locally and commit
qyearsley9c9781a2017-02-11 00:08:39107it, and on the next auto-import, the new tests should be imported.
108
109If you want to import immediately (in order to try the tests out locally, etc)
110you can also run `wpt-import --allow-local-commits`, but this is not required.
qyearsley4f0acca42017-01-30 08:18:43111
foolipdf2a8632017-02-15 15:03:16112## Writing tests
qyearsley4f0acca42017-01-30 08:18:43113
foolipeda32ab2017-02-16 19:21:58114To contribute changes to web-platform-tests, just commit your changes directly
foolipdf2a8632017-02-15 15:03:16115to [LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
qyearsley4f0acca42017-01-30 08:18:43116and the changes will be automatically upstreamed within 24 hours.
117
foolipdf2a8632017-02-15 15:03:16118Changes involving adding, removing or modifying tests can all be upstreamed.
119Any changes outside of
120[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) will not be
121upstreamed, and any changes `*-expected.txt`, `OWNERS`, and `MANIFEST.json`,
122will also not be upstreamed.
rbyers6299b9132017-02-10 18:06:57123
Jeff Carpentereb1ff6b2017-03-02 23:21:58124Running the layout tests will automatically regenerate MANIFEST.json to pick up
125any local modifications.
foolip2f198552017-02-24 16:42:35126
foolipdf2a8632017-02-15 15:03:16127Most tests are written using testharness.js, see
128[Writing Layout Tests](./writing_layout_tests.md) and
129[Layout Tests Tips](./layout_tests_tips.md) for general guidelines.
qyearsley9c9781a2017-02-11 00:08:39130
foolipdf2a8632017-02-15 15:03:16131### Write tests against specifications
132
foolipeda32ab2017-02-16 19:21:58133Tests in web-platform-tests are expected to match behavior defined by the
foolipdf2a8632017-02-15 15:03:16134relevant specification. In other words, all assertions that a test makes
135should be derived from a specification's normative requirements, and not go
136beyond them. It is often necessary to change the specification to clarify what
137is and isn't required.
138
139When the standards discussion is still ongoing or blocked on some implementation
140successfully shipping the hoped-for behavior, write the tests outside of
141web-platform-tests and upstream them when the specification is finally updated.
142Optionally, it may be possible to write deliberately failing tests against the
143current specification and later update them.
144
145### Tests that require testing APIs
146
147Tests that depend on `internals.*`, `eventSender.*` or other internal testing
148APIs cannot yet be written as part of web-platform-tests.
149
150An alternative is to write manual tests that are automated with scripts from
151[wpt_automation](../../third_party/WebKit/LayoutTests/external/wpt_automation).
Quinten Yearsleye577029f2017-07-06 00:21:03152Injection of JS in manual tests is determined by `loadAutomationScript` in
153[testharnessreport.js](../../third_party/WebKit/LayoutTests/resources/testharnessreport.js).
154
foolipdf2a8632017-02-15 15:03:16155Such tests still require case-by-case automation to run for other browser
156engines, but are more valuable than purely manual tests.
157
Quinten Yearsleye577029f2017-07-06 00:21:03158Manual tests that have no automation are still imported, but skipped in
159[NeverFixTests](../../third_party/WebKit/LayoutTests/NeverFixTests); see
160[issue 738489](https://crbug.com/738489).
161
foolipdf2a8632017-02-15 15:03:16162*** note
163TODO(foolip): Figure out and document a more scalable test automation solution.
164***
165
166### Adding new top-level directories
qyearsley9c9781a2017-02-11 00:08:39167
168Entirely new top-level directories should generally be added upstream, since
169that's the only way to add an OWNERS file upstream. After adding a new top-level
170directory upstream, you should add a line for it in `W3CImportExpectations`.
171
foolipdf2a8632017-02-15 15:03:16172Adding the new directory (and `W3CImportExpectations` entry) in Chromium and
173later adding an OWNERS file upstream also works.
174
qyearsley4f0acca42017-01-30 08:18:43175### Will the exported commits be linked to my GitHub profile?
176
177The email you commit with in Chromium will be the author of the commit on
178GitHub. You can [add it as a secondary address on your GitHub
179account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/)
180to link your exported commits to your GitHub profile.
181
182### What if there are conflicts?
183
184This cannot be avoided entirely as the two repositories are independent, but
185should be rare with frequent imports and exports. When it does happen, manual
186intervention will be needed and in non-trivial cases you may be asked to help
187resolve the conflict.
188
189### Direct pull requests
190
foolipeda32ab2017-02-16 19:21:58191It's still possible to make direct pull requests to web-platform-tests, see
192http://web-platform-tests.org/appendix/github-intro.html.
foolipdf2a8632017-02-15 15:03:16193
194## Reviewing tests
195
196Anyone who can review code and tests in Chromium can also review changes in
197[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
198that will be automatically upstreamed. There will be no additional review in
199web-platform-tests as part of the export process.
200
201If upstream reviewers have feedback on the changes, discuss on the pull request
202created during export, and if necessary work on a new pull request to iterate
203until everyone is satisfied.
204
205When reviewing tests, check that they match the relevant specification, which
206may not fully match the implementation. See also
207[Write tests against specifications](#Write-tests-against-specifications).