blob: e20e83af9f3288037064820a1436630ec1161a4a [file] [log] [blame] [view]
qyearsley4f0acca42017-01-30 08:18:431# Web Platform Tests
2
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
qyearsley9c9781a2017-02-11 00:08:399test suite where all browser engines are collaborating. There's also a
rbyers6299b9132017-02-10 18:06:5710[csswg-test repository](https://github.com/w3c/csswg-test) for CSS tests, but
11that will [soon be merged into
12web-platform-tests](https://github.com/w3c/csswg-test/issues/1102).
qyearsley4f0acca42017-01-30 08:18:4313
foolipdf2a8632017-02-15 15:03:1614Chromium has 2-way import/export process with the upstream web-platform-tests
15repository, where tests are imported into
16[LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
17and any changes to the imported tests are also exported to web-platform-tests.
18
qyearsley4f0acca42017-01-30 08:18:4319[TOC]
20
foolipdf2a8632017-02-15 15:03:1621## Importing tests
qyearsley4f0acca42017-01-30 08:18:4322
23Chromium has mirrors
24([web-platform-tests](https://chromium.googlesource.com/external/w3c/web-platform-tests/),
25[csswg-test](https://chromium.googlesource.com/external/w3c/csswg-test/)) of the
26GitHub 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
foolipdf2a8632017-02-15 15:03:1629The goal 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
31tracking tip-of-tree in the Web Platform Tests repository as closely as
32possible, and running as many of the tests as possible.
33
34### Automatic import process
35
36There is an automatic process for updating the Chromium copy of the Web Platform
37Tests. The import is done by the builder [w3c-test-autoroller
38builder](https://build.chromium.org/p/chromium.infra.cron/builders/w3c-test-autoroller).
39
40The easiest way to check the status of recent imports is to look at:
41
42- Recent logs on Buildbot for [w3c-test-autoroller
43 builder](https://build.chromium.org/p/chromium.infra.cron/builders/w3c-test-autoroller)
44- 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
qyearsley4f0acca42017-01-30 08:18:4349### Skipped tests
50
51We control which tests are imported via a file called
52[W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations),
53which has a list of directories to skip while importing.
54
55In addition to the directories and tests explicitly skipped there, tests may
56also be skipped for a couple other reasons, e.g. if the file path is too long
57for Windows. To check what files are skipped in import, check the recent logs
58for [w3c-test-autoroller
59builder](https://build.chromium.org/p/chromium.infra.cron/builders/w3c-test-autoroller).
60
61### Manual import
62
63To pull the latest versions of the tests that are currently being imported, you
64can also directly invoke the
65[wpt-import](../../third_party/WebKit/Tools/Scripts/wpt-import) script.
66
67That script will pull the latest version of the tests from our mirrors of the
68upstream repositories. If any new versions of tests are found, they will be
69committed locally to your local repository. You may then upload the changes.
70
qyearsley9c9781a2017-02-11 00:08:3971### Enabling import for a new directory
72
qyearsley4f0acca42017-01-30 08:18:4373If you wish to add more tests (by un-skipping some of the directories currently
74skipped in `W3CImportExpectations`), you can modify that file locally and commit
qyearsley9c9781a2017-02-11 00:08:3975it, and on the next auto-import, the new tests should be imported.
76
77If you want to import immediately (in order to try the tests out locally, etc)
78you can also run `wpt-import --allow-local-commits`, but this is not required.
qyearsley4f0acca42017-01-30 08:18:4379
foolipdf2a8632017-02-15 15:03:1680## Writing tests
qyearsley4f0acca42017-01-30 08:18:4381
foolipdf2a8632017-02-15 15:03:1682To contribute changes to Web Platform Tests, just commit your changes directly
83to [LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
qyearsley4f0acca42017-01-30 08:18:4384and the changes will be automatically upstreamed within 24 hours.
85
foolipdf2a8632017-02-15 15:03:1686Changes involving adding, removing or modifying tests can all be upstreamed.
87Any changes outside of
88[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) will not be
89upstreamed, and any changes `*-expected.txt`, `OWNERS`, and `MANIFEST.json`,
90will also not be upstreamed.
rbyers6299b9132017-02-10 18:06:5791
qyearsley4f0acca42017-01-30 08:18:4392Note: if you're adding a new test in `external/wpt`, you'll need to re-generate
93MANIFEST.json manually until [CL 2644783003](https://crrev.com/2644783003) is
94landed. The command to do so is:
95
96```bash
97Tools/Scripts/webkitpy/thirdparty/wpt/wpt/manifest --work \
98 --tests-root=LayoutTests/external/wpt
99```
100
foolipdf2a8632017-02-15 15:03:16101Most tests are written using testharness.js, see
102[Writing Layout Tests](./writing_layout_tests.md) and
103[Layout Tests Tips](./layout_tests_tips.md) for general guidelines.
qyearsley9c9781a2017-02-11 00:08:39104
foolipdf2a8632017-02-15 15:03:16105### Write tests against specifications
106
107Tests in Web Platform Tests are expected to match behavior defined by the
108relevant specification. In other words, all assertions that a test makes
109should be derived from a specification's normative requirements, and not go
110beyond them. It is often necessary to change the specification to clarify what
111is and isn't required.
112
113When the standards discussion is still ongoing or blocked on some implementation
114successfully shipping the hoped-for behavior, write the tests outside of
115web-platform-tests and upstream them when the specification is finally updated.
116Optionally, it may be possible to write deliberately failing tests against the
117current specification and later update them.
118
119### Tests that require testing APIs
120
121Tests that depend on `internals.*`, `eventSender.*` or other internal testing
122APIs cannot yet be written as part of web-platform-tests.
123
124An alternative is to write manual tests that are automated with scripts from
125[wpt_automation](../../third_party/WebKit/LayoutTests/external/wpt_automation).
126Such tests still require case-by-case automation to run for other browser
127engines, but are more valuable than purely manual tests.
128
129*** note
130TODO(foolip): Figure out and document a more scalable test automation solution.
131***
132
133### Adding new top-level directories
qyearsley9c9781a2017-02-11 00:08:39134
135Entirely new top-level directories should generally be added upstream, since
136that's the only way to add an OWNERS file upstream. After adding a new top-level
137directory upstream, you should add a line for it in `W3CImportExpectations`.
138
foolipdf2a8632017-02-15 15:03:16139Adding the new directory (and `W3CImportExpectations` entry) in Chromium and
140later adding an OWNERS file upstream also works.
141
qyearsley4f0acca42017-01-30 08:18:43142### Will the exported commits be linked to my GitHub profile?
143
144The email you commit with in Chromium will be the author of the commit on
145GitHub. You can [add it as a secondary address on your GitHub
146account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/)
147to link your exported commits to your GitHub profile.
148
149### What if there are conflicts?
150
151This cannot be avoided entirely as the two repositories are independent, but
152should be rare with frequent imports and exports. When it does happen, manual
153intervention will be needed and in non-trivial cases you may be asked to help
154resolve the conflict.
155
156### Direct pull requests
157
158It's still possible to make direct pull requests to web-platform-tests. The
159processes for getting new tests committed the W3C repos are at
qyearsley7b458d52017-02-02 17:51:15160http://testthewebforward.org/docs/. Some specifics are at
161http://testthewebforward.org/docs/github-101.html.
foolipdf2a8632017-02-15 15:03:16162
163## Reviewing tests
164
165Anyone who can review code and tests in Chromium can also review changes in
166[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
167that will be automatically upstreamed. There will be no additional review in
168web-platform-tests as part of the export process.
169
170If upstream reviewers have feedback on the changes, discuss on the pull request
171created during export, and if necessary work on a new pull request to iterate
172until everyone is satisfied.
173
174When reviewing tests, check that they match the relevant specification, which
175may not fully match the implementation. See also
176[Write tests against specifications](#Write-tests-against-specifications).