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