Darwin Huang | a8cd3818 | 2019-01-10 11:05:10 | [diff] [blame] | 1 | # Web Tests (formerly known as "Layout Tests" or "LayoutTests") |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 2 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 3 | Web tests are used by Blink to test many components, including but not |
| 4 | limited to layout and rendering. In general, web tests involve loading pages |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 5 | in a test renderer (`content_shell`) and comparing the rendered output or |
| 6 | JavaScript output against an expected output file. |
| 7 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 8 | This document covers running and debugging existing web tests. See the |
| 9 | [Writing Web Tests documentation](./writing_web_tests.md) if you find |
| 10 | yourself writing web tests. |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 11 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 12 | Note that we changed the term "layout tests" to "web tests". |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 13 | Please assume these terms mean the identical stuff. We also call it as |
| 14 | "WebKit tests" and "WebKit layout tests". |
| 15 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 16 | [TOC] |
| 17 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 18 | ## Running Web Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 19 | |
| 20 | ### Initial Setup |
| 21 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 22 | Before you can run the web tests, you need to build the `blink_tests` target |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 23 | to get `content_shell` and all of the other needed binaries. |
| 24 | |
| 25 | ```bash |
kyle Ju | 8f7d38df | 2018-11-26 16:51:22 | [diff] [blame] | 26 | autoninja -C out/Default blink_tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 27 | ``` |
| 28 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 29 | On **Android** (web test support |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 30 | [currently limited to KitKat and earlier](https://crbug.com/567947)) you need to |
| 31 | build and install `content_shell_apk` instead. See also: |
| 32 | [Android Build Instructions](../android_build_instructions.md). |
| 33 | |
| 34 | ```bash |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 35 | autoninja -C out/Default content_shell_apk |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 36 | adb install -r out/Default/apks/ContentShell.apk |
| 37 | ``` |
| 38 | |
| 39 | On **Mac**, you probably want to strip the content_shell binary before starting |
| 40 | the tests. If you don't, you'll have 5-10 running concurrently, all stuck being |
| 41 | examined by the OS crash reporter. This may cause other failures like timeouts |
| 42 | where they normally don't occur. |
| 43 | |
| 44 | ```bash |
| 45 | strip ./xcodebuild/{Debug,Release}/content_shell.app/Contents/MacOS/content_shell |
| 46 | ``` |
| 47 | |
| 48 | ### Running the Tests |
| 49 | |
| 50 | TODO: mention `testing/xvfb.py` |
| 51 | |
| 52 | The test runner script is in |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 53 | `third_party/blink/tools/run_web_tests.py`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 54 | |
| 55 | To specify which build directory to use (e.g. out/Default, out/Release, |
| 56 | out/Debug) you should pass the `-t` or `--target` parameter. For example, to |
| 57 | use the build in `out/Default`, use: |
| 58 | |
| 59 | ```bash |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 60 | python third_party/blink/tools/run_web_tests.py -t Default |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 61 | ``` |
| 62 | |
| 63 | For Android (if your build directory is `out/android`): |
| 64 | |
| 65 | ```bash |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 66 | python third_party/blink/tools/run_web_tests.py -t android --android |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 67 | ``` |
| 68 | |
| 69 | Tests marked as `[ Skip ]` in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 70 | [TestExpectations](../../third_party/blink/web_tests/TestExpectations) |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 71 | won't be run at all, generally because they cause some intractable tool error. |
| 72 | To force one of them to be run, either rename that file or specify the skipped |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 73 | test as the only one on the command line (see below). Read the |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 74 | [Web Test Expectations documentation](./web_test_expectations.md) to learn |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 75 | more about TestExpectations and related files. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 76 | |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 77 | *** promo |
| 78 | Currently only the tests listed in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 79 | [SmokeTests](../../third_party/blink/web_tests/SmokeTests) |
| 80 | are run on the Android bots, since running all web tests takes too long on |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 81 | Android (and may still have some infrastructure issues). Most developers focus |
| 82 | their Blink testing on Linux. We rely on the fact that the Linux and Android |
| 83 | behavior is nearly identical for scenarios outside those covered by the smoke |
| 84 | tests. |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 85 | *** |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 86 | |
| 87 | To run only some of the tests, specify their directories or filenames as |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 88 | arguments to `run_web_tests.py` relative to the web test directory |
| 89 | (`src/third_party/blink/web_tests`). For example, to run the fast form tests, |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 90 | use: |
| 91 | |
| 92 | ```bash |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 93 | python third_party/blink/tools/run_web_tests.py fast/forms |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 94 | ``` |
| 95 | |
| 96 | Or you could use the following shorthand: |
| 97 | |
| 98 | ```bash |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 99 | python third_party/blink/tools/run_web_tests.py fast/fo\* |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 100 | ``` |
| 101 | |
| 102 | *** promo |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 103 | Example: To run the web tests with a debug build of `content_shell`, but only |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 104 | test the SVG tests and run pixel tests, you would run: |
| 105 | |
| 106 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 107 | [python] third_party/blink/tools/run_web_tests.py -t Default svg |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 108 | ``` |
| 109 | *** |
| 110 | |
| 111 | As a final quick-but-less-robust alternative, you can also just use the |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 112 | content_shell executable to run specific tests by using (example on Windows): |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 113 | |
| 114 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 115 | out/Default/content_shell.exe --run-web-tests <url>|<full_test_source_path>|<relative_test_path> |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 116 | ``` |
| 117 | |
| 118 | as in: |
| 119 | |
| 120 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 121 | out/Default/content_shell.exe --run-web-tests \ |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 122 | c:/chrome/src/third_party/blink/web_tests/fast/forms/001.html |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 123 | ``` |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 124 | or |
| 125 | |
| 126 | ```bash |
| 127 | out/Default/content_shell.exe --run-web-tests fast/forms/001.html |
| 128 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 129 | |
| 130 | but this requires a manual diff against expected results, because the shell |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 131 | doesn't do it for you. It also just dumps the text result only (as the dump of |
| 132 | pixels and audio binary data is not human readable). |
| 133 | See [Running Web Tests Using the Content Shell](web_tests_in_content_shell.md] |
| 134 | for more details of running `content_shell`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 135 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 136 | To see a complete list of arguments supported, run: |
| 137 | |
| 138 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 139 | python third_party/blink/tools/run_web_tests.py --help |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 140 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 141 | |
| 142 | *** note |
| 143 | **Linux Note:** We try to match the Windows render tree output exactly by |
| 144 | matching font metrics and widget metrics. If there's a difference in the render |
| 145 | tree output, we should see if we can avoid rebaselining by improving our font |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 146 | metrics. For additional information on Linux web tests, please see |
| 147 | [docs/web_tests_linux.md](../web_tests_linux.md). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 148 | *** |
| 149 | |
| 150 | *** note |
| 151 | **Mac Note:** While the tests are running, a bunch of Appearance settings are |
| 152 | overridden for you so the right type of scroll bars, colors, etc. are used. |
| 153 | Your main display's "Color Profile" is also changed to make sure color |
| 154 | correction by ColorSync matches what is expected in the pixel tests. The change |
| 155 | is noticeable, how much depends on the normal level of correction for your |
| 156 | display. The tests do their best to restore your setting when done, but if |
| 157 | you're left in the wrong state, you can manually reset it by going to |
| 158 | System Preferences → Displays → Color and selecting the "right" value. |
| 159 | *** |
| 160 | |
| 161 | ### Test Harness Options |
| 162 | |
| 163 | This script has a lot of command line flags. You can pass `--help` to the script |
| 164 | to see a full list of options. A few of the most useful options are below: |
| 165 | |
| 166 | | Option | Meaning | |
| 167 | |:----------------------------|:--------------------------------------------------| |
| 168 | | `--debug` | Run the debug build of the test shell (default is release). Equivalent to `-t Debug` | |
| 169 | | `--nocheck-sys-deps` | Don't check system dependencies; this allows faster iteration. | |
| 170 | | `--verbose` | Produce more verbose output, including a list of tests that pass. | |
Xianzhu Wang | cacba48 | 2017-06-05 18:46:43 | [diff] [blame] | 171 | | `--reset-results` | Overwrite the current baselines (`-expected.{png|txt|wav}` files) with actual results, or create new baselines if there are no existing baselines. | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 172 | | `--renderer-startup-dialog` | Bring up a modal dialog before running the test, useful for attaching a debugger. | |
Quinten Yearsley | 17bf9b43 | 2018-01-02 22:02:45 | [diff] [blame] | 173 | | `--fully-parallel` | Run tests in parallel using as many child processes as the system has cores. | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 174 | | `--driver-logging` | Print C++ logs (LOG(WARNING), etc). | |
| 175 | |
| 176 | ## Success and Failure |
| 177 | |
| 178 | A test succeeds when its output matches the pre-defined expected results. If any |
| 179 | tests fail, the test script will place the actual generated results, along with |
| 180 | a diff of the actual and expected results, into |
| 181 | `src/out/Default/layout_test_results/`, and by default launch a browser with a |
| 182 | summary and link to the results/diffs. |
| 183 | |
| 184 | The expected results for tests are in the |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 185 | `src/third_party/blink/web_tests/platform` or alongside their respective |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 186 | tests. |
| 187 | |
| 188 | *** note |
| 189 | Tests which use [testharness.js](https://github.com/w3c/testharness.js/) |
| 190 | do not have expected result files if all test cases pass. |
| 191 | *** |
| 192 | |
| 193 | A test that runs but produces the wrong output is marked as "failed", one that |
| 194 | causes the test shell to crash is marked as "crashed", and one that takes longer |
| 195 | than a certain amount of time to complete is aborted and marked as "timed out". |
| 196 | A row of dots in the script's output indicates one or more tests that passed. |
| 197 | |
| 198 | ## Test expectations |
| 199 | |
| 200 | The |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 201 | [TestExpectations](../../third_party/blink/web_tests/TestExpectations) file (and related |
| 202 | files) contains the list of all known web test failures. See the |
| 203 | [Web Test Expectations documentation](./web_test_expectations.md) for more |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 204 | on this. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 205 | |
| 206 | ## Testing Runtime Flags |
| 207 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 208 | There are two ways to run web tests with additional command-line arguments: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 209 | |
| 210 | * Using `--additional-driver-flag`: |
| 211 | |
| 212 | ```bash |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 213 | python run_web_tests.py --additional-driver-flag=--blocking-repaint |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 214 | ``` |
| 215 | |
| 216 | This tells the test harness to pass `--blocking-repaint` to the |
| 217 | content_shell binary. |
| 218 | |
| 219 | It will also look for flag-specific expectations in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 220 | `web_tests/FlagExpectations/blocking-repaint`, if this file exists. The |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 221 | suppressions in this file override the main TestExpectations file. |
| 222 | |
| 223 | * Using a *virtual test suite* defined in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 224 | [web_tests/VirtualTestSuites](../../third_party/blink/web_tests/VirtualTestSuites). |
| 225 | A virtual test suite runs a subset of web tests under a specific path with |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 226 | additional flags. For example, you could test a (hypothetical) new mode for |
| 227 | repainting using the following virtual test suite: |
| 228 | |
| 229 | ```json |
| 230 | { |
| 231 | "prefix": "blocking_repaint", |
| 232 | "base": "fast/repaint", |
| 233 | "args": ["--blocking-repaint"], |
| 234 | } |
| 235 | ``` |
| 236 | |
| 237 | This will create new "virtual" tests of the form |
Robert Ma | 89dd91d83 | 2017-08-02 18:08:44 | [diff] [blame] | 238 | `virtual/blocking_repaint/fast/repaint/...` which correspond to the files |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 239 | under `web_tests/fast/repaint` and pass `--blocking-repaint` to |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 240 | content_shell when they are run. |
| 241 | |
| 242 | These virtual tests exist in addition to the original `fast/repaint/...` |
| 243 | tests. They can have their own expectations in TestExpectations, and their own |
| 244 | baselines. The test harness will use the non-virtual baselines as a fallback. |
| 245 | However, the non-virtual expectations are not inherited: if |
| 246 | `fast/repaint/foo.html` is marked `[ Fail ]`, the test harness still expects |
| 247 | `virtual/blocking_repaint/fast/repaint/foo.html` to pass. If you expect the |
| 248 | virtual test to also fail, it needs its own suppression. |
| 249 | |
| 250 | The "prefix" value does not have to be unique. This is useful if you want to |
| 251 | run multiple directories with the same flags (but see the notes below about |
| 252 | performance). Using the same prefix for different sets of flags is not |
| 253 | recommended. |
| 254 | |
| 255 | For flags whose implementation is still in progress, virtual test suites and |
| 256 | flag-specific expectations represent two alternative strategies for testing. |
| 257 | Consider the following when choosing between them: |
| 258 | |
| 259 | * The |
| 260 | [waterfall builders](https://dev.chromium.org/developers/testing/chromium-build-infrastructure/tour-of-the-chromium-buildbot) |
| 261 | and [try bots](https://dev.chromium.org/developers/testing/try-server-usage) |
| 262 | will run all virtual test suites in addition to the non-virtual tests. |
| 263 | Conversely, a flag-specific expectations file won't automatically cause the |
| 264 | bots to test your flag - if you want bot coverage without virtual test suites, |
| 265 | you will need to set up a dedicated bot for your flag. |
| 266 | |
| 267 | * Due to the above, virtual test suites incur a performance penalty for the |
| 268 | commit queue and the continuous build infrastructure. This is exacerbated by |
| 269 | the need to restart `content_shell` whenever flags change, which limits |
| 270 | parallelism. Therefore, you should avoid adding large numbers of virtual test |
| 271 | suites. They are well suited to running a subset of tests that are directly |
| 272 | related to the feature, but they don't scale to flags that make deep |
| 273 | architectural changes that potentially impact all of the tests. |
| 274 | |
Jeff Carpenter | 489d402 | 2018-05-15 00:23:00 | [diff] [blame] | 275 | * Note that using wildcards in virtual test path names (e.g. |
| 276 | `virtual/blocking_repaint/fast/repaint/*`) is not supported. |
| 277 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 278 | ## Tracking Test Failures |
| 279 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 280 | All bugs, associated with web test failures must have the |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 281 | [Test-Layout](https://crbug.com/?q=label:Test-Layout) label. Depending on how |
| 282 | much you know about the bug, assign the status accordingly: |
| 283 | |
| 284 | * **Unconfirmed** -- You aren't sure if this is a simple rebaseline, possible |
| 285 | duplicate of an existing bug, or a real failure |
| 286 | * **Untriaged** -- Confirmed but unsure of priority or root cause. |
| 287 | * **Available** -- You know the root cause of the issue. |
| 288 | * **Assigned** or **Started** -- You will fix this issue. |
| 289 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 290 | When creating a new web test bug, please set the following properties: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 291 | |
| 292 | * Components: a sub-component of Blink |
| 293 | * OS: **All** (or whichever OS the failure is on) |
| 294 | * Priority: 2 (1 if it's a crash) |
| 295 | * Type: **Bug** |
| 296 | * Labels: **Test-Layout** |
| 297 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 298 | You can also use the _Layout Test Failure_ template, which pre-sets these |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 299 | labels for you. |
| 300 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 301 | ## Debugging Web Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 302 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 303 | After the web tests run, you should get a summary of tests that pass or |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 304 | fail. If something fails unexpectedly (a new regression), you will get a |
| 305 | `content_shell` window with a summary of the unexpected failures. Or you might |
| 306 | have a failing test in mind to investigate. In any case, here are some steps and |
| 307 | tips for finding the problem. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 308 | |
| 309 | * Take a look at the result. Sometimes tests just need to be rebaselined (see |
| 310 | below) to account for changes introduced in your patch. |
| 311 | * Load the test into a trunk Chrome or content_shell build and look at its |
| 312 | result. (For tests in the http/ directory, start the http server first. |
| 313 | See above. Navigate to `http://localhost:8000/` and proceed from there.) |
| 314 | The best tests describe what they're looking for, but not all do, and |
| 315 | sometimes things they're not explicitly testing are still broken. Compare |
| 316 | it to Safari, Firefox, and IE if necessary to see if it's correct. If |
| 317 | you're still not sure, find the person who knows the most about it and |
| 318 | ask. |
| 319 | * Some tests only work properly in content_shell, not Chrome, because they |
| 320 | rely on extra APIs exposed there. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 321 | * Some tests only work properly when they're run in the web-test |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 322 | framework, not when they're loaded into content_shell directly. The test |
| 323 | should mention that in its visible text, but not all do. So try that too. |
| 324 | See "Running the tests", above. |
| 325 | * If you think the test is correct, confirm your suspicion by looking at the |
| 326 | diffs between the expected result and the actual one. |
| 327 | * Make sure that the diffs reported aren't important. Small differences in |
| 328 | spacing or box sizes are often unimportant, especially around fonts and |
| 329 | form controls. Differences in wording of JS error messages are also |
| 330 | usually acceptable. |
jonross | 2618570 | 2019-04-08 18:54:10 | [diff] [blame^] | 331 | * `python run_web_tests.py path/to/your/test.html` produces a page listing |
| 332 | all test results. Those which fail their expectations will include links |
| 333 | to the expected result, actual result, and diff. These results are saved |
| 334 | to `$root_build_dir/layout-test-results`. |
| 335 | * Alternatively the `--results-directory=path/for/output/` option allows |
| 336 | you to specify an alternative directory for the output to be saved to. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 337 | * If you're still sure it's correct, rebaseline the test (see below). |
| 338 | Otherwise... |
| 339 | * If you're lucky, your test is one that runs properly when you navigate to it |
| 340 | in content_shell normally. In that case, build the Debug content_shell |
| 341 | project, fire it up in your favorite debugger, and load the test file either |
qyearsley | 23599b7 | 2017-02-16 19:10:42 | [diff] [blame] | 342 | from a `file:` URL. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 343 | * You'll probably be starting and stopping the content_shell a lot. In VS, |
| 344 | to save navigating to the test every time, you can set the URL to your |
qyearsley | 23599b7 | 2017-02-16 19:10:42 | [diff] [blame] | 345 | test (`file:` or `http:`) as the command argument in the Debugging section of |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 346 | the content_shell project Properties. |
| 347 | * If your test contains a JS call, DOM manipulation, or other distinctive |
| 348 | piece of code that you think is failing, search for that in the Chrome |
| 349 | solution. That's a good place to put a starting breakpoint to start |
| 350 | tracking down the issue. |
| 351 | * Otherwise, you're running in a standard message loop just like in Chrome. |
| 352 | If you have no other information, set a breakpoint on page load. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 353 | * If your test only works in full web-test mode, or if you find it simpler to |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 354 | debug without all the overhead of an interactive session, start the |
Kent Tamura | cd3ebc4 | 2018-05-16 06:44:22 | [diff] [blame] | 355 | content_shell with the command-line flag `--run-web-tests`, followed by the |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 356 | URL (`file:` or `http:`) to your test. More information about running web tests |
| 357 | in content_shell can be found [here](./web_tests_in_content_shell.md). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 358 | * In VS, you can do this in the Debugging section of the content_shell |
| 359 | project Properties. |
| 360 | * Now you're running with exactly the same API, theme, and other setup that |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 361 | the web tests use. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 362 | * Again, if your test contains a JS call, DOM manipulation, or other |
| 363 | distinctive piece of code that you think is failing, search for that in |
| 364 | the Chrome solution. That's a good place to put a starting breakpoint to |
| 365 | start tracking down the issue. |
| 366 | * If you can't find any better place to set a breakpoint, start at the |
| 367 | `TestShell::RunFileTest()` call in `content_shell_main.cc`, or at |
| 368 | `shell->LoadURL() within RunFileTest()` in `content_shell_win.cc`. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 369 | * Debug as usual. Once you've gotten this far, the failing web test is just a |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 370 | (hopefully) reduced test case that exposes a problem. |
| 371 | |
| 372 | ### Debugging HTTP Tests |
| 373 | |
| 374 | To run the server manually to reproduce/debug a failure: |
| 375 | |
| 376 | ```bash |
Kent Tamura | e81dbff | 2018-04-20 17:35:34 | [diff] [blame] | 377 | cd src/third_party/blink/tools |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 378 | python run_blink_httpd.py |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 379 | ``` |
| 380 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 381 | The web tests are served from `http://127.0.0.1:8000/`. For example, to |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 382 | run the test |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 383 | `web_tests/http/tests/serviceworker/chromium/service-worker-allowed.html`, |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 384 | navigate to |
| 385 | `http://127.0.0.1:8000/serviceworker/chromium/service-worker-allowed.html`. Some |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 386 | tests behave differently if you go to `127.0.0.1` vs. `localhost`, so use |
| 387 | `127.0.0.1`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 388 | |
Kent Tamura | e81dbff | 2018-04-20 17:35:34 | [diff] [blame] | 389 | To kill the server, hit any key on the terminal where `run_blink_httpd.py` is |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 390 | running, use `taskkill` or the Task Manager on Windows, or `killall` or |
| 391 | Activity Monitor on macOS. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 392 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 393 | The test server sets up an alias to the `web_tests/resources` directory. For |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 394 | example, in HTTP tests, you can access the testing framework using |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 395 | `src="/js-test-resources/js-test.js"`. |
| 396 | |
| 397 | ### Tips |
| 398 | |
| 399 | Check https://test-results.appspot.com/ to see how a test did in the most recent |
| 400 | ~100 builds on each builder (as long as the page is being updated regularly). |
| 401 | |
| 402 | A timeout will often also be a text mismatch, since the wrapper script kills the |
| 403 | content_shell before it has a chance to finish. The exception is if the test |
| 404 | finishes loading properly, but somehow hangs before it outputs the bit of text |
| 405 | that tells the wrapper it's done. |
| 406 | |
| 407 | Why might a test fail (or crash, or timeout) on buildbot, but pass on your local |
| 408 | machine? |
| 409 | * If the test finishes locally but is slow, more than 10 seconds or so, that |
| 410 | would be why it's called a timeout on the bot. |
| 411 | * Otherwise, try running it as part of a set of tests; it's possible that a test |
| 412 | one or two (or ten) before this one is corrupting something that makes this |
| 413 | one fail. |
| 414 | * If it consistently works locally, make sure your environment looks like the |
| 415 | one on the bot (look at the top of the stdio for the webkit_tests step to see |
| 416 | all the environment variables and so on). |
| 417 | * If none of that helps, and you have access to the bot itself, you may have to |
| 418 | log in there and see if you can reproduce the problem manually. |
| 419 | |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 420 | ### Debugging DevTools Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 421 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 422 | * Add `debug_devtools=true` to `args.gn` and compile: `autoninja -C out/Default devtools_frontend_resources` |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 423 | > Debug DevTools lets you avoid having to recompile after every change to the DevTools front-end. |
| 424 | * Do one of the following: |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 425 | * Option A) Run from the `chromium/src` folder: |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 426 | `third_party/blink/tools/run_web_tests.sh |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 427 | --additional-driver-flag='--debug-devtools' |
| 428 | --additional-driver-flag='--remote-debugging-port=9222' |
| 429 | --time-out-ms=6000000` |
| 430 | * Option B) If you need to debug an http/tests/inspector test, start httpd |
| 431 | as described above. Then, run content_shell: |
Kent Tamura | cd3ebc4 | 2018-05-16 06:44:22 | [diff] [blame] | 432 | `out/Default/content_shell --debug-devtools --remote-debugging-port=9222 --run-web-tests |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 433 | http://127.0.0.1:8000/path/to/test.html` |
| 434 | * Open `http://localhost:9222` in a stable/beta/canary Chrome, click the single |
| 435 | link to open the devtools with the test loaded. |
| 436 | * In the loaded devtools, set any required breakpoints and execute `test()` in |
| 437 | the console to actually start the test. |
| 438 | |
| 439 | NOTE: If the test is an html file, this means it's a legacy test so you need to add: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 440 | * Add `window.debugTest = true;` to your test code as follows: |
| 441 | |
| 442 | ```javascript |
| 443 | window.debugTest = true; |
| 444 | function test() { |
| 445 | /* TEST CODE */ |
| 446 | } |
Kim Paulhamus | 61d60c3 | 2018-02-09 18:03:49 | [diff] [blame] | 447 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 448 | |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 449 | ## Bisecting Regressions |
| 450 | |
| 451 | You can use [`git bisect`](https://git-scm.com/docs/git-bisect) to find which |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 452 | commit broke (or fixed!) a web test in a fully automated way. Unlike |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 453 | [bisect-builds.py](http://dev.chromium.org/developers/bisect-builds-py), which |
| 454 | downloads pre-built Chromium binaries, `git bisect` operates on your local |
| 455 | checkout, so it can run tests with `content_shell`. |
| 456 | |
| 457 | Bisecting can take several hours, but since it is fully automated you can leave |
| 458 | it running overnight and view the results the next day. |
| 459 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 460 | To set up an automated bisect of a web test regression, create a script like |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 461 | this: |
| 462 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 463 | ```bash |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 464 | #!/bin/bash |
| 465 | |
| 466 | # Exit code 125 tells git bisect to skip the revision. |
| 467 | gclient sync || exit 125 |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 468 | autoninja -C out/Debug -j100 blink_tests || exit 125 |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 469 | |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 470 | third_party/blink/tools/run_web_tests.py -t Debug \ |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 471 | --no-show-results --no-retry-failures \ |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 472 | path/to/web/test.html |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 473 | ``` |
| 474 | |
| 475 | Modify the `out` directory, ninja args, and test name as appropriate, and save |
| 476 | the script in `~/checkrev.sh`. Then run: |
| 477 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 478 | ```bash |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 479 | chmod u+x ~/checkrev.sh # mark script as executable |
| 480 | git bisect start <badrev> <goodrev> |
| 481 | git bisect run ~/checkrev.sh |
| 482 | git bisect reset # quit the bisect session |
| 483 | ``` |
| 484 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 485 | ## Rebaselining Web Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 486 | |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 487 | *** promo |
| 488 | To automatically re-baseline tests across all Chromium platforms, using the |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 489 | buildbot results, see [How to rebaseline](./web_test_expectations.md#How-to-rebaseline). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 490 | Alternatively, to manually run and test and rebaseline it on your workstation, |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 491 | read on. |
| 492 | *** |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 493 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 494 | ```bash |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 495 | cd src/third_party/blink |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 496 | python tools/run_web_tests.py --reset-results foo/bar/test.html |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 497 | ``` |
| 498 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 499 | If there are current expectation files for `web_tests/foo/bar/test.html`, |
Xianzhu Wang | cacba48 | 2017-06-05 18:46:43 | [diff] [blame] | 500 | the above command will overwrite the current baselines at their original |
| 501 | locations with the actual results. The current baseline means the `-expected.*` |
| 502 | file used to compare the actual result when the test is run locally, i.e. the |
Darwin Huang | a8cd3818 | 2019-01-10 11:05:10 | [diff] [blame] | 503 | first file found in the [baseline search path](https://cs.chromium.org/search/?q=port/base.py+baseline_search_path). |
Xianzhu Wang | cacba48 | 2017-06-05 18:46:43 | [diff] [blame] | 504 | |
| 505 | If there are no current baselines, the above command will create new baselines |
| 506 | in the platform-independent directory, e.g. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 507 | `web_tests/foo/bar/test-expected.{txt,png}`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 508 | |
| 509 | When you rebaseline a test, make sure your commit description explains why the |
Xianzhu Wang | cacba48 | 2017-06-05 18:46:43 | [diff] [blame] | 510 | test is being re-baselined. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 511 | |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 512 | ### Rebaselining flag-specific expectations |
| 513 | |
| 514 | Though we prefer the Rebaseline Tool to local rebaselining, the Rebaseline Tool |
| 515 | doesn't support rebaselining flag-specific expectations. |
| 516 | |
| 517 | ```bash |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 518 | cd src/third_party/blink |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 519 | python tools/run_web_tests.py --additional-driver-flag=--enable-flag --reset-results foo/bar/test.html |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 520 | ``` |
| 521 | |
| 522 | New baselines will be created in the flag-specific baselines directory, e.g. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 523 | `web_tests/flag-specific/enable-flag/foo/bar/test-expected.{txt,png}`. |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 524 | |
| 525 | Then you can commit the new baselines and upload the patch for review. |
| 526 | |
| 527 | However, it's difficult for reviewers to review the patch containing only new |
Xianzhu Wang | d063968e | 2017-10-16 16:47:44 | [diff] [blame] | 528 | files. You can follow the steps below for easier review. |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 529 | |
Xianzhu Wang | d063968e | 2017-10-16 16:47:44 | [diff] [blame] | 530 | 1. Copy existing baselines to the flag-specific baselines directory for the |
| 531 | tests to be rebaselined: |
| 532 | ```bash |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 533 | third_party/blink/tools/run_web_tests.py --additional-driver-flag=--enable-flag --copy-baselines foo/bar/test.html |
Xianzhu Wang | d063968e | 2017-10-16 16:47:44 | [diff] [blame] | 534 | ``` |
| 535 | Then add the newly created baseline files, commit and upload the patch. |
| 536 | Note that the above command won't copy baselines for passing tests. |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 537 | |
Xianzhu Wang | d063968e | 2017-10-16 16:47:44 | [diff] [blame] | 538 | 2. Rebaseline the test locally: |
| 539 | ```bash |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 540 | third_party/blink/tools/run_web_tests.py --additional-driver-flag=--enable-flag --reset-results foo/bar/test.html |
Xianzhu Wang | d063968e | 2017-10-16 16:47:44 | [diff] [blame] | 541 | ``` |
| 542 | Commit the changes and upload the patch. |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 543 | |
Xianzhu Wang | d063968e | 2017-10-16 16:47:44 | [diff] [blame] | 544 | 3. Request review of the CL and tell the reviewer to compare the patch sets that |
| 545 | were uploaded in step 1 and step 2 to see the differences of the rebaselines. |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 546 | |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 547 | ## web-platform-tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 548 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 549 | In addition to web tests developed and run just by the Blink team, there is |
foolip | eda32ab | 2017-02-16 19:21:58 | [diff] [blame] | 550 | also a shared test suite, see [web-platform-tests](./web_platform_tests.md). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 551 | |
| 552 | ## Known Issues |
| 553 | |
| 554 | See |
| 555 | [bugs with the component Blink>Infra](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=component%3ABlink%3EInfra) |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 556 | for issues related to Blink tools, include the web test runner. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 557 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 558 | * If QuickTime is not installed, the plugin tests |
| 559 | `fast/dom/object-embed-plugin-scripting.html` and |
| 560 | `plugins/embed-attributes-setting.html` are expected to fail. |