| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 over other mechanisms for structuring asynchronous code. | 263 over other mechanisms for structuring asynchronous code. |
| 264 | 264 |
| 265 *** promo | 265 *** promo |
| 266 The recommendation to prefer `const` and `let` over `var` is currently being | 266 The recommendation to prefer `const` and `let` over `var` is currently being |
| 267 discussed on | 267 discussed on |
| 268 [blink-dev](https://groups.google.com/a/chromium.org/d/topic/blink-dev/XsR6PKRrS
1E/discussion). | 268 [blink-dev](https://groups.google.com/a/chromium.org/d/topic/blink-dev/XsR6PKRrS
1E/discussion). |
| 269 *** | 269 *** |
| 270 | 270 |
| 271 ### Character Encoding | 271 ### Character Encoding |
| 272 | 272 |
| 273 Tests should use the UTF-8 **character encoding**, which should be declared by | 273 🚧 Tests should use the UTF-8 **character encoding**, which should be |
| 274 `<meta charset=utf-8>`. This does not apply when specifically testing encodings. | 274 declared by `<meta charset=utf-8>`. This does not apply when specifically |
| 275 testing encodings. |
| 275 | 276 |
| 276 The `<meta>` tag must be the first child of the document's `<head>` element. In | 277 The `<meta>` tag must be the first child of the document's `<head>` element. In |
| 277 documents that do not have an explicit `<head>`, the `<meta>` tag must follow | 278 documents that do not have an explicit `<head>`, the `<meta>` tag must follow |
| 278 the doctype. | 279 the doctype. |
| 279 | 280 |
| 280 When HTML pages do not explicitly declare a character encoding, browsers | 281 When HTML pages do not explicitly declare a character encoding, browsers |
| 281 determine the encoding using an | 282 determine the encoding using an |
| 282 [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html
#determining-the-character-encoding) | 283 [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html
#determining-the-character-encoding) |
| 283 that will surprise most modern Web developers. Highlights include a default | 284 that will surprise most modern Web developers. Highlights include a default |
| 284 encoding that depends on the user's locale, and non-standardized | 285 encoding that depends on the user's locale, and non-standardized |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 navigate to | 647 navigate to |
| 647 `http://127.0.0.1:8000/serviceworker/chromium/service-worker-allowed.html`. Some | 648 `http://127.0.0.1:8000/serviceworker/chromium/service-worker-allowed.html`. Some |
| 648 tests will behave differently if you go to 127.0.0.1 instead of localhost, so | 649 tests will behave differently if you go to 127.0.0.1 instead of localhost, so |
| 649 use 127.0.0.1. | 650 use 127.0.0.1. |
| 650 | 651 |
| 651 To kill the server, run `run-blink-httpd --server stop`, or just use `taskkill` | 652 To kill the server, run `run-blink-httpd --server stop`, or just use `taskkill` |
| 652 or the Task Manager on Windows, and `killall` or Activity Monitor on MacOS. | 653 or the Task Manager on Windows, and `killall` or Activity Monitor on MacOS. |
| 653 | 654 |
| 654 The test server sets up an alias to the `LayoutTests/resources` directory. In | 655 The test server sets up an alias to the `LayoutTests/resources` directory. In |
| 655 HTTP tests, you can access the testing framework at e.g. | 656 HTTP tests, you can access the testing framework at e.g. |
| 656 `src="/js-test-resources/testharness.js"`. | 657 `src="/resources/testharness.js"`. |
| 657 | 658 |
| 658 TODO: Document [wptserve](http://wptserve.readthedocs.io/) when we are in a | 659 TODO: Document [wptserve](http://wptserve.readthedocs.io/) when we are in a |
| 659 position to use it to run layout tests. | 660 position to use it to run layout tests. |
| 660 | 661 |
| 661 ## Reference Tests (Reftests) | 662 ## Reference Tests (Reftests) |
| 662 | 663 |
| 663 Reference tests, also known as reftests, perform a pixel-by-pixel comparison | 664 Reference tests, also known as reftests, perform a pixel-by-pixel comparison |
| 664 between the rendered image of a test page and the rendered image of a reference | 665 between the rendered image of a test page and the rendered image of a reference |
| 665 page. Most reference tests pass if the two images match, but there are cases | 666 page. Most reference tests pass if the two images match, but there are cases |
| 666 where it is useful to have a test pass when the two images do _not_ match. | 667 where it is useful to have a test pass when the two images do _not_ match. |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 * The `http/` directory hosts tests that require an HTTP server (see above). | 881 * The `http/` directory hosts tests that require an HTTP server (see above). |
| 881 * The `resources/` subdirectory in every directory contains binary files, such | 882 * The `resources/` subdirectory in every directory contains binary files, such |
| 882 as media files, and code that is shared by multiple test files. | 883 as media files, and code that is shared by multiple test files. |
| 883 | 884 |
| 884 *** note | 885 *** note |
| 885 Some layout tests consist of a minimal HTML page that references a JavaScript | 886 Some layout tests consist of a minimal HTML page that references a JavaScript |
| 886 file in `resources/`. Please do not use this pattern for new tests, as it goes | 887 file in `resources/`. Please do not use this pattern for new tests, as it goes |
| 887 against the minimality principle. JavaScript and CSS files should only live in | 888 against the minimality principle. JavaScript and CSS files should only live in |
| 888 `resources/` if they are shared by at least two test files. | 889 `resources/` if they are shared by at least two test files. |
| 889 *** | 890 *** |
| OLD | NEW |