| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 a last resort. | 220 a last resort. |
| 221 | 221 |
| 222 A downside of Blink-specific APIs is that they are not as well documented as the | 222 A downside of Blink-specific APIs is that they are not as well documented as the |
| 223 Web Platform features. Learning to use a Blink-specific feature requires finding | 223 Web Platform features. Learning to use a Blink-specific feature requires finding |
| 224 other tests that use it, or reading its source code. | 224 other tests that use it, or reading its source code. |
| 225 | 225 |
| 226 For example, the most popular Blink-specific API is `testRunner`, which is | 226 For example, the most popular Blink-specific API is `testRunner`, which is |
| 227 implemented in | 227 implemented in |
| 228 [components/test_runner/test_runner.h](../../components/test_runner/test_runner.
h) | 228 [components/test_runner/test_runner.h](../../components/test_runner/test_runner.
h) |
| 229 and | 229 and |
| 230 [components/test_runner/test_runner.cpp](../../components/test_runner/test_runne
r.cpp). | 230 [components/test_runner/test_runner.cc](../../components/test_runner/test_runner
.cc). |
| 231 By skimming the `TestRunnerBindings::Install` method, we learn that the | 231 By skimming the `TestRunnerBindings::Install` method, we learn that the |
| 232 testRunner API is presented by the `window.testRunner` and | 232 testRunner API is presented by the `window.testRunner` and |
| 233 `window.layoutTestsController` objects, which are synonyms. Reading the | 233 `window.layoutTestsController` objects, which are synonyms. Reading the |
| 234 `TestRunnerBindings::GetObjectTemplateBuilder` method tells us what properties | 234 `TestRunnerBindings::GetObjectTemplateBuilder` method tells us what properties |
| 235 are available on the `window.testRunner` object. | 235 are available on the `window.testRunner` object. |
| 236 | 236 |
| 237 *** aside | 237 *** aside |
| 238 `window.testRunner` is the preferred way to access the `testRunner` APIs. | 238 `window.testRunner` is the preferred way to access the `testRunner` APIs. |
| 239 `window.layoutTestsController` is still supported because it is used by | 239 `window.layoutTestsController` is still supported because it is used by |
| 240 3rd-party tests. | 240 3rd-party tests. |
| 241 *** | 241 *** |
| 242 | 242 |
| 243 *** note | 243 *** note |
| 244 `testRunner` is the most popular testing API because it is also used indirectly | 244 `testRunner` is the most popular testing API because it is also used indirectly |
| 245 by tests that stick to Web Platform APIs. The `testharnessreport.js` file in | 245 by tests that stick to Web Platform APIs. The `testharnessreport.js` file in |
| 246 `testharness.js` is specifically designated to hold glue code that connects | 246 `testharness.js` is specifically designated to hold glue code that connects |
| 247 `testharness.js` to the testing environment. Our implementation is in | 247 `testharness.js` to the testing environment. Our implementation is in |
| 248 [third_party/WebKit/LayoutTests/resources/testharnessreport.js](../../third_part
y/WebKit/LayoutTests/resources/testharnessreport.js), | 248 [third_party/WebKit/LayoutTests/resources/testharnessreport.js](../../third_part
y/WebKit/LayoutTests/resources/testharnessreport.js), |
| 249 and uses the `testRunner` API. | 249 and uses the `testRunner` API. |
| 250 *** | 250 *** |
| 251 | 251 |
| 252 See the [components/test_runner/](../../components/test_runner/) directory and | 252 See the [components/test_runner/](../../components/test_runner/) directory and |
| 253 [WebKit's LayoutTests guide](https://trac.webkit.org/wiki/Writing%20Layout%20Tes
ts%20for%20DumpRenderTree) | 253 [WebKit's LayoutTests guide](https://trac.webkit.org/wiki/Writing%20Layout%20Tes
ts%20for%20DumpRenderTree) |
| 254 for other useful APIs. For example, `window.eventSender` | 254 for other useful APIs. For example, `window.eventSender` |
| 255 ([components/test_runner/event_sender.h](../../components/test_runner/event_send
er.h) | 255 ([components/test_runner/event_sender.h](../../components/test_runner/event_send
er.h) |
| 256 and | 256 and |
| 257 [components/test_runner/event_sender.cpp](../../components/test_runner/event_sen
der.cpp)) | 257 [components/test_runner/event_sender.cc](../../components/test_runner/event_send
er.cc)) |
| 258 has methods that simulate events input such as keyboard / mouse input and | 258 has methods that simulate events input such as keyboard / mouse input and |
| 259 drag-and-drop. | 259 drag-and-drop. |
| 260 | 260 |
| 261 Here is a UML diagram of how the `testRunner` bindings fit into Chromium. | 261 Here is a UML diagram of how the `testRunner` bindings fit into Chromium. |
| 262 | 262 |
| 263 [](https://docs.google
.com/drawings/d/1KNRNjlxK0Q3Tp8rKxuuM5mpWf4OJQZmvm9_kpwu_Wwg/edit) | 263 [](https://docs.google
.com/drawings/d/1KNRNjlxK0Q3Tp8rKxuuM5mpWf4OJQZmvm9_kpwu_Wwg/edit) |
| 264 | 264 |
| 265 ### Text Test Baselines | 265 ### Text Test Baselines |
| 266 | 266 |
| 267 By default, all the test cases in a file that uses `testharness.js` are expected | 267 By default, all the test cases in a file that uses `testharness.js` are expected |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 * The `http/` directory hosts tests that require an HTTP server (see above). | 575 * The `http/` directory hosts tests that require an HTTP server (see above). |
| 576 * The `resources/` subdirectory in every directory contains binary files, such | 576 * The `resources/` subdirectory in every directory contains binary files, such |
| 577 as media files, and code that is shared by multiple test files. | 577 as media files, and code that is shared by multiple test files. |
| 578 | 578 |
| 579 *** note | 579 *** note |
| 580 Some layout tests consist of a minimal HTML page that references a JavaScript | 580 Some layout tests consist of a minimal HTML page that references a JavaScript |
| 581 file in `resources/`. Please do not use this pattern for new tests, as it goes | 581 file in `resources/`. Please do not use this pattern for new tests, as it goes |
| 582 against the minimality principle. JavaScript and CSS files should only live in | 582 against the minimality principle. JavaScript and CSS files should only live in |
| 583 `resources/` if they are shared by at least two test files. | 583 `resources/` if they are shared by at least two test files. |
| 584 *** | 584 *** |
| OLD | NEW |