foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 1 | # web-platform-tests |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 2 | |
rbyers | 6299b913 | 2017-02-10 18:06:57 | [diff] [blame] | 3 | Interoperability between browsers is |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 4 | [critical](https://www.chromium.org/blink/platform-predictability) to Chromium's |
| 5 | mission of improving the web. We believe that leveraging and contributing to a |
| 6 | shared test suite is one of the most important tools in achieving |
| 7 | interoperability between browsers. The [web-platform-tests |
rbyers | 6299b913 | 2017-02-10 18:06:57 | [diff] [blame] | 8 | repository](https://github.com/w3c/web-platform-tests) is the primary shared |
Quinten Yearsley | fab627a | 2017-03-29 22:30:18 | [diff] [blame] | 9 | test suite where all browser engines are collaborating. |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 10 | |
Jeff Carpenter | abd1360 | 2017-03-29 22:49:59 | [diff] [blame] | 11 | Chromium has a 2-way import/export process with the upstream web-platform-tests |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 12 | repository, where tests are imported into |
| 13 | [LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) |
| 14 | and any changes to the imported tests are also exported to web-platform-tests. |
| 15 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 16 | See http://web-platform-tests.org/ for general documentation on |
| 17 | web-platform-tests, including tips for writing and reviewing tests. |
| 18 | |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 19 | [TOC] |
| 20 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 21 | ## Importing tests |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 22 | |
Quinten Yearsley | fab627a | 2017-03-29 22:30:18 | [diff] [blame] | 23 | Chromium has a mirror |
| 24 | ([web-platform-tests](https://chromium.googlesource.com/external/w3c/web-platform-tests/) |
| 25 | of the |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 26 | GitHub repos, and periodically imports a subset of the tests so that they are |
| 27 | run as part of the regular Blink layout test testing process. |
| 28 | |
raphael.kubo.da.costa | 21ed71a | 2017-04-12 10:50:44 | [diff] [blame] | 29 | The goals of this process are to be able to run web-platform-tests unmodified |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 30 | locally just as easily as we can run the Blink tests, and ensure that we are |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 31 | tracking tip-of-tree in the web-platform-tests repository as closely as |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 32 | possible, and running as many of the tests as possible. |
| 33 | |
| 34 | ### Automatic import process |
| 35 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 36 | There is an automatic process for updating the Chromium copy of |
Quinten Yearsley | fab627a | 2017-03-29 22:30:18 | [diff] [blame] | 37 | web-platform-tests. The import is done by the builder [wpt-importer |
| 38 | builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer). |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 39 | |
| 40 | The easiest way to check the status of recent imports is to look at: |
| 41 | |
Quinten Yearsley | fab627a | 2017-03-29 22:30:18 | [diff] [blame] | 42 | - Recent logs on Buildbot for [wpt-importer |
| 43 | builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer) |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 44 | - Recent CLs created by |
| 45 | [[email protected]](https://codereview.chromium.org/search?owner=blink-w3c-test-autoroller%40chromium.org). |
| 46 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 47 | Automatic imports are intended to run at least once every 24 hours. |
| 48 | |
Quinten Yearsley | 12a15b7 | 2017-06-05 21:51:23 | [diff] [blame] | 49 | ### Failures caused by automatic imports. |
| 50 | |
| 51 | If there are new test failures that start after an auto-import, |
| 52 | there 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 | |
| 58 | Because these tests are imported from the Web Platform tests, it is better |
| 59 | to have them in the repository (and marked failing) than not, so prefer to |
| 60 | [add test expectations](layout_test_expectations.md) rather than reverting. |
| 61 | However, if a huge number of tests are failing, please revert the CL so we |
| 62 | can fix it manually. |
| 63 | |
Jeff Carpenter | abd1360 | 2017-03-29 22:49:59 | [diff] [blame] | 64 | ### Automatic export process |
| 65 | |
| 66 | If a commit to Chromium master changes any files in the |
| 67 | [third_party/WebKit/LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) |
| 68 | directory, the WPT Exporter will create a Pull Request on GitHub for it. |
| 69 | All 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). |
| 71 | The exporter runs continuously under the chromium.infra.cron master: |
| 72 | see [all recent builds](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-exporter). |
| 73 | The source for the exporter lives in |
| 74 | [third_party/WebKit/Tools/Scripts/wpt-exporter](../../third_party/WebKit/Tools/Scripts/wpt-exporter). |
| 75 | |
| 76 | In the unlikely event that the exporter starts misbehaving -- for example, |
| 77 | creating the same PR over and over again -- **all you need to do to disable the |
| 78 | exporter is [land this CL](https://chromium-review.googlesource.com/c/462381/)**, |
| 79 | which will put it in "dry run" mode. |
| 80 | |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 81 | ### Skipped tests |
| 82 | |
| 83 | We control which tests are imported via a file called |
| 84 | [W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations), |
| 85 | which has a list of directories to skip while importing. |
| 86 | |
| 87 | In addition to the directories and tests explicitly skipped there, tests may |
| 88 | also be skipped for a couple other reasons, e.g. if the file path is too long |
| 89 | for Windows. To check what files are skipped in import, check the recent logs |
Quinten Yearsley | fab627a | 2017-03-29 22:30:18 | [diff] [blame] | 90 | for [wpt-importer |
| 91 | builder](https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer). |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 92 | |
| 93 | ### Manual import |
| 94 | |
| 95 | To pull the latest versions of the tests that are currently being imported, you |
| 96 | can also directly invoke the |
| 97 | [wpt-import](../../third_party/WebKit/Tools/Scripts/wpt-import) script. |
| 98 | |
| 99 | That script will pull the latest version of the tests from our mirrors of the |
| 100 | upstream repositories. If any new versions of tests are found, they will be |
| 101 | committed locally to your local repository. You may then upload the changes. |
| 102 | |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 103 | ### Enabling import for a new directory |
| 104 | |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 105 | If you wish to add more tests (by un-skipping some of the directories currently |
| 106 | skipped in `W3CImportExpectations`), you can modify that file locally and commit |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 107 | it, and on the next auto-import, the new tests should be imported. |
| 108 | |
| 109 | If you want to import immediately (in order to try the tests out locally, etc) |
| 110 | you can also run `wpt-import --allow-local-commits`, but this is not required. |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 111 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 112 | ## Writing tests |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 113 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 114 | To contribute changes to web-platform-tests, just commit your changes directly |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 115 | to [LayoutTests/external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 116 | and the changes will be automatically upstreamed within 24 hours. |
| 117 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 118 | Changes involving adding, removing or modifying tests can all be upstreamed. |
| 119 | Any changes outside of |
| 120 | [external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) will not be |
| 121 | upstreamed, and any changes `*-expected.txt`, `OWNERS`, and `MANIFEST.json`, |
| 122 | will also not be upstreamed. |
rbyers | 6299b913 | 2017-02-10 18:06:57 | [diff] [blame] | 123 | |
Jeff Carpenter | eb1ff6b | 2017-03-02 23:21:58 | [diff] [blame] | 124 | Running the layout tests will automatically regenerate MANIFEST.json to pick up |
| 125 | any local modifications. |
foolip | 2f19855 | 2017-02-24 16:42:35 | [diff] [blame] | 126 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 127 | Most 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. |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 130 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 131 | ### Write tests against specifications |
| 132 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 133 | Tests in web-platform-tests are expected to match behavior defined by the |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 134 | relevant specification. In other words, all assertions that a test makes |
| 135 | should be derived from a specification's normative requirements, and not go |
| 136 | beyond them. It is often necessary to change the specification to clarify what |
| 137 | is and isn't required. |
| 138 | |
| 139 | When the standards discussion is still ongoing or blocked on some implementation |
| 140 | successfully shipping the hoped-for behavior, write the tests outside of |
| 141 | web-platform-tests and upstream them when the specification is finally updated. |
| 142 | Optionally, it may be possible to write deliberately failing tests against the |
| 143 | current specification and later update them. |
| 144 | |
| 145 | ### Tests that require testing APIs |
| 146 | |
| 147 | Tests that depend on `internals.*`, `eventSender.*` or other internal testing |
| 148 | APIs cannot yet be written as part of web-platform-tests. |
| 149 | |
| 150 | An alternative is to write manual tests that are automated with scripts from |
| 151 | [wpt_automation](../../third_party/WebKit/LayoutTests/external/wpt_automation). |
Quinten Yearsley | e577029f | 2017-07-06 00:21:03 | [diff] [blame^] | 152 | Injection of JS in manual tests is determined by `loadAutomationScript` in |
| 153 | [testharnessreport.js](../../third_party/WebKit/LayoutTests/resources/testharnessreport.js). |
| 154 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 155 | Such tests still require case-by-case automation to run for other browser |
| 156 | engines, but are more valuable than purely manual tests. |
| 157 | |
Quinten Yearsley | e577029f | 2017-07-06 00:21:03 | [diff] [blame^] | 158 | Manual 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 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 162 | *** note |
| 163 | TODO(foolip): Figure out and document a more scalable test automation solution. |
| 164 | *** |
| 165 | |
| 166 | ### Adding new top-level directories |
qyearsley | 9c9781a | 2017-02-11 00:08:39 | [diff] [blame] | 167 | |
| 168 | Entirely new top-level directories should generally be added upstream, since |
| 169 | that's the only way to add an OWNERS file upstream. After adding a new top-level |
| 170 | directory upstream, you should add a line for it in `W3CImportExpectations`. |
| 171 | |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 172 | Adding the new directory (and `W3CImportExpectations` entry) in Chromium and |
| 173 | later adding an OWNERS file upstream also works. |
| 174 | |
qyearsley | 4f0acca4 | 2017-01-30 08:18:43 | [diff] [blame] | 175 | ### Will the exported commits be linked to my GitHub profile? |
| 176 | |
| 177 | The email you commit with in Chromium will be the author of the commit on |
| 178 | GitHub. You can [add it as a secondary address on your GitHub |
| 179 | account](https://help.github.com/articles/adding-an-email-address-to-your-github-account/) |
| 180 | to link your exported commits to your GitHub profile. |
| 181 | |
| 182 | ### What if there are conflicts? |
| 183 | |
| 184 | This cannot be avoided entirely as the two repositories are independent, but |
| 185 | should be rare with frequent imports and exports. When it does happen, manual |
| 186 | intervention will be needed and in non-trivial cases you may be asked to help |
| 187 | resolve the conflict. |
| 188 | |
| 189 | ### Direct pull requests |
| 190 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 191 | It's still possible to make direct pull requests to web-platform-tests, see |
| 192 | http://web-platform-tests.org/appendix/github-intro.html. |
foolip | df2a863 | 2017-02-15 15:03:16 | [diff] [blame] | 193 | |
| 194 | ## Reviewing tests |
| 195 | |
| 196 | Anyone who can review code and tests in Chromium can also review changes in |
| 197 | [external/wpt](../../third_party/WebKit/LayoutTests/external/wpt) |
| 198 | that will be automatically upstreamed. There will be no additional review in |
| 199 | web-platform-tests as part of the export process. |
| 200 | |
| 201 | If upstream reviewers have feedback on the changes, discuss on the pull request |
| 202 | created during export, and if necessary work on a new pull request to iterate |
| 203 | until everyone is satisfied. |
| 204 | |
| 205 | When reviewing tests, check that they match the relevant specification, which |
| 206 | may not fully match the implementation. See also |
| 207 | [Write tests against specifications](#Write-tests-against-specifications). |