OLD | NEW |
1 # Writing Layout Tests | 1 # Writing Layout Tests |
2 | 2 |
3 _Layout tests_ is a bit of a misnomer. This term is | 3 _Layout tests_ is a bit of a misnomer. This term is |
4 [a part of our WebKit heritage](https://webkit.org/blog/1452/layout-tests-theory
/), | 4 [a part of our WebKit heritage](https://webkit.org/blog/1452/layout-tests-theory
/), |
5 and we use it to refer to every test that is written as a Web page (HTML, SVG, | 5 and we use it to refer to every test that is written as a Web page (HTML, SVG, |
6 or XHTML) and lives in | 6 or XHTML) and lives in |
7 [third_party/WebKit/LayoutTests/](../../third_party/WebKit/LayoutTests). | 7 [third_party/WebKit/LayoutTests/](../../third_party/WebKit/LayoutTests). |
8 | 8 |
9 [TOC] | 9 [TOC] |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 you're unopinionated and looking for a style guide to follow, the document also | 86 you're unopinionated and looking for a style guide to follow, the document also |
87 suggests some defaults. | 87 suggests some defaults. |
88 | 88 |
89 ## JavaScript Tests | 89 ## JavaScript Tests |
90 | 90 |
91 Whenever possible, the testing criteria should be expressed in JavaScript. The | 91 Whenever possible, the testing criteria should be expressed in JavaScript. The |
92 alternatives, which will be described in future sections, result in slower and | 92 alternatives, which will be described in future sections, result in slower and |
93 less reliable tests. | 93 less reliable tests. |
94 | 94 |
95 All new JavaScript tests should be written using the | 95 All new JavaScript tests should be written using the |
96 [testharness.js](https://github.com/w3c/testharness.js/) testing framework. This | 96 [testharness.js](https://github.com/w3c/web-platform-tests/tree/master/resources
) |
97 framework is used by the tests in the | 97 testing framework. This framework is used by the tests in the |
98 [web-platform-tests](https://github.com/w3c/web-platform-tests) repository, | 98 [web-platform-tests](https://github.com/w3c/web-platform-tests) repository, |
99 which is shared with all the other browser vendors, so `testharness.js` tests | 99 which is shared with all the other browser vendors, so `testharness.js` tests |
100 are more accessible to browser developers. | 100 are more accessible to browser developers. |
101 | 101 |
102 See the [API documentation](https://github.com/w3c/testharness.js/blob/master/do
cs/api.md) | 102 See the [API documentation](http://web-platform-tests.org/writing-tests/testharn
ess-api.html) |
103 for a thorough introduction to `testharness.js`. | 103 for a thorough introduction to `testharness.js`. |
104 | 104 |
105 Layout tests should follow the recommendations of the above documentation. | 105 Layout tests should follow the recommendations of the above documentation. |
106 Furthermore, layout tests should include relevant | 106 Furthermore, layout tests should include relevant |
107 [metadata](http://web-platform-tests.org/writing-tests/css-metadata.html). The | 107 [metadata](http://web-platform-tests.org/writing-tests/css-metadata.html). The |
108 specification URL (in `<link rel="help">`) is almost always relevant, and is | 108 specification URL (in `<link rel="help">`) is almost always relevant, and is |
109 incredibly helpful to a developer who needs to understand the test quickly. | 109 incredibly helpful to a developer who needs to understand the test quickly. |
110 | 110 |
111 Below is a skeleton for a JavaScript test embedded in an HTML page. Note that, | 111 Below is a skeleton for a JavaScript test embedded in an HTML page. Note that, |
112 in order to follow the minimality guideline, the test omits the tags `<html>`, | 112 in order to follow the minimality guideline, the test omits the tags `<html>`, |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 * The `http/` directory hosts tests that require an HTTP server (see above). | 574 * The `http/` directory hosts tests that require an HTTP server (see above). |
575 * The `resources/` subdirectory in every directory contains binary files, such | 575 * The `resources/` subdirectory in every directory contains binary files, such |
576 as media files, and code that is shared by multiple test files. | 576 as media files, and code that is shared by multiple test files. |
577 | 577 |
578 *** note | 578 *** note |
579 Some layout tests consist of a minimal HTML page that references a JavaScript | 579 Some layout tests consist of a minimal HTML page that references a JavaScript |
580 file in `resources/`. Please do not use this pattern for new tests, as it goes | 580 file in `resources/`. Please do not use this pattern for new tests, as it goes |
581 against the minimality principle. JavaScript and CSS files should only live in | 581 against the minimality principle. JavaScript and CSS files should only live in |
582 `resources/` if they are shared by at least two test files. | 582 `resources/` if they are shared by at least two test files. |
583 *** | 583 *** |
OLD | NEW |