blob: a5d90685e1ec9d970529dc463486e461377021ee [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
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
foolipeda32ab2017-02-16 19:21:5819See http://web-platform-tests.org/ for general documentation on
20web-platform-tests, including tips for writing and reviewing tests.
21
qyearsley4f0acca42017-01-30 08:18:4322[TOC]
23
foolipdf2a8632017-02-15 15:03:1624## Importing tests
qyearsley4f0acca42017-01-30 08:18:4325
26Chromium has mirrors
27([web-platform-tests](https://chromium.googlesource.com/external/w3c/web-platform-tests/),
28[csswg-test](https://chromium.googlesource.com/external/w3c/csswg-test/)) of the
29GitHub repos, and periodically imports a subset of the tests so that they are
30run as part of the regular Blink layout test testing process.
31
foolipeda32ab2017-02-16 19:21:5832The goal of this process are to be able to run web-platform-tests unmodified
qyearsley4f0acca42017-01-30 08:18:4333locally just as easily as we can run the Blink tests, and ensure that we are
foolipeda32ab2017-02-16 19:21:5834tracking tip-of-tree in the web-platform-tests repository as closely as
qyearsley4f0acca42017-01-30 08:18:4335possible, and running as many of the tests as possible.
36
37### Automatic import process
38
foolipeda32ab2017-02-16 19:21:5839There is an automatic process for updating the Chromium copy of
40web-platform-tests. The import is done by the builder [w3c-test-autoroller
qyearsley4f0acca42017-01-30 08:18:4341builder](https://build.chromium.org/p/chromium.infra.cron/builders/w3c-test-autoroller).
42
43The easiest way to check the status of recent imports is to look at:
44
45- Recent logs on Buildbot for [w3c-test-autoroller
46 builder](https://build.chromium.org/p/chromium.infra.cron/builders/w3c-test-autoroller)
47- Recent CLs created by
48 [[email protected]](https://codereview.chromium.org/search?owner=blink-w3c-test-autoroller%40chromium.org).
49
foolipdf2a8632017-02-15 15:03:1650Automatic imports are intended to run at least once every 24 hours.
51
qyearsley4f0acca42017-01-30 08:18:4352### Skipped tests
53
54We control which tests are imported via a file called
55[W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations),
56which has a list of directories to skip while importing.
57
58In addition to the directories and tests explicitly skipped there, tests may
59also be skipped for a couple other reasons, e.g. if the file path is too long
60for Windows. To check what files are skipped in import, check the recent logs
61for [w3c-test-autoroller
62builder](https://build.chromium.org/p/chromium.infra.cron/builders/w3c-test-autoroller).
63
64### Manual import
65
66To pull the latest versions of the tests that are currently being imported, you
67can also directly invoke the
68[wpt-import](../../third_party/WebKit/Tools/Scripts/wpt-import) script.
69
70That script will pull the latest version of the tests from our mirrors of the
71upstream repositories. If any new versions of tests are found, they will be
72committed locally to your local repository. You may then upload the changes.
73
qyearsley9c9781a2017-02-11 00:08:3974### Enabling import for a new directory
75
qyearsley4f0acca42017-01-30 08:18:4376If you wish to add more tests (by un-skipping some of the directories currently
77skipped in `W3CImportExpectations`), you can modify that file locally and commit
qyearsley9c9781a2017-02-11 00:08:3978it, and on the next auto-import, the new tests should be imported.
79
80If you want to import immediately (in order to try the tests out locally, etc)
81you can also run `wpt-import --allow-local-commits`, but this is not required.
qyearsley4f0acca42017-01-30 08:18:4382
foolipdf2a8632017-02-15 15:03:1683## Writing tests
qyearsley4f0acca42017-01-30 08:18:4384
foolipeda32ab2017-02-16 19:21:5885To contribute changes to web-platform-tests, just commit your changes directly
foolipdf2a8632017-02-15 15:03:1686to [LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
qyearsley4f0acca42017-01-30 08:18:4387and the changes will be automatically upstreamed within 24 hours.
88
foolipdf2a8632017-02-15 15:03:1689Changes involving adding, removing or modifying tests can all be upstreamed.
90Any changes outside of
91[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) will not be
92upstreamed, and any changes `*-expected.txt`, `OWNERS`, and `MANIFEST.json`,
93will also not be upstreamed.
rbyers6299b9132017-02-10 18:06:5794
qyearsley4f0acca42017-01-30 08:18:4395Note: if you're adding a new test in `external/wpt`, you'll need to re-generate
96MANIFEST.json manually until [CL 2644783003](https://crrev.com/2644783003) is
97landed. The command to do so is:
98
99```bash
100Tools/Scripts/webkitpy/thirdparty/wpt/wpt/manifest --work \
101 --tests-root=LayoutTests/external/wpt
102```
103
foolip2f198552017-02-24 16:42:35104Note: the `--work` argument is important even if you have no local changes.
105Without it the `manifest` script will try to generate a manifest for all files
106in the Chromium tree and take a very long time.
107See [wpt-tools issue #171](https://github.com/w3c/wpt-tools/issues/171).
108
foolipdf2a8632017-02-15 15:03:16109Most tests are written using testharness.js, see
110[Writing Layout Tests](./writing_layout_tests.md) and
111[Layout Tests Tips](./layout_tests_tips.md) for general guidelines.
qyearsley9c9781a2017-02-11 00:08:39112
foolipdf2a8632017-02-15 15:03:16113### Write tests against specifications
114
foolipeda32ab2017-02-16 19:21:58115Tests in web-platform-tests are expected to match behavior defined by the
foolipdf2a8632017-02-15 15:03:16116relevant specification. In other words, all assertions that a test makes
117should be derived from a specification's normative requirements, and not go
118beyond them. It is often necessary to change the specification to clarify what
119is and isn't required.
120
121When the standards discussion is still ongoing or blocked on some implementation
122successfully shipping the hoped-for behavior, write the tests outside of
123web-platform-tests and upstream them when the specification is finally updated.
124Optionally, it may be possible to write deliberately failing tests against the
125current specification and later update them.
126
127### Tests that require testing APIs
128
129Tests that depend on `internals.*`, `eventSender.*` or other internal testing
130APIs cannot yet be written as part of web-platform-tests.
131
132An alternative is to write manual tests that are automated with scripts from
133[wpt_automation](../../third_party/WebKit/LayoutTests/external/wpt_automation).
134Such tests still require case-by-case automation to run for other browser
135engines, but are more valuable than purely manual tests.
136
137*** note
138TODO(foolip): Figure out and document a more scalable test automation solution.
139***
140
141### Adding new top-level directories
qyearsley9c9781a2017-02-11 00:08:39142
143Entirely new top-level directories should generally be added upstream, since
144that's the only way to add an OWNERS file upstream. After adding a new top-level
145directory upstream, you should add a line for it in `W3CImportExpectations`.
146
foolipdf2a8632017-02-15 15:03:16147Adding the new directory (and `W3CImportExpectations` entry) in Chromium and
148later adding an OWNERS file upstream also works.
149
qyearsley4f0acca42017-01-30 08:18:43150### Will the exported commits be linked to my GitHub profile?
151
152The email you commit with in Chromium will be the author of the commit on
153GitHub. You can [add it as a secondary address on your GitHub
154account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/)
155to link your exported commits to your GitHub profile.
156
157### What if there are conflicts?
158
159This cannot be avoided entirely as the two repositories are independent, but
160should be rare with frequent imports and exports. When it does happen, manual
161intervention will be needed and in non-trivial cases you may be asked to help
162resolve the conflict.
163
164### Direct pull requests
165
foolipeda32ab2017-02-16 19:21:58166It's still possible to make direct pull requests to web-platform-tests, see
167http://web-platform-tests.org/appendix/github-intro.html.
foolipdf2a8632017-02-15 15:03:16168
169## Reviewing tests
170
171Anyone who can review code and tests in Chromium can also review changes in
172[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
173that will be automatically upstreamed. There will be no additional review in
174web-platform-tests as part of the export process.
175
176If upstream reviewers have feedback on the changes, discuss on the pull request
177created during export, and if necessary work on a new pull request to iterate
178until everyone is satisfied.
179
180When reviewing tests, check that they match the relevant specification, which
181may not fully match the implementation. See also
182[Write tests against specifications](#Write-tests-against-specifications).