blob: db6d6dc2d5d896c3639504e78159bd3d9024c257 [file] [log] [blame] [view]
Darwin Huanga8cd38182019-01-10 11:05:101# Web Tests (formerly known as "Layout Tests" or "LayoutTests")
pwnallae101a5f2016-11-08 00:24:382
Kent Tamura59ffb022018-11-27 05:30:563Web tests are used by Blink to test many components, including but not
4limited to layout and rendering. In general, web tests involve loading pages
pwnallae101a5f2016-11-08 00:24:385in a test renderer (`content_shell`) and comparing the rendered output or
6JavaScript output against an expected output file.
7
Kent Tamura59ffb022018-11-27 05:30:568This document covers running and debugging existing web tests. See the
9[Writing Web Tests documentation](./writing_web_tests.md) if you find
10yourself writing web tests.
pwnall4ea2eb32016-11-29 02:47:2511
Kent Tamura59ffb022018-11-27 05:30:5612Note that we changed the term "layout tests" to "web tests".
Kent Tamuraa045a7f2018-04-25 05:08:1113Please assume these terms mean the identical stuff. We also call it as
14"WebKit tests" and "WebKit layout tests".
15
Matt Falkenhagencef09742020-01-06 05:43:3816["Web platform tests"](./web_platform_tests.md) (WPT) are the preferred form of
17web tests and are located at
18[web_tests/external/wpt](/third_party/blink/web_tests/external/wpt).
19Tests that should work across browsers go there. Other directories are for
20Chrome-specific tests only.
21
Yoshisato Yanagisawa638e2ee02021-12-09 05:52:0822Note: if you are looking for a guide for the Web Platform Test, you should read
23["Web platform tests"](./web_platform_tests.md) (WPT). This document does not
24cover WPT specific features/behaviors.
25
Weizhong Xiabe863d722023-11-01 22:36:1526Note: if you are looking for a guide for running the Web Platform Tests with
27Chrome, Chrome Android or WebView, you should read ["Running Web Platform Tests with run_wpt_tests.py"](./run_web_platform_tests.md).
28
pwnallae101a5f2016-11-08 00:24:3829[TOC]
30
Kent Tamura59ffb022018-11-27 05:30:5631## Running Web Tests
pwnallae101a5f2016-11-08 00:24:3832
Stephen McGruer7878d062021-01-15 20:23:2033### Supported Platforms
34
35* Linux
36* MacOS
37* Windows
38* Fuchsia
39
40Android is [not supported](https://crbug.com/567947).
41
pwnallae101a5f2016-11-08 00:24:3842### Initial Setup
43
Kent Tamura59ffb022018-11-27 05:30:5644Before you can run the web tests, you need to build the `blink_tests` target
pwnallae101a5f2016-11-08 00:24:3845to get `content_shell` and all of the other needed binaries.
46
47```bash
kyle Ju8f7d38df2018-11-26 16:51:2248autoninja -C out/Default blink_tests
pwnallae101a5f2016-11-08 00:24:3849```
50
pwnallae101a5f2016-11-08 00:24:3851On **Mac**, you probably want to strip the content_shell binary before starting
52the tests. If you don't, you'll have 5-10 running concurrently, all stuck being
53examined by the OS crash reporter. This may cause other failures like timeouts
54where they normally don't occur.
55
56```bash
Fangzhen Song2f09f202021-09-17 23:56:4357strip ./out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell
pwnallae101a5f2016-11-08 00:24:3858```
59
60### Running the Tests
61
Robert Ma7ed16792020-06-16 16:38:5262The test runner script is in `third_party/blink/tools/run_web_tests.py`.
pwnallae101a5f2016-11-08 00:24:3863
Dirk Pranke341ad9c2021-09-01 20:42:5764To specify which build directory to use (e.g. out/Default, etc.)
Jocelyn Trancfb81012022-08-05 17:39:4565you should pass the `-t` or `--target` parameter. If no directory is specified,
Thiago Perrottae7e240c2023-07-14 18:37:5766`out/Release` will be used. To use the built-in `out/Default`, use:
pwnallae101a5f2016-11-08 00:24:3867
68```bash
Robert Ma7ed16792020-06-16 16:38:5269third_party/blink/tools/run_web_tests.py -t Default
pwnallae101a5f2016-11-08 00:24:3870```
71
Robert Ma7ed16792020-06-16 16:38:5272*** promo
Gabriel Charette45cbb4a72021-03-19 15:08:1273* Windows users need to use `third_party\blink\tools\run_web_tests.bat` instead.
Robert Macca3b252020-11-23 20:11:3674* Linux users should not use `testing/xvfb.py`; `run_web_tests.py` manages Xvfb
75 itself.
Robert Ma7ed16792020-06-16 16:38:5276***
77
pwnallae101a5f2016-11-08 00:24:3878Tests marked as `[ Skip ]` in
Kent Tamura59ffb022018-11-27 05:30:5679[TestExpectations](../../third_party/blink/web_tests/TestExpectations)
Xianzhu Wang15355b22019-11-02 23:20:0280won't be run by default, generally because they cause some intractable tool error.
pwnallae101a5f2016-11-08 00:24:3881To force one of them to be run, either rename that file or specify the skipped
Xianzhu Wang15355b22019-11-02 23:20:0282test on the command line (see below) or in a file specified with --test-list
83(however, --skip=always can make the tests marked as `[ Skip ]` always skipped).
84Read the [Web Test Expectations documentation](./web_test_expectations.md) to
85learn more about TestExpectations and related files.
pwnallae101a5f2016-11-08 00:24:3886
pwnall4ea2eb32016-11-29 02:47:2587*** promo
88Currently only the tests listed in
An Sung65d9eab2023-07-26 01:38:4389[Default.txt](../../third_party/blink/web_tests/TestLists/Default.txt) are run
Weizhong Xiaa33c6162022-05-03 02:11:2790on the Fuchsia bots, since running all web tests takes too long on Fuchshia.
91Most developers focus their Blink testing on Linux. We rely on the fact that the
Stephen McGruer7878d062021-01-15 20:23:2092Linux and Fuchsia behavior is nearly identical for scenarios outside those
93covered by the smoke tests.
pwnall4ea2eb32016-11-29 02:47:2594***
pwnallae101a5f2016-11-08 00:24:3895
Weizhong Xiaa33c6162022-05-03 02:11:2796*** promo
97Similar to Fuchsia's case, the tests listed in [Mac.txt]
An Sung65d9eab2023-07-26 01:38:4398(../../third_party/blink/web_tests/TestLists/Mac.txt)
Weizhong Xiaa33c6162022-05-03 02:11:2799are run on older mac version bots. By doing this we reduced the resources needed to run
100the tests. This relies on the fact that the majority of web tests will behavior similarly on
101different mac versions.
102***
103
pwnallae101a5f2016-11-08 00:24:38104To run only some of the tests, specify their directories or filenames as
Kent Tamura59ffb022018-11-27 05:30:56105arguments to `run_web_tests.py` relative to the web test directory
106(`src/third_party/blink/web_tests`). For example, to run the fast form tests,
pwnallae101a5f2016-11-08 00:24:38107use:
108
109```bash
Robert Ma7ed16792020-06-16 16:38:52110third_party/blink/tools/run_web_tests.py fast/forms
pwnallae101a5f2016-11-08 00:24:38111```
112
113Or you could use the following shorthand:
114
115```bash
Robert Ma7ed16792020-06-16 16:38:52116third_party/blink/tools/run_web_tests.py fast/fo\*
pwnallae101a5f2016-11-08 00:24:38117```
118
119*** promo
Kent Tamura59ffb022018-11-27 05:30:56120Example: To run the web tests with a debug build of `content_shell`, but only
pwnallae101a5f2016-11-08 00:24:38121test the SVG tests and run pixel tests, you would run:
122
123```bash
Robert Ma7ed16792020-06-16 16:38:52124third_party/blink/tools/run_web_tests.py -t Default svg
pwnallae101a5f2016-11-08 00:24:38125```
126***
127
128As a final quick-but-less-robust alternative, you can also just use the
Xianzhu Wang0a37e9d2019-03-27 21:27:29129content_shell executable to run specific tests by using (example on Windows):
pwnallae101a5f2016-11-08 00:24:38130
131```bash
Xianzhu Wang61d49d52021-07-31 16:44:53132out\Default\content_shell.exe --run-web-tests <url>|<full_test_source_path>|<relative_test_path>
pwnallae101a5f2016-11-08 00:24:38133```
134
135as in:
136
137```bash
Xianzhu Wang61d49d52021-07-31 16:44:53138out\Default\content_shell.exe --run-web-tests \
139 c:\chrome\src\third_party\blink\web_tests\fast\forms\001.html
pwnallae101a5f2016-11-08 00:24:38140```
Xianzhu Wang0a37e9d2019-03-27 21:27:29141or
142
143```bash
Xianzhu Wang61d49d52021-07-31 16:44:53144out\Default\content_shell.exe --run-web-tests fast\forms\001.html
Xianzhu Wang0a37e9d2019-03-27 21:27:29145```
pwnallae101a5f2016-11-08 00:24:38146
147but this requires a manual diff against expected results, because the shell
Xianzhu Wang0a37e9d2019-03-27 21:27:29148doesn't do it for you. It also just dumps the text result only (as the dump of
149pixels and audio binary data is not human readable).
Jeonghee Ahn2cbb9cb2019-09-23 02:52:57150See [Running Web Tests Using the Content Shell](./web_tests_in_content_shell.md)
Xianzhu Wang0a37e9d2019-03-27 21:27:29151for more details of running `content_shell`.
pwnallae101a5f2016-11-08 00:24:38152
Mathias Bynens172fc6b2018-09-05 09:39:43153To see a complete list of arguments supported, run:
154
155```bash
Robert Ma7ed16792020-06-16 16:38:52156third_party/blink/tools/run_web_tests.py --help
Mathias Bynens172fc6b2018-09-05 09:39:43157```
pwnallae101a5f2016-11-08 00:24:38158
159*** note
160**Linux Note:** We try to match the Windows render tree output exactly by
161matching font metrics and widget metrics. If there's a difference in the render
162tree output, we should see if we can avoid rebaselining by improving our font
Kent Tamura59ffb022018-11-27 05:30:56163metrics. For additional information on Linux web tests, please see
Jeonghee Ahn2cbb9cb2019-09-23 02:52:57164[docs/web_tests_linux.md](./web_tests_linux.md).
pwnallae101a5f2016-11-08 00:24:38165***
166
167*** note
168**Mac Note:** While the tests are running, a bunch of Appearance settings are
169overridden for you so the right type of scroll bars, colors, etc. are used.
170Your main display's "Color Profile" is also changed to make sure color
171correction by ColorSync matches what is expected in the pixel tests. The change
172is noticeable, how much depends on the normal level of correction for your
173display. The tests do their best to restore your setting when done, but if
174you're left in the wrong state, you can manually reset it by going to
175System Preferences → Displays → Color and selecting the "right" value.
176***
177
178### Test Harness Options
179
180This script has a lot of command line flags. You can pass `--help` to the script
181to see a full list of options. A few of the most useful options are below:
182
183| Option | Meaning |
184|:----------------------------|:--------------------------------------------------|
185| `--debug` | Run the debug build of the test shell (default is release). Equivalent to `-t Debug` |
186| `--nocheck-sys-deps` | Don't check system dependencies; this allows faster iteration. |
187| `--verbose` | Produce more verbose output, including a list of tests that pass. |
Takahiro Aoyagi96517392022-01-05 05:19:44188| `--reset-results` | Overwrite the current baselines (`-expected.{png`&#124;`txt`&#124;`wav}` files) with actual results, or create new baselines if there are no existing baselines. |
Quinten Yearsley17bf9b432018-01-02 22:02:45189| `--fully-parallel` | Run tests in parallel using as many child processes as the system has cores. |
pwnallae101a5f2016-11-08 00:24:38190| `--driver-logging` | Print C++ logs (LOG(WARNING), etc). |
191
192## Success and Failure
193
194A test succeeds when its output matches the pre-defined expected results. If any
195tests fail, the test script will place the actual generated results, along with
196a diff of the actual and expected results, into
Xiaohan Wangd54343362022-12-09 17:20:42197`src/out/Default/layout-test-results/`, and by default launch a browser with a
pwnallae101a5f2016-11-08 00:24:38198summary and link to the results/diffs.
199
200The expected results for tests are in the
Kent Tamura59ffb022018-11-27 05:30:56201`src/third_party/blink/web_tests/platform` or alongside their respective
pwnallae101a5f2016-11-08 00:24:38202tests.
203
204*** note
205Tests which use [testharness.js](https://github.com/w3c/testharness.js/)
206do not have expected result files if all test cases pass.
207***
208
209A test that runs but produces the wrong output is marked as "failed", one that
210causes the test shell to crash is marked as "crashed", and one that takes longer
211than a certain amount of time to complete is aborted and marked as "timed out".
212A row of dots in the script's output indicates one or more tests that passed.
213
214## Test expectations
215
216The
Kent Tamura59ffb022018-11-27 05:30:56217[TestExpectations](../../third_party/blink/web_tests/TestExpectations) file (and related
218files) contains the list of all known web test failures. See the
219[Web Test Expectations documentation](./web_test_expectations.md) for more
pwnall4ea2eb32016-11-29 02:47:25220on this.
pwnallae101a5f2016-11-08 00:24:38221
222## Testing Runtime Flags
223
Kent Tamura59ffb022018-11-27 05:30:56224There are two ways to run web tests with additional command-line arguments:
pwnallae101a5f2016-11-08 00:24:38225
Xianzhu Wang3ee2c99d82022-08-10 17:07:21226### --flag-specific
pwnallae101a5f2016-11-08 00:24:38227
Xianzhu Wang61d49d52021-07-31 16:44:53228```bash
Xianzhu Wang3ee2c99d82022-08-10 17:07:21229third_party/blink/tools/run_web_tests.py --flag-specific=blocking-repaint
230```
231It requires that `web_tests/FlagSpecificConfig` contains an entry like:
232
233```json
234{
235 "name": "blocking-repaint",
236 "args": ["--blocking-repaint", "--another-flag"]
237}
Xianzhu Wang61d49d52021-07-31 16:44:53238```
pwnallae101a5f2016-11-08 00:24:38239
Xianzhu Wang3ee2c99d82022-08-10 17:07:21240This tells the test harness to pass `--blocking-repaint --another-flag` to the
Xianzhu Wang61d49d52021-07-31 16:44:53241content_shell binary.
pwnallae101a5f2016-11-08 00:24:38242
Xianzhu Wang61d49d52021-07-31 16:44:53243It will also look for flag-specific expectations in
244`web_tests/FlagExpectations/blocking-repaint`, if this file exists. The
245suppressions in this file override the main TestExpectations files.
246However, `[ Slow ]` in either flag-specific expectations or base expectations
247is always merged into the used expectations.
pwnallae101a5f2016-11-08 00:24:38248
Xianzhu Wang61d49d52021-07-31 16:44:53249It will also look for baselines in `web_tests/flag-specific/blocking-repaint`.
250The baselines in this directory override the fallback baselines.
Xianzhu Wang15355b22019-11-02 23:20:02251
Weizhong Xia53c492162021-09-09 17:08:24252*** note
253[BUILD.gn](../../BUILD.gn) assumes flag-specific builders always runs on linux bots, so
254flag-specific test expectations and baselines are only downloaded to linux bots.
Thiago Perrottae7e240c2023-07-14 18:37:57255If you need run flag-specific builderst-n other platforms, please update
Weizhong Xia53c492162021-09-09 17:08:24256BUILD.gn to download flag-specific related data to that platform.
257***
258
Xianzhu Wang3ee2c99d82022-08-10 17:07:21259You can also use `--additional-driver-flag` to specify additional command-line
260arguments to content_shell, but the test harness won't use any flag-specific
261test expectations or baselines.
262
Xianzhu Wang61d49d52021-07-31 16:44:53263### Virtual test suites
Xianzhu Wang15355b22019-11-02 23:20:02264
Xianzhu Wang61d49d52021-07-31 16:44:53265A *virtual test suite* can be defined in
266[web_tests/VirtualTestSuites](../../third_party/blink/web_tests/VirtualTestSuites),
267to run a subset of web tests with additional flags, with
268`virtual/<prefix>/...` in their paths. The tests can be virtual tests that
269map to real base tests (directories or files) whose paths match any of the
270specified bases, or any real tests under `web_tests/virtual/<prefix>/`
271directory. For example, you could test a (hypothetical) new mode for
272repainting using the following virtual test suite:
pwnallae101a5f2016-11-08 00:24:38273
Xianzhu Wang61d49d52021-07-31 16:44:53274```json
275{
276 "prefix": "blocking_repaint",
Weizhong Xia5ab16822022-03-23 21:02:51277 "platforms": ["Linux", "Mac", "Win"],
Xianzhu Wang61d49d52021-07-31 16:44:53278 "bases": ["compositing", "fast/repaint"],
279 "args": ["--blocking-repaint"]
280}
281```
pwnallae101a5f2016-11-08 00:24:38282
Xianzhu Wang61d49d52021-07-31 16:44:53283This will create new "virtual" tests of the form
284`virtual/blocking_repaint/compositing/...` and
285`virtual/blocking_repaint/fast/repaint/...` which correspond to the files
286under `web_tests/compositing` and `web_tests/fast/repaint`, respectively,
287and pass `--blocking-repaint` to `content_shell` when they are run.
pwnallae101a5f2016-11-08 00:24:38288
Yoshisato Yanagisawaf702d7e2021-10-12 01:47:57289Note that you can run the tests with the following command line:
290
291```bash
292third_party/blink/tools/run_web_tests.py virtual/blocking_repaint/compositing \
293 virtual/blocking_repaint/fast/repaint
294```
295
Xianzhu Wang61d49d52021-07-31 16:44:53296These virtual tests exist in addition to the original `compositing/...` and
297`fast/repaint/...` tests. They can have their own expectations in
298`web_tests/TestExpectations`, and their own baselines. The test harness will
299use the non-virtual expectations and baselines as a fallback. If a virtual
300test has its own expectations, they will override all non-virtual
Thiago Perrottae7e240c2023-07-14 18:37:57301expectations. Otherwise the non-virtual expectations will be used. However,
Xianzhu Wang61d49d52021-07-31 16:44:53302`[ Slow ]` in either virtual or non-virtual expectations is always merged
303into the used expectations. If a virtual test is expected to pass while the
304non-virtual test is expected to fail, you need to add an explicit `[ Pass ]`
305entry for the virtual test.
pwnallae101a5f2016-11-08 00:24:38306
Xianzhu Wang61d49d52021-07-31 16:44:53307This will also let any real tests under `web_tests/virtual/blocking_repaint`
308directory run with the `--blocking-repaint` flag.
Xianzhu Wang5d682c82019-10-29 05:08:19309
Weizhong Xia5ab16822022-03-23 21:02:51310The "platforms" configuration can be used to skip tests on some platforms. If
311a virtual test suites uses more than 5% of total test time, we should consider
312to skip the test suites on some platforms.
313
Xianzhu Wang61d49d52021-07-31 16:44:53314The "prefix" value should be unique. Multiple directories with the same flags
315should be listed in the same "bases" list. The "bases" list can be empty,
316in case that we just want to run the real tests under `virtual/<prefix>`
317with the flags without creating any virtual tests.
pwnallae101a5f2016-11-08 00:24:38318
Xianzhu Wang112e68282022-11-09 22:20:50319A virtual test suite can have an optional `exclusive_tests` field to specify
320all (with `"ALL"`) or a subset of `bases` tests that will be exclusively run
321under this virtual suite. The specified base tests will be skipped. Corresponding
322virtual tests under other virtual suites that don't specify the tests in their
323`exclusive_tests` list will be skipped, too. For example (unrelated fields
324are omitted):
325
326```json
327{
328 "prefix": "v1",
329 "bases": ["a"],
330}
331{
332 "prefix": "v2",
333 "bases": ["a/a1", "a/a2"],
334 "exclusive_tests": "ALL",
335}
336{
337 "prefix": "v3",
338 "bases": ["a"],
339 "exclusive_tests": ["a/a1"],
340}
341```
Jonathan Lee35bedec92023-01-26 18:58:20342
Xianzhu Wang112e68282022-11-09 22:20:50343Suppose there are directories `a/a1`, `a/a2` and `a/a3`, we will run the
344following tests:
Jonathan Lee35bedec92023-01-26 18:58:20345
Xianzhu Wang112e68282022-11-09 22:20:50346| Suite | a/a1 | a/a2 | a/a3 |
347| ---------: | :-----: | :-----: | :--: |
348| base | skipped | skipped | run |
349| virtual/v1 | skipped | skipped | run |
350| virtual/v2 | run | run | n/a |
351| virtual/v3 | run | skipped | run |
352
Yotam Hacohena949ab1a2023-07-19 21:18:14353In a similar manner, a virtual test suite can also have an optional
354`skip_base_tests` field to specify all (with `"ALL"`) or a subset of `bases`
355tests that will be run under this virtual while the base tests will be skipped.
356This will not affect other virtual suites.
357
358```json
359{
360 "prefix": "v1",
361 "bases": ["a/a1"],
362}
363{
364 "prefix": "v2",
365 "bases": ["a/a1"],
366 "skip_base_tests": "ALL",
367}
368```
369Suppose there are directories `a/a1` and `a/a2` we will run the following tests:
370
371| Suite | a/a1 | a/a2 |
372| ---------: | :-----: | :-----: |
373| base | skipped | run |
374| virtual/v1 | run | n/a |
375| virtual/v2 | run | n/a |
376
Xianzhu Wang112e68282022-11-09 22:20:50377
Xianzhu Wang61d49d52021-07-31 16:44:53378### Choosing between flag-specific and virtual test suite
379
380For flags whose implementation is still in progress, flag-specific expectations
381and virtual test suites represent two alternative strategies for testing both
Thiago Perrottae7e240c2023-07-14 18:37:57382the enabled code path and non-enabled code path. They are preferred to only
Xianzhu Wangadb0670a22020-07-16 23:04:58383setting a [runtime enabled feature](../../third_party/blink/renderer/platform/RuntimeEnabledFeatures.md)
384to `status: "test"` if the feature has substantially different code path from
385production because the latter would cause loss of test coverage of the production
386code path.
387
388Consider the following when choosing between virtual test suites and
Jonathan Lee35bedec92023-01-26 18:58:20389flag-specific suites:
pwnallae101a5f2016-11-08 00:24:38390
391* The
392 [waterfall builders](https://dev.chromium.org/developers/testing/chromium-build-infrastructure/tour-of-the-chromium-buildbot)
393 and [try bots](https://dev.chromium.org/developers/testing/try-server-usage)
394 will run all virtual test suites in addition to the non-virtual tests.
Jonathan Lee35bedec92023-01-26 18:58:20395 Conversely, a flag-specific configuration won't automatically cause the bots
396 to test your flag - if you want bot coverage without virtual test suites, you
397 will need to follow [these instructions](#running-a-new-flag_specific-suite-in-cq_ci).
pwnallae101a5f2016-11-08 00:24:38398
399* Due to the above, virtual test suites incur a performance penalty for the
400 commit queue and the continuous build infrastructure. This is exacerbated by
401 the need to restart `content_shell` whenever flags change, which limits
402 parallelism. Therefore, you should avoid adding large numbers of virtual test
403 suites. They are well suited to running a subset of tests that are directly
404 related to the feature, but they don't scale to flags that make deep
405 architectural changes that potentially impact all of the tests.
406
Jeff Carpenter489d4022018-05-15 00:23:00407* Note that using wildcards in virtual test path names (e.g.
Xianzhu Wang61d49d52021-07-31 16:44:53408 `virtual/blocking_repaint/fast/repaint/*`) is not supported in
409 `run_web_tests.py` command line , but you can still use
410 `virtual/blocking_repaint` to run all real and virtual tests
Xianzhu Wang5d682c82019-10-29 05:08:19411 in the suite or `virtual/blocking_repaint/fast/repaint/dir` to run real
412 or virtual tests in the suite under a specific directory.
Jeff Carpenter489d4022018-05-15 00:23:00413
Xianzhu Wanga617a142020-05-07 21:57:47414*** note
415We can run a virtual test with additional flags. Both the virtual args and the
416additional flags will be applied. The fallback order of baselines and
417expectations will be: 1) flag-specific virtual, 2) non-flag-specific virtual,
4183) flag-specific base, 4) non-flag-specific base
419***
420
Jonathan Lee35bedec92023-01-26 18:58:20421### Running a New Flag-Specific Suite in CQ/CI
422
423Assuming you have already created a `FlagSpecificConfig` entry:
424
4251. File a resource request ([internal
426 docs](https://g3doc.corp.google.com/company/teams/chrome/ops/business/resources/resource-request-program.md?cl=head&polyglot=chrome-browser#i-need-new-resources))
427 for increased capacity in the `chromium.tests` swarming pool and wait for
428 approval.
4291. Define a new dedicated
430 [Buildbot test suite](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;l=1516-1583;drc=0694b605fb77c975a065a3734bdcf3bd81fd8ca4;bpv=0;bpt=0)
431 with `--flag-specific` and possibly other special configurations (e.g., fewer shards).
4321. Add the Buildbot suite to the relevant `*-blink-rel` builder's
433 composition suite first
434 ([example](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;l=5779-5780;drc=0694b605fb77c975a065a3734bdcf3bd81fd8ca4;bpv=0;bpt=0)).
4351. Add the flag-specific step name to the relevant builder in
436 [`builders.json`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/tools/blinkpy/common/config/builders.json;l=127-129;drc=ff938aaff9566b2cc442476a51835e0b90b1c6f6;bpv=0;bpt=0).
437 `rebaseline-cl` and the WPT importer will now create baselines for that suite.
4381. Rebaseline the new suite and add any necessary suppressions under
439 `FlagExpectations/`.
4401. Enable the flag-specific suite for CQ/CI by adding the Buildbot suite to the
441 desired builder.
442 This could be an existing CQ builder like
443 [`linux-rel`](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;l=5828-5829;drc=0694b605fb77c975a065a3734bdcf3bd81fd8ca4;bpv=0;bpt=0)
444 or a dedicated builder like
445 [`linux-blink-web-tests-force-accessibility-rel`](https://source.chromium.org/chromium/chromium/src/+/main:infra/config/subprojects/chromium/try/tryserver.chromium.accessibility.star;drc=adad4c6d55e69783ba1f16d30f4bc7367e2e626a;bpv=0;bpt=0), which has customized location filters.
446
pwnallae101a5f2016-11-08 00:24:38447## Tracking Test Failures
448
Kent Tamura59ffb022018-11-27 05:30:56449All bugs, associated with web test failures must have the
pwnallae101a5f2016-11-08 00:24:38450[Test-Layout](https://crbug.com/?q=label:Test-Layout) label. Depending on how
451much you know about the bug, assign the status accordingly:
452
453* **Unconfirmed** -- You aren't sure if this is a simple rebaseline, possible
454 duplicate of an existing bug, or a real failure
455* **Untriaged** -- Confirmed but unsure of priority or root cause.
456* **Available** -- You know the root cause of the issue.
457* **Assigned** or **Started** -- You will fix this issue.
458
Kent Tamura59ffb022018-11-27 05:30:56459When creating a new web test bug, please set the following properties:
pwnallae101a5f2016-11-08 00:24:38460
461* Components: a sub-component of Blink
462* OS: **All** (or whichever OS the failure is on)
463* Priority: 2 (1 if it's a crash)
464* Type: **Bug**
465* Labels: **Test-Layout**
466
Mathias Bynens172fc6b2018-09-05 09:39:43467You can also use the _Layout Test Failure_ template, which pre-sets these
pwnallae101a5f2016-11-08 00:24:38468labels for you.
469
Kent Tamura59ffb022018-11-27 05:30:56470## Debugging Web Tests
pwnallae101a5f2016-11-08 00:24:38471
Kent Tamura59ffb022018-11-27 05:30:56472After the web tests run, you should get a summary of tests that pass or
Mathias Bynens172fc6b2018-09-05 09:39:43473fail. If something fails unexpectedly (a new regression), you will get a
474`content_shell` window with a summary of the unexpected failures. Or you might
475have a failing test in mind to investigate. In any case, here are some steps and
476tips for finding the problem.
pwnallae101a5f2016-11-08 00:24:38477
478* Take a look at the result. Sometimes tests just need to be rebaselined (see
479 below) to account for changes introduced in your patch.
480 * Load the test into a trunk Chrome or content_shell build and look at its
481 result. (For tests in the http/ directory, start the http server first.
482 See above. Navigate to `http://localhost:8000/` and proceed from there.)
483 The best tests describe what they're looking for, but not all do, and
484 sometimes things they're not explicitly testing are still broken. Compare
485 it to Safari, Firefox, and IE if necessary to see if it's correct. If
486 you're still not sure, find the person who knows the most about it and
487 ask.
488 * Some tests only work properly in content_shell, not Chrome, because they
489 rely on extra APIs exposed there.
Kent Tamura59ffb022018-11-27 05:30:56490 * Some tests only work properly when they're run in the web-test
pwnallae101a5f2016-11-08 00:24:38491 framework, not when they're loaded into content_shell directly. The test
492 should mention that in its visible text, but not all do. So try that too.
493 See "Running the tests", above.
494* If you think the test is correct, confirm your suspicion by looking at the
495 diffs between the expected result and the actual one.
496 * Make sure that the diffs reported aren't important. Small differences in
497 spacing or box sizes are often unimportant, especially around fonts and
498 form controls. Differences in wording of JS error messages are also
499 usually acceptable.
Robert Ma7ed16792020-06-16 16:38:52500 * `third_party/blink/tools/run_web_tests.py path/to/your/test.html` produces
501 a page listing all test results. Those which fail their expectations will
502 include links to the expected result, actual result, and diff. These
503 results are saved to `$root_build_dir/layout-test-results`.
jonross26185702019-04-08 18:54:10504 * Alternatively the `--results-directory=path/for/output/` option allows
505 you to specify an alternative directory for the output to be saved to.
pwnallae101a5f2016-11-08 00:24:38506 * If you're still sure it's correct, rebaseline the test (see below).
507 Otherwise...
508* If you're lucky, your test is one that runs properly when you navigate to it
509 in content_shell normally. In that case, build the Debug content_shell
510 project, fire it up in your favorite debugger, and load the test file either
qyearsley23599b72017-02-16 19:10:42511 from a `file:` URL.
pwnallae101a5f2016-11-08 00:24:38512 * You'll probably be starting and stopping the content_shell a lot. In VS,
513 to save navigating to the test every time, you can set the URL to your
qyearsley23599b72017-02-16 19:10:42514 test (`file:` or `http:`) as the command argument in the Debugging section of
pwnallae101a5f2016-11-08 00:24:38515 the content_shell project Properties.
516 * If your test contains a JS call, DOM manipulation, or other distinctive
517 piece of code that you think is failing, search for that in the Chrome
518 solution. That's a good place to put a starting breakpoint to start
519 tracking down the issue.
520 * Otherwise, you're running in a standard message loop just like in Chrome.
521 If you have no other information, set a breakpoint on page load.
Kent Tamura59ffb022018-11-27 05:30:56522* If your test only works in full web-test mode, or if you find it simpler to
pwnallae101a5f2016-11-08 00:24:38523 debug without all the overhead of an interactive session, start the
Kent Tamuracd3ebc42018-05-16 06:44:22524 content_shell with the command-line flag `--run-web-tests`, followed by the
Kent Tamura59ffb022018-11-27 05:30:56525 URL (`file:` or `http:`) to your test. More information about running web tests
526 in content_shell can be found [here](./web_tests_in_content_shell.md).
pwnallae101a5f2016-11-08 00:24:38527 * In VS, you can do this in the Debugging section of the content_shell
528 project Properties.
529 * Now you're running with exactly the same API, theme, and other setup that
Kent Tamura59ffb022018-11-27 05:30:56530 the web tests use.
pwnallae101a5f2016-11-08 00:24:38531 * Again, if your test contains a JS call, DOM manipulation, or other
532 distinctive piece of code that you think is failing, search for that in
533 the Chrome solution. That's a good place to put a starting breakpoint to
534 start tracking down the issue.
535 * If you can't find any better place to set a breakpoint, start at the
536 `TestShell::RunFileTest()` call in `content_shell_main.cc`, or at
537 `shell->LoadURL() within RunFileTest()` in `content_shell_win.cc`.
Kent Tamura59ffb022018-11-27 05:30:56538* Debug as usual. Once you've gotten this far, the failing web test is just a
pwnallae101a5f2016-11-08 00:24:38539 (hopefully) reduced test case that exposes a problem.
540
541### Debugging HTTP Tests
542
Yoshisato Yanagisawa638e2ee02021-12-09 05:52:08543Note: HTTP Tests mean tests under `web_tests/http/tests/`,
544which is a subset of WebKit Layout Tests originated suite.
545If you want to debug WPT's HTTP behavior, you should read
546["Web platform tests"](./web_platform_tests.md) instead.
547
548
pwnallae101a5f2016-11-08 00:24:38549To run the server manually to reproduce/debug a failure:
550
551```bash
Robert Ma7ed16792020-06-16 16:38:52552third_party/blink/tools/run_blink_httpd.py
pwnallae101a5f2016-11-08 00:24:38553```
554
Kent Tamura59ffb022018-11-27 05:30:56555The web tests are served from `http://127.0.0.1:8000/`. For example, to
pwnallae101a5f2016-11-08 00:24:38556run the test
Kent Tamura59ffb022018-11-27 05:30:56557`web_tests/http/tests/serviceworker/chromium/service-worker-allowed.html`,
pwnallae101a5f2016-11-08 00:24:38558navigate to
559`http://127.0.0.1:8000/serviceworker/chromium/service-worker-allowed.html`. Some
Mathias Bynens172fc6b2018-09-05 09:39:43560tests behave differently if you go to `127.0.0.1` vs. `localhost`, so use
561`127.0.0.1`.
pwnallae101a5f2016-11-08 00:24:38562
Kent Tamurae81dbff2018-04-20 17:35:34563To kill the server, hit any key on the terminal where `run_blink_httpd.py` is
Mathias Bynens172fc6b2018-09-05 09:39:43564running, use `taskkill` or the Task Manager on Windows, or `killall` or
565Activity Monitor on macOS.
pwnallae101a5f2016-11-08 00:24:38566
Kent Tamura59ffb022018-11-27 05:30:56567The test server sets up an alias to the `web_tests/resources` directory. For
Mathias Bynens172fc6b2018-09-05 09:39:43568example, in HTTP tests, you can access the testing framework using
pwnallae101a5f2016-11-08 00:24:38569`src="/js-test-resources/js-test.js"`.
570
571### Tips
572
573Check https://test-results.appspot.com/ to see how a test did in the most recent
574~100 builds on each builder (as long as the page is being updated regularly).
575
576A timeout will often also be a text mismatch, since the wrapper script kills the
577content_shell before it has a chance to finish. The exception is if the test
578finishes loading properly, but somehow hangs before it outputs the bit of text
579that tells the wrapper it's done.
580
581Why might a test fail (or crash, or timeout) on buildbot, but pass on your local
582machine?
583* If the test finishes locally but is slow, more than 10 seconds or so, that
584 would be why it's called a timeout on the bot.
585* Otherwise, try running it as part of a set of tests; it's possible that a test
586 one or two (or ten) before this one is corrupting something that makes this
587 one fail.
588* If it consistently works locally, make sure your environment looks like the
589 one on the bot (look at the top of the stdio for the webkit_tests step to see
590 all the environment variables and so on).
591* If none of that helps, and you have access to the bot itself, you may have to
592 log in there and see if you can reproduce the problem manually.
593
Will Chen22b488502017-11-30 21:37:15594### Debugging DevTools Tests
pwnallae101a5f2016-11-08 00:24:38595
Will Chen22b488502017-11-30 21:37:15596* Do one of the following:
Mathias Bynens172fc6b2018-09-05 09:39:43597 * Option A) Run from the `chromium/src` folder:
Weizhong Xia91b53362022-01-05 17:13:35598 `third_party/blink/tools/run_web_tests.py --additional-driver-flag='--remote-debugging-port=9222' --additional-driver-flag='--debug-devtools' --timeout-ms=6000000`
Will Chen22b488502017-11-30 21:37:15599 * Option B) If you need to debug an http/tests/inspector test, start httpd
600 as described above. Then, run content_shell:
Tim van der Lippeae606432020-06-03 15:30:25601 `out/Default/content_shell --remote-debugging-port=9222 --additional-driver-flag='--debug-devtools' --run-web-tests http://127.0.0.1:8000/path/to/test.html`
Will Chen22b488502017-11-30 21:37:15602* Open `http://localhost:9222` in a stable/beta/canary Chrome, click the single
603 link to open the devtools with the test loaded.
604* In the loaded devtools, set any required breakpoints and execute `test()` in
605 the console to actually start the test.
606
607NOTE: If the test is an html file, this means it's a legacy test so you need to add:
pwnallae101a5f2016-11-08 00:24:38608* Add `window.debugTest = true;` to your test code as follows:
609
610 ```javascript
611 window.debugTest = true;
612 function test() {
613 /* TEST CODE */
614 }
Kim Paulhamus61d60c32018-02-09 18:03:49615 ```
pwnallae101a5f2016-11-08 00:24:38616
Steve Kobese123a3d42017-07-20 01:20:30617## Bisecting Regressions
618
619You can use [`git bisect`](https://git-scm.com/docs/git-bisect) to find which
Kent Tamura59ffb022018-11-27 05:30:56620commit broke (or fixed!) a web test in a fully automated way. Unlike
Steve Kobese123a3d42017-07-20 01:20:30621[bisect-builds.py](http://dev.chromium.org/developers/bisect-builds-py), which
622downloads pre-built Chromium binaries, `git bisect` operates on your local
623checkout, so it can run tests with `content_shell`.
624
625Bisecting can take several hours, but since it is fully automated you can leave
626it running overnight and view the results the next day.
627
Kent Tamura59ffb022018-11-27 05:30:56628To set up an automated bisect of a web test regression, create a script like
Steve Kobese123a3d42017-07-20 01:20:30629this:
630
Mathias Bynens172fc6b2018-09-05 09:39:43631```bash
Steve Kobese123a3d42017-07-20 01:20:30632#!/bin/bash
633
634# Exit code 125 tells git bisect to skip the revision.
635gclient sync || exit 125
Max Morozf5b31fcd2018-08-10 21:55:48636autoninja -C out/Debug -j100 blink_tests || exit 125
Steve Kobese123a3d42017-07-20 01:20:30637
Kent Tamuraa045a7f2018-04-25 05:08:11638third_party/blink/tools/run_web_tests.py -t Debug \
Steve Kobese123a3d42017-07-20 01:20:30639 --no-show-results --no-retry-failures \
Kent Tamura59ffb022018-11-27 05:30:56640 path/to/web/test.html
Steve Kobese123a3d42017-07-20 01:20:30641```
642
643Modify the `out` directory, ninja args, and test name as appropriate, and save
644the script in `~/checkrev.sh`. Then run:
645
Mathias Bynens172fc6b2018-09-05 09:39:43646```bash
Steve Kobese123a3d42017-07-20 01:20:30647chmod u+x ~/checkrev.sh # mark script as executable
648git bisect start <badrev> <goodrev>
649git bisect run ~/checkrev.sh
650git bisect reset # quit the bisect session
651```
652
Kent Tamura59ffb022018-11-27 05:30:56653## Rebaselining Web Tests
pwnallae101a5f2016-11-08 00:24:38654
Xianzhu Wang61d49d52021-07-31 16:44:53655See [How to rebaseline](./web_test_expectations.md#How-to-rebaseline).
Xianzhu Wang95d0bac32017-06-05 21:09:39656
pwnallae101a5f2016-11-08 00:24:38657## Known Issues
658
659See
660[bugs with the component Blink>Infra](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=component%3ABlink%3EInfra)
Kent Tamura59ffb022018-11-27 05:30:56661for issues related to Blink tools, include the web test runner.
pwnallae101a5f2016-11-08 00:24:38662
pwnallae101a5f2016-11-08 00:24:38663* If QuickTime is not installed, the plugin tests
664 `fast/dom/object-embed-plugin-scripting.html` and
665 `plugins/embed-attributes-setting.html` are expected to fail.