blob: 063ca3e368c56b00c7f0f38e6008476a25015ccc [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
Jeff Carpentereb1ff6b2017-03-02 23:21:5895Running the layout tests will automatically regenerate MANIFEST.json to pick up
96any local modifications.
foolip2f198552017-02-24 16:42:3597
foolipdf2a8632017-02-15 15:03:1698Most tests are written using testharness.js, see
99[Writing Layout Tests](./writing_layout_tests.md) and
100[Layout Tests Tips](./layout_tests_tips.md) for general guidelines.
qyearsley9c9781a2017-02-11 00:08:39101
foolipdf2a8632017-02-15 15:03:16102### Write tests against specifications
103
foolipeda32ab2017-02-16 19:21:58104Tests in web-platform-tests are expected to match behavior defined by the
foolipdf2a8632017-02-15 15:03:16105relevant specification. In other words, all assertions that a test makes
106should be derived from a specification's normative requirements, and not go
107beyond them. It is often necessary to change the specification to clarify what
108is and isn't required.
109
110When the standards discussion is still ongoing or blocked on some implementation
111successfully shipping the hoped-for behavior, write the tests outside of
112web-platform-tests and upstream them when the specification is finally updated.
113Optionally, it may be possible to write deliberately failing tests against the
114current specification and later update them.
115
116### Tests that require testing APIs
117
118Tests that depend on `internals.*`, `eventSender.*` or other internal testing
119APIs cannot yet be written as part of web-platform-tests.
120
121An alternative is to write manual tests that are automated with scripts from
122[wpt_automation](../../third_party/WebKit/LayoutTests/external/wpt_automation).
123Such tests still require case-by-case automation to run for other browser
124engines, but are more valuable than purely manual tests.
125
126*** note
127TODO(foolip): Figure out and document a more scalable test automation solution.
128***
129
130### Adding new top-level directories
qyearsley9c9781a2017-02-11 00:08:39131
132Entirely new top-level directories should generally be added upstream, since
133that's the only way to add an OWNERS file upstream. After adding a new top-level
134directory upstream, you should add a line for it in `W3CImportExpectations`.
135
foolipdf2a8632017-02-15 15:03:16136Adding the new directory (and `W3CImportExpectations` entry) in Chromium and
137later adding an OWNERS file upstream also works.
138
qyearsley4f0acca42017-01-30 08:18:43139### Will the exported commits be linked to my GitHub profile?
140
141The email you commit with in Chromium will be the author of the commit on
142GitHub. You can [add it as a secondary address on your GitHub
143account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/)
144to link your exported commits to your GitHub profile.
145
146### What if there are conflicts?
147
148This cannot be avoided entirely as the two repositories are independent, but
149should be rare with frequent imports and exports. When it does happen, manual
150intervention will be needed and in non-trivial cases you may be asked to help
151resolve the conflict.
152
153### Direct pull requests
154
foolipeda32ab2017-02-16 19:21:58155It's still possible to make direct pull requests to web-platform-tests, see
156http://web-platform-tests.org/appendix/github-intro.html.
foolipdf2a8632017-02-15 15:03:16157
158## Reviewing tests
159
160Anyone who can review code and tests in Chromium can also review changes in
161[external/wpt](../../third_party/WebKit/LayoutTests/external/wpt)
162that will be automatically upstreamed. There will be no additional review in
163web-platform-tests as part of the export process.
164
165If upstream reviewers have feedback on the changes, discuss on the pull request
166created during export, and if necessary work on a new pull request to iterate
167until everyone is satisfied.
168
169When reviewing tests, check that they match the relevant specification, which
170may not fully match the implementation. See also
171[Write tests against specifications](#Write-tests-against-specifications).