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 | |
Matt Falkenhagen | cef0974 | 2020-01-06 05:43:38 | [diff] [blame] | 16 | ["Web platform tests"](./web_platform_tests.md) (WPT) are the preferred form of |
| 17 | web tests and are located at |
| 18 | [web_tests/external/wpt](/third_party/blink/web_tests/external/wpt). |
| 19 | Tests that should work across browsers go there. Other directories are for |
| 20 | Chrome-specific tests only. |
| 21 | |
Yoshisato Yanagisawa | 638e2ee0 | 2021-12-09 05:52:08 | [diff] [blame] | 22 | Note: 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 |
| 24 | cover WPT specific features/behaviors. |
| 25 | |
Weizhong Xia | be863d72 | 2023-11-01 22:36:15 | [diff] [blame] | 26 | Note: if you are looking for a guide for running the Web Platform Tests with |
| 27 | Chrome, Chrome Android or WebView, you should read ["Running Web Platform Tests with run_wpt_tests.py"](./run_web_platform_tests.md). |
| 28 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 29 | [TOC] |
| 30 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 31 | ## Running Web Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 32 | |
Stephen McGruer | 7878d06 | 2021-01-15 20:23:20 | [diff] [blame] | 33 | ### Supported Platforms |
| 34 | |
| 35 | * Linux |
| 36 | * MacOS |
| 37 | * Windows |
| 38 | * Fuchsia |
| 39 | |
| 40 | Android is [not supported](https://crbug.com/567947). |
| 41 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 42 | ### Initial Setup |
| 43 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 44 | 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] | 45 | to get `content_shell` and all of the other needed binaries. |
| 46 | |
| 47 | ```bash |
kyle Ju | 8f7d38df | 2018-11-26 16:51:22 | [diff] [blame] | 48 | autoninja -C out/Default blink_tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 49 | ``` |
| 50 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 51 | On **Mac**, you probably want to strip the content_shell binary before starting |
| 52 | the tests. If you don't, you'll have 5-10 running concurrently, all stuck being |
| 53 | examined by the OS crash reporter. This may cause other failures like timeouts |
| 54 | where they normally don't occur. |
| 55 | |
| 56 | ```bash |
Fangzhen Song | 2f09f20 | 2021-09-17 23:56:43 | [diff] [blame] | 57 | strip ./out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 58 | ``` |
| 59 | |
| 60 | ### Running the Tests |
| 61 | |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 62 | The test runner script is in `third_party/blink/tools/run_web_tests.py`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 63 | |
Dirk Pranke | 341ad9c | 2021-09-01 20:42:57 | [diff] [blame] | 64 | To specify which build directory to use (e.g. out/Default, etc.) |
Jocelyn Tran | cfb8101 | 2022-08-05 17:39:45 | [diff] [blame] | 65 | you should pass the `-t` or `--target` parameter. If no directory is specified, |
Thiago Perrotta | e7e240c | 2023-07-14 18:37:57 | [diff] [blame] | 66 | `out/Release` will be used. To use the built-in `out/Default`, use: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 67 | |
| 68 | ```bash |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 69 | third_party/blink/tools/run_web_tests.py -t Default |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 70 | ``` |
| 71 | |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 72 | *** promo |
Gabriel Charette | 45cbb4a7 | 2021-03-19 15:08:12 | [diff] [blame] | 73 | * Windows users need to use `third_party\blink\tools\run_web_tests.bat` instead. |
Robert Ma | cca3b25 | 2020-11-23 20:11:36 | [diff] [blame] | 74 | * Linux users should not use `testing/xvfb.py`; `run_web_tests.py` manages Xvfb |
| 75 | itself. |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 76 | *** |
| 77 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 78 | Tests marked as `[ Skip ]` in |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 79 | [TestExpectations](../../third_party/blink/web_tests/TestExpectations) |
Xianzhu Wang | 15355b2 | 2019-11-02 23:20:02 | [diff] [blame] | 80 | won't be run by default, generally because they cause some intractable tool error. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 81 | To force one of them to be run, either rename that file or specify the skipped |
Xianzhu Wang | 15355b2 | 2019-11-02 23:20:02 | [diff] [blame] | 82 | test 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). |
| 84 | Read the [Web Test Expectations documentation](./web_test_expectations.md) to |
| 85 | learn more about TestExpectations and related files. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 86 | |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 87 | *** promo |
| 88 | Currently only the tests listed in |
An Sung | 65d9eab | 2023-07-26 01:38:43 | [diff] [blame] | 89 | [Default.txt](../../third_party/blink/web_tests/TestLists/Default.txt) are run |
Weizhong Xia | a33c616 | 2022-05-03 02:11:27 | [diff] [blame] | 90 | on the Fuchsia bots, since running all web tests takes too long on Fuchshia. |
| 91 | Most developers focus their Blink testing on Linux. We rely on the fact that the |
Stephen McGruer | 7878d06 | 2021-01-15 20:23:20 | [diff] [blame] | 92 | Linux and Fuchsia behavior is nearly identical for scenarios outside those |
| 93 | covered by the smoke tests. |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 94 | *** |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 95 | |
Weizhong Xia | a33c616 | 2022-05-03 02:11:27 | [diff] [blame] | 96 | *** promo |
Weizhong Xia | e415c52c | 2025-02-12 21:29:01 | [diff] [blame] | 97 | Similar to Fuchsia's case, the tests listed in [MacOld.txt](../../third_party/blink/web_tests/TestLists/MacOld.txt) |
Weizhong Xia | a33c616 | 2022-05-03 02:11:27 | [diff] [blame] | 98 | are run on older mac version bots. By doing this we reduced the resources needed to run |
| 99 | the tests. This relies on the fact that the majority of web tests will behavior similarly on |
| 100 | different mac versions. |
| 101 | *** |
| 102 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 103 | To run only some of the tests, specify their directories or filenames as |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 104 | arguments to `run_web_tests.py` relative to the web test directory |
| 105 | (`src/third_party/blink/web_tests`). For example, to run the fast form tests, |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 106 | use: |
| 107 | |
| 108 | ```bash |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 109 | third_party/blink/tools/run_web_tests.py fast/forms |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 110 | ``` |
| 111 | |
| 112 | Or you could use the following shorthand: |
| 113 | |
| 114 | ```bash |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 115 | third_party/blink/tools/run_web_tests.py fast/fo\* |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 116 | ``` |
| 117 | |
| 118 | *** promo |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 119 | 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] | 120 | test the SVG tests and run pixel tests, you would run: |
| 121 | |
| 122 | ```bash |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 123 | third_party/blink/tools/run_web_tests.py -t Default svg |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 124 | ``` |
| 125 | *** |
| 126 | |
| 127 | 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] | 128 | content_shell executable to run specific tests by using (example on Windows): |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 129 | |
| 130 | ```bash |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 131 | 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] | 132 | ``` |
| 133 | |
| 134 | as in: |
| 135 | |
| 136 | ```bash |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 137 | out\Default\content_shell.exe --run-web-tests \ |
| 138 | c:\chrome\src\third_party\blink\web_tests\fast\forms\001.html |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 139 | ``` |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 140 | or |
| 141 | |
| 142 | ```bash |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 143 | out\Default\content_shell.exe --run-web-tests fast\forms\001.html |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 144 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 145 | |
| 146 | but this requires a manual diff against expected results, because the shell |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 147 | doesn't do it for you. It also just dumps the text result only (as the dump of |
| 148 | pixels and audio binary data is not human readable). |
Jeonghee Ahn | 2cbb9cb | 2019-09-23 02:52:57 | [diff] [blame] | 149 | See [Running Web Tests Using the Content Shell](./web_tests_in_content_shell.md) |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 150 | for more details of running `content_shell`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 151 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 152 | To see a complete list of arguments supported, run: |
| 153 | |
| 154 | ```bash |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 155 | third_party/blink/tools/run_web_tests.py --help |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 156 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 157 | |
| 158 | *** note |
| 159 | **Linux Note:** We try to match the Windows render tree output exactly by |
| 160 | matching font metrics and widget metrics. If there's a difference in the render |
| 161 | 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] | 162 | metrics. For additional information on Linux web tests, please see |
Jeonghee Ahn | 2cbb9cb | 2019-09-23 02:52:57 | [diff] [blame] | 163 | [docs/web_tests_linux.md](./web_tests_linux.md). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 164 | *** |
| 165 | |
| 166 | *** note |
| 167 | **Mac Note:** While the tests are running, a bunch of Appearance settings are |
| 168 | overridden for you so the right type of scroll bars, colors, etc. are used. |
| 169 | Your main display's "Color Profile" is also changed to make sure color |
| 170 | correction by ColorSync matches what is expected in the pixel tests. The change |
| 171 | is noticeable, how much depends on the normal level of correction for your |
| 172 | display. The tests do their best to restore your setting when done, but if |
| 173 | you're left in the wrong state, you can manually reset it by going to |
| 174 | System Preferences → Displays → Color and selecting the "right" value. |
| 175 | *** |
| 176 | |
| 177 | ### Test Harness Options |
| 178 | |
| 179 | This script has a lot of command line flags. You can pass `--help` to the script |
| 180 | to see a full list of options. A few of the most useful options are below: |
| 181 | |
| 182 | | Option | Meaning | |
| 183 | |:----------------------------|:--------------------------------------------------| |
| 184 | | `--debug` | Run the debug build of the test shell (default is release). Equivalent to `-t Debug` | |
| 185 | | `--nocheck-sys-deps` | Don't check system dependencies; this allows faster iteration. | |
| 186 | | `--verbose` | Produce more verbose output, including a list of tests that pass. | |
Takahiro Aoyagi | 9651739 | 2022-01-05 05:19:44 | [diff] [blame] | 187 | | `--reset-results` | Overwrite the current baselines (`-expected.{png`|`txt`|`wav}` files) with actual results, or create new baselines if there are no existing baselines. | |
Quinten Yearsley | 17bf9b43 | 2018-01-02 22:02:45 | [diff] [blame] | 188 | | `--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] | 189 | | `--driver-logging` | Print C++ logs (LOG(WARNING), etc). | |
| 190 | |
| 191 | ## Success and Failure |
| 192 | |
| 193 | A test succeeds when its output matches the pre-defined expected results. If any |
| 194 | tests fail, the test script will place the actual generated results, along with |
| 195 | a diff of the actual and expected results, into |
Xiaohan Wang | d5434336 | 2022-12-09 17:20:42 | [diff] [blame] | 196 | `src/out/Default/layout-test-results/`, and by default launch a browser with a |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 197 | summary and link to the results/diffs. |
| 198 | |
| 199 | The expected results for tests are in the |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 200 | `src/third_party/blink/web_tests/platform` or alongside their respective |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 201 | tests. |
| 202 | |
| 203 | *** note |
| 204 | Tests which use [testharness.js](https://github.com/w3c/testharness.js/) |
| 205 | do not have expected result files if all test cases pass. |
| 206 | *** |
| 207 | |
| 208 | A test that runs but produces the wrong output is marked as "failed", one that |
| 209 | causes the test shell to crash is marked as "crashed", and one that takes longer |
| 210 | than a certain amount of time to complete is aborted and marked as "timed out". |
| 211 | A row of dots in the script's output indicates one or more tests that passed. |
| 212 | |
| 213 | ## Test expectations |
| 214 | |
| 215 | The |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 216 | [TestExpectations](../../third_party/blink/web_tests/TestExpectations) file (and related |
| 217 | files) contains the list of all known web test failures. See the |
| 218 | [Web Test Expectations documentation](./web_test_expectations.md) for more |
pwnall | 4ea2eb3 | 2016-11-29 02:47:25 | [diff] [blame] | 219 | on this. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 220 | |
| 221 | ## Testing Runtime Flags |
| 222 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 223 | There are two ways to run web tests with additional command-line arguments: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 224 | |
Xianzhu Wang | 3ee2c99d8 | 2022-08-10 17:07:21 | [diff] [blame] | 225 | ### --flag-specific |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 226 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 227 | ```bash |
Xianzhu Wang | 3ee2c99d8 | 2022-08-10 17:07:21 | [diff] [blame] | 228 | third_party/blink/tools/run_web_tests.py --flag-specific=blocking-repaint |
| 229 | ``` |
| 230 | It requires that `web_tests/FlagSpecificConfig` contains an entry like: |
| 231 | |
| 232 | ```json |
| 233 | { |
| 234 | "name": "blocking-repaint", |
| 235 | "args": ["--blocking-repaint", "--another-flag"] |
| 236 | } |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 237 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 238 | |
Xianzhu Wang | 3ee2c99d8 | 2022-08-10 17:07:21 | [diff] [blame] | 239 | This tells the test harness to pass `--blocking-repaint --another-flag` to the |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 240 | content_shell binary. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 241 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 242 | It will also look for flag-specific expectations in |
| 243 | `web_tests/FlagExpectations/blocking-repaint`, if this file exists. The |
| 244 | suppressions in this file override the main TestExpectations files. |
| 245 | However, `[ Slow ]` in either flag-specific expectations or base expectations |
| 246 | is always merged into the used expectations. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 247 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 248 | It will also look for baselines in `web_tests/flag-specific/blocking-repaint`. |
| 249 | The baselines in this directory override the fallback baselines. |
Xianzhu Wang | 15355b2 | 2019-11-02 23:20:02 | [diff] [blame] | 250 | |
Weizhong Xia | 53c49216 | 2021-09-09 17:08:24 | [diff] [blame] | 251 | *** note |
| 252 | [BUILD.gn](../../BUILD.gn) assumes flag-specific builders always runs on linux bots, so |
| 253 | flag-specific test expectations and baselines are only downloaded to linux bots. |
Gaston Rodriguez Lopez | b36aa7c | 2024-01-08 23:02:48 | [diff] [blame] | 254 | If you need run flag-specific builders on other platforms, please update |
Weizhong Xia | 53c49216 | 2021-09-09 17:08:24 | [diff] [blame] | 255 | BUILD.gn to download flag-specific related data to that platform. |
| 256 | *** |
| 257 | |
Xianzhu Wang | 3ee2c99d8 | 2022-08-10 17:07:21 | [diff] [blame] | 258 | You can also use `--additional-driver-flag` to specify additional command-line |
| 259 | arguments to content_shell, but the test harness won't use any flag-specific |
| 260 | test expectations or baselines. |
| 261 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 262 | ### Virtual test suites |
Xianzhu Wang | 15355b2 | 2019-11-02 23:20:02 | [diff] [blame] | 263 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 264 | A *virtual test suite* can be defined in |
| 265 | [web_tests/VirtualTestSuites](../../third_party/blink/web_tests/VirtualTestSuites), |
| 266 | to run a subset of web tests with additional flags, with |
| 267 | `virtual/<prefix>/...` in their paths. The tests can be virtual tests that |
| 268 | map to real base tests (directories or files) whose paths match any of the |
| 269 | specified bases, or any real tests under `web_tests/virtual/<prefix>/` |
| 270 | directory. For example, you could test a (hypothetical) new mode for |
| 271 | repainting using the following virtual test suite: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 272 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 273 | ```json |
| 274 | { |
| 275 | "prefix": "blocking_repaint", |
Weizhong Xia | 5ab1682 | 2022-03-23 21:02:51 | [diff] [blame] | 276 | "platforms": ["Linux", "Mac", "Win"], |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 277 | "bases": ["compositing", "fast/repaint"], |
| 278 | "args": ["--blocking-repaint"] |
| 279 | } |
| 280 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 281 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 282 | This will create new "virtual" tests of the form |
| 283 | `virtual/blocking_repaint/compositing/...` and |
| 284 | `virtual/blocking_repaint/fast/repaint/...` which correspond to the files |
| 285 | under `web_tests/compositing` and `web_tests/fast/repaint`, respectively, |
| 286 | and pass `--blocking-repaint` to `content_shell` when they are run. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 287 | |
Yoshisato Yanagisawa | f702d7e | 2021-10-12 01:47:57 | [diff] [blame] | 288 | Note that you can run the tests with the following command line: |
| 289 | |
| 290 | ```bash |
| 291 | third_party/blink/tools/run_web_tests.py virtual/blocking_repaint/compositing \ |
| 292 | virtual/blocking_repaint/fast/repaint |
| 293 | ``` |
| 294 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 295 | These virtual tests exist in addition to the original `compositing/...` and |
| 296 | `fast/repaint/...` tests. They can have their own expectations in |
| 297 | `web_tests/TestExpectations`, and their own baselines. The test harness will |
| 298 | use the non-virtual expectations and baselines as a fallback. If a virtual |
| 299 | test has its own expectations, they will override all non-virtual |
Thiago Perrotta | e7e240c | 2023-07-14 18:37:57 | [diff] [blame] | 300 | expectations. Otherwise the non-virtual expectations will be used. However, |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 301 | `[ Slow ]` in either virtual or non-virtual expectations is always merged |
| 302 | into the used expectations. If a virtual test is expected to pass while the |
| 303 | non-virtual test is expected to fail, you need to add an explicit `[ Pass ]` |
| 304 | entry for the virtual test. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 305 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 306 | This will also let any real tests under `web_tests/virtual/blocking_repaint` |
| 307 | directory run with the `--blocking-repaint` flag. |
Xianzhu Wang | 5d682c8 | 2019-10-29 05:08:19 | [diff] [blame] | 308 | |
Weizhong Xia | 5ab1682 | 2022-03-23 21:02:51 | [diff] [blame] | 309 | The "platforms" configuration can be used to skip tests on some platforms. If |
| 310 | a virtual test suites uses more than 5% of total test time, we should consider |
| 311 | to skip the test suites on some platforms. |
| 312 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 313 | The "prefix" value should be unique. Multiple directories with the same flags |
| 314 | should be listed in the same "bases" list. The "bases" list can be empty, |
| 315 | in case that we just want to run the real tests under `virtual/<prefix>` |
| 316 | with the flags without creating any virtual tests. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 317 | |
Xianzhu Wang | 112e6828 | 2022-11-09 22:20:50 | [diff] [blame] | 318 | A virtual test suite can have an optional `exclusive_tests` field to specify |
| 319 | all (with `"ALL"`) or a subset of `bases` tests that will be exclusively run |
| 320 | under this virtual suite. The specified base tests will be skipped. Corresponding |
| 321 | virtual tests under other virtual suites that don't specify the tests in their |
| 322 | `exclusive_tests` list will be skipped, too. For example (unrelated fields |
| 323 | are omitted): |
| 324 | |
| 325 | ```json |
| 326 | { |
| 327 | "prefix": "v1", |
| 328 | "bases": ["a"], |
| 329 | } |
| 330 | { |
| 331 | "prefix": "v2", |
| 332 | "bases": ["a/a1", "a/a2"], |
| 333 | "exclusive_tests": "ALL", |
| 334 | } |
| 335 | { |
| 336 | "prefix": "v3", |
| 337 | "bases": ["a"], |
| 338 | "exclusive_tests": ["a/a1"], |
| 339 | } |
| 340 | ``` |
Jonathan Lee | 35bedec9 | 2023-01-26 18:58:20 | [diff] [blame] | 341 | |
Xianzhu Wang | 112e6828 | 2022-11-09 22:20:50 | [diff] [blame] | 342 | Suppose there are directories `a/a1`, `a/a2` and `a/a3`, we will run the |
| 343 | following tests: |
Jonathan Lee | 35bedec9 | 2023-01-26 18:58:20 | [diff] [blame] | 344 | |
Xianzhu Wang | 112e6828 | 2022-11-09 22:20:50 | [diff] [blame] | 345 | | Suite | a/a1 | a/a2 | a/a3 | |
| 346 | | ---------: | :-----: | :-----: | :--: | |
| 347 | | base | skipped | skipped | run | |
| 348 | | virtual/v1 | skipped | skipped | run | |
| 349 | | virtual/v2 | run | run | n/a | |
| 350 | | virtual/v3 | run | skipped | run | |
| 351 | |
Yotam Hacohen | a949ab1a | 2023-07-19 21:18:14 | [diff] [blame] | 352 | In a similar manner, a virtual test suite can also have an optional |
| 353 | `skip_base_tests` field to specify all (with `"ALL"`) or a subset of `bases` |
| 354 | tests that will be run under this virtual while the base tests will be skipped. |
| 355 | This will not affect other virtual suites. |
| 356 | |
| 357 | ```json |
| 358 | { |
| 359 | "prefix": "v1", |
| 360 | "bases": ["a/a1"], |
| 361 | } |
| 362 | { |
| 363 | "prefix": "v2", |
| 364 | "bases": ["a/a1"], |
| 365 | "skip_base_tests": "ALL", |
| 366 | } |
| 367 | ``` |
| 368 | Suppose there are directories `a/a1` and `a/a2` we will run the following tests: |
| 369 | |
| 370 | | Suite | a/a1 | a/a2 | |
| 371 | | ---------: | :-----: | :-----: | |
| 372 | | base | skipped | run | |
| 373 | | virtual/v1 | run | n/a | |
| 374 | | virtual/v2 | run | n/a | |
| 375 | |
Xianzhu Wang | 112e6828 | 2022-11-09 22:20:50 | [diff] [blame] | 376 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 377 | ### Choosing between flag-specific and virtual test suite |
| 378 | |
| 379 | For flags whose implementation is still in progress, flag-specific expectations |
| 380 | and virtual test suites represent two alternative strategies for testing both |
Thiago Perrotta | e7e240c | 2023-07-14 18:37:57 | [diff] [blame] | 381 | the enabled code path and non-enabled code path. They are preferred to only |
Xianzhu Wang | adb0670a2 | 2020-07-16 23:04:58 | [diff] [blame] | 382 | setting a [runtime enabled feature](../../third_party/blink/renderer/platform/RuntimeEnabledFeatures.md) |
| 383 | to `status: "test"` if the feature has substantially different code path from |
| 384 | production because the latter would cause loss of test coverage of the production |
| 385 | code path. |
| 386 | |
| 387 | Consider the following when choosing between virtual test suites and |
Jonathan Lee | 35bedec9 | 2023-01-26 18:58:20 | [diff] [blame] | 388 | flag-specific suites: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 389 | |
| 390 | * The |
| 391 | [waterfall builders](https://dev.chromium.org/developers/testing/chromium-build-infrastructure/tour-of-the-chromium-buildbot) |
| 392 | and [try bots](https://dev.chromium.org/developers/testing/try-server-usage) |
| 393 | will run all virtual test suites in addition to the non-virtual tests. |
Jonathan Lee | 35bedec9 | 2023-01-26 18:58:20 | [diff] [blame] | 394 | Conversely, a flag-specific configuration won't automatically cause the bots |
| 395 | to test your flag - if you want bot coverage without virtual test suites, you |
| 396 | will need to follow [these instructions](#running-a-new-flag_specific-suite-in-cq_ci). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 397 | |
| 398 | * Due to the above, virtual test suites incur a performance penalty for the |
| 399 | commit queue and the continuous build infrastructure. This is exacerbated by |
| 400 | the need to restart `content_shell` whenever flags change, which limits |
| 401 | parallelism. Therefore, you should avoid adding large numbers of virtual test |
| 402 | suites. They are well suited to running a subset of tests that are directly |
| 403 | related to the feature, but they don't scale to flags that make deep |
| 404 | architectural changes that potentially impact all of the tests. |
| 405 | |
Jeff Carpenter | 489d402 | 2018-05-15 00:23:00 | [diff] [blame] | 406 | * Note that using wildcards in virtual test path names (e.g. |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 407 | `virtual/blocking_repaint/fast/repaint/*`) is not supported in |
| 408 | `run_web_tests.py` command line , but you can still use |
| 409 | `virtual/blocking_repaint` to run all real and virtual tests |
Xianzhu Wang | 5d682c8 | 2019-10-29 05:08:19 | [diff] [blame] | 410 | in the suite or `virtual/blocking_repaint/fast/repaint/dir` to run real |
| 411 | or virtual tests in the suite under a specific directory. |
Jeff Carpenter | 489d402 | 2018-05-15 00:23:00 | [diff] [blame] | 412 | |
Xianzhu Wang | a617a14 | 2020-05-07 21:57:47 | [diff] [blame] | 413 | *** note |
| 414 | We can run a virtual test with additional flags. Both the virtual args and the |
| 415 | additional flags will be applied. The fallback order of baselines and |
| 416 | expectations will be: 1) flag-specific virtual, 2) non-flag-specific virtual, |
| 417 | 3) flag-specific base, 4) non-flag-specific base |
| 418 | *** |
| 419 | |
Jonathan Lee | 35bedec9 | 2023-01-26 18:58:20 | [diff] [blame] | 420 | ### Running a New Flag-Specific Suite in CQ/CI |
| 421 | |
| 422 | Assuming you have already created a `FlagSpecificConfig` entry: |
| 423 | |
| 424 | 1. File a resource request ([internal |
| 425 | 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)) |
| 426 | for increased capacity in the `chromium.tests` swarming pool and wait for |
| 427 | approval. |
| 428 | 1. Define a new dedicated |
| 429 | [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) |
| 430 | with `--flag-specific` and possibly other special configurations (e.g., fewer shards). |
| 431 | 1. Add the Buildbot suite to the relevant `*-blink-rel` builder's |
| 432 | composition suite first |
| 433 | ([example](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;l=5779-5780;drc=0694b605fb77c975a065a3734bdcf3bd81fd8ca4;bpv=0;bpt=0)). |
| 434 | 1. Add the flag-specific step name to the relevant builder in |
| 435 | [`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). |
| 436 | `rebaseline-cl` and the WPT importer will now create baselines for that suite. |
| 437 | 1. Rebaseline the new suite and add any necessary suppressions under |
| 438 | `FlagExpectations/`. |
| 439 | 1. Enable the flag-specific suite for CQ/CI by adding the Buildbot suite to the |
| 440 | desired builder. |
| 441 | This could be an existing CQ builder like |
| 442 | [`linux-rel`](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;l=5828-5829;drc=0694b605fb77c975a065a3734bdcf3bd81fd8ca4;bpv=0;bpt=0) |
| 443 | or a dedicated builder like |
| 444 | [`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. |
| 445 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 446 | ## Tracking Test Failures |
| 447 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 448 | All bugs, associated with web test failures must have the |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 449 | [Test-Layout](https://crbug.com/?q=label:Test-Layout) label. Depending on how |
| 450 | much you know about the bug, assign the status accordingly: |
| 451 | |
| 452 | * **Unconfirmed** -- You aren't sure if this is a simple rebaseline, possible |
| 453 | duplicate of an existing bug, or a real failure |
| 454 | * **Untriaged** -- Confirmed but unsure of priority or root cause. |
| 455 | * **Available** -- You know the root cause of the issue. |
| 456 | * **Assigned** or **Started** -- You will fix this issue. |
| 457 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 458 | When creating a new web test bug, please set the following properties: |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 459 | |
| 460 | * Components: a sub-component of Blink |
| 461 | * OS: **All** (or whichever OS the failure is on) |
| 462 | * Priority: 2 (1 if it's a crash) |
| 463 | * Type: **Bug** |
| 464 | * Labels: **Test-Layout** |
| 465 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 466 | You can also use the _Layout Test Failure_ template, which pre-sets these |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 467 | labels for you. |
| 468 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 469 | ## Debugging Web Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 470 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 471 | 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] | 472 | fail. If something fails unexpectedly (a new regression), you will get a |
| 473 | `content_shell` window with a summary of the unexpected failures. Or you might |
| 474 | have a failing test in mind to investigate. In any case, here are some steps and |
| 475 | tips for finding the problem. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 476 | |
| 477 | * Take a look at the result. Sometimes tests just need to be rebaselined (see |
| 478 | below) to account for changes introduced in your patch. |
| 479 | * Load the test into a trunk Chrome or content_shell build and look at its |
| 480 | result. (For tests in the http/ directory, start the http server first. |
| 481 | See above. Navigate to `http://localhost:8000/` and proceed from there.) |
| 482 | The best tests describe what they're looking for, but not all do, and |
| 483 | sometimes things they're not explicitly testing are still broken. Compare |
| 484 | it to Safari, Firefox, and IE if necessary to see if it's correct. If |
| 485 | you're still not sure, find the person who knows the most about it and |
| 486 | ask. |
| 487 | * Some tests only work properly in content_shell, not Chrome, because they |
| 488 | rely on extra APIs exposed there. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 489 | * Some tests only work properly when they're run in the web-test |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 490 | framework, not when they're loaded into content_shell directly. The test |
| 491 | should mention that in its visible text, but not all do. So try that too. |
| 492 | See "Running the tests", above. |
| 493 | * If you think the test is correct, confirm your suspicion by looking at the |
| 494 | diffs between the expected result and the actual one. |
| 495 | * Make sure that the diffs reported aren't important. Small differences in |
| 496 | spacing or box sizes are often unimportant, especially around fonts and |
| 497 | form controls. Differences in wording of JS error messages are also |
| 498 | usually acceptable. |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 499 | * `third_party/blink/tools/run_web_tests.py path/to/your/test.html` produces |
| 500 | a page listing all test results. Those which fail their expectations will |
| 501 | include links to the expected result, actual result, and diff. These |
| 502 | results are saved to `$root_build_dir/layout-test-results`. |
jonross | 2618570 | 2019-04-08 18:54:10 | [diff] [blame] | 503 | * Alternatively the `--results-directory=path/for/output/` option allows |
| 504 | you to specify an alternative directory for the output to be saved to. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 505 | * If you're still sure it's correct, rebaseline the test (see below). |
| 506 | Otherwise... |
| 507 | * If you're lucky, your test is one that runs properly when you navigate to it |
| 508 | in content_shell normally. In that case, build the Debug content_shell |
| 509 | project, fire it up in your favorite debugger, and load the test file either |
qyearsley | 23599b7 | 2017-02-16 19:10:42 | [diff] [blame] | 510 | from a `file:` URL. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 511 | * You'll probably be starting and stopping the content_shell a lot. In VS, |
| 512 | 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] | 513 | test (`file:` or `http:`) as the command argument in the Debugging section of |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 514 | the content_shell project Properties. |
| 515 | * If your test contains a JS call, DOM manipulation, or other distinctive |
| 516 | piece of code that you think is failing, search for that in the Chrome |
| 517 | solution. That's a good place to put a starting breakpoint to start |
| 518 | tracking down the issue. |
| 519 | * Otherwise, you're running in a standard message loop just like in Chrome. |
| 520 | If you have no other information, set a breakpoint on page load. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 521 | * 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] | 522 | debug without all the overhead of an interactive session, start the |
Kent Tamura | cd3ebc4 | 2018-05-16 06:44:22 | [diff] [blame] | 523 | content_shell with the command-line flag `--run-web-tests`, followed by the |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 524 | URL (`file:` or `http:`) to your test. More information about running web tests |
| 525 | in content_shell can be found [here](./web_tests_in_content_shell.md). |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 526 | * In VS, you can do this in the Debugging section of the content_shell |
| 527 | project Properties. |
| 528 | * 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] | 529 | the web tests use. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 530 | * Again, if your test contains a JS call, DOM manipulation, or other |
| 531 | distinctive piece of code that you think is failing, search for that in |
| 532 | the Chrome solution. That's a good place to put a starting breakpoint to |
| 533 | start tracking down the issue. |
| 534 | * If you can't find any better place to set a breakpoint, start at the |
| 535 | `TestShell::RunFileTest()` call in `content_shell_main.cc`, or at |
| 536 | `shell->LoadURL() within RunFileTest()` in `content_shell_win.cc`. |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 537 | * 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] | 538 | (hopefully) reduced test case that exposes a problem. |
| 539 | |
| 540 | ### Debugging HTTP Tests |
| 541 | |
Yoshisato Yanagisawa | 638e2ee0 | 2021-12-09 05:52:08 | [diff] [blame] | 542 | Note: HTTP Tests mean tests under `web_tests/http/tests/`, |
| 543 | which is a subset of WebKit Layout Tests originated suite. |
| 544 | If you want to debug WPT's HTTP behavior, you should read |
| 545 | ["Web platform tests"](./web_platform_tests.md) instead. |
| 546 | |
| 547 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 548 | To run the server manually to reproduce/debug a failure: |
| 549 | |
| 550 | ```bash |
Robert Ma | 7ed1679 | 2020-06-16 16:38:52 | [diff] [blame] | 551 | third_party/blink/tools/run_blink_httpd.py |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 552 | ``` |
| 553 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 554 | 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] | 555 | run the test |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 556 | `web_tests/http/tests/serviceworker/chromium/service-worker-allowed.html`, |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 557 | navigate to |
| 558 | `http://127.0.0.1:8000/serviceworker/chromium/service-worker-allowed.html`. Some |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 559 | tests behave differently if you go to `127.0.0.1` vs. `localhost`, so use |
| 560 | `127.0.0.1`. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 561 | |
Kent Tamura | e81dbff | 2018-04-20 17:35:34 | [diff] [blame] | 562 | 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] | 563 | running, use `taskkill` or the Task Manager on Windows, or `killall` or |
| 564 | Activity Monitor on macOS. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 565 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 566 | 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] | 567 | example, in HTTP tests, you can access the testing framework using |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 568 | `src="/js-test-resources/js-test.js"`. |
| 569 | |
| 570 | ### Tips |
| 571 | |
| 572 | Check https://test-results.appspot.com/ to see how a test did in the most recent |
| 573 | ~100 builds on each builder (as long as the page is being updated regularly). |
| 574 | |
| 575 | A timeout will often also be a text mismatch, since the wrapper script kills the |
| 576 | content_shell before it has a chance to finish. The exception is if the test |
| 577 | finishes loading properly, but somehow hangs before it outputs the bit of text |
| 578 | that tells the wrapper it's done. |
| 579 | |
| 580 | Why might a test fail (or crash, or timeout) on buildbot, but pass on your local |
| 581 | machine? |
| 582 | * If the test finishes locally but is slow, more than 10 seconds or so, that |
| 583 | would be why it's called a timeout on the bot. |
| 584 | * Otherwise, try running it as part of a set of tests; it's possible that a test |
| 585 | one or two (or ten) before this one is corrupting something that makes this |
| 586 | one fail. |
| 587 | * If it consistently works locally, make sure your environment looks like the |
| 588 | one on the bot (look at the top of the stdio for the webkit_tests step to see |
| 589 | all the environment variables and so on). |
| 590 | * If none of that helps, and you have access to the bot itself, you may have to |
| 591 | log in there and see if you can reproduce the problem manually. |
| 592 | |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 593 | ### Debugging DevTools Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 594 | |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 595 | * Do one of the following: |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 596 | * Option A) Run from the `chromium/src` folder: |
Alex Rudenko | 16b8ecf1 | 2024-02-27 10:23:15 | [diff] [blame] | 597 | `third_party/blink/tools/run_web_tests.py --additional-driver-flag='--remote-debugging-port=9222' --additional-driver-flag='--remote-allow-origins=*' --additional-driver-flag='--debug-devtools' --timeout-ms=6000000` |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 598 | * Option B) If you need to debug an http/tests/inspector test, start httpd |
| 599 | as described above. Then, run content_shell: |
Alex Rudenko | 16b8ecf1 | 2024-02-27 10:23:15 | [diff] [blame] | 600 | `out/Default/content_shell --remote-debugging-port=9222 --additional-driver-flag='--remote-allow-origins=*' --additional-driver-flag='--debug-devtools' --run-web-tests http://127.0.0.1:8000/path/to/test.html` |
Will Chen | 22b48850 | 2017-11-30 21:37:15 | [diff] [blame] | 601 | * Open `http://localhost:9222` in a stable/beta/canary Chrome, click the single |
| 602 | link to open the devtools with the test loaded. |
| 603 | * In the loaded devtools, set any required breakpoints and execute `test()` in |
| 604 | the console to actually start the test. |
| 605 | |
| 606 | 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] | 607 | * Add `window.debugTest = true;` to your test code as follows: |
| 608 | |
| 609 | ```javascript |
| 610 | window.debugTest = true; |
| 611 | function test() { |
| 612 | /* TEST CODE */ |
| 613 | } |
Kim Paulhamus | 61d60c3 | 2018-02-09 18:03:49 | [diff] [blame] | 614 | ``` |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 615 | |
Alex Rudenko | ddedf8e9 | 2024-03-19 16:16:58 | [diff] [blame] | 616 | ### Reproducing flaky inspector protocol tests |
| 617 | |
| 618 | https://crrev.com/c/5318502 implemented logging for inspector-protocol tests. |
| 619 | With this CL for each test in stderr you should see Chrome DevTools Protocol |
| 620 | messages that the test and the browser exchanged. |
| 621 | |
| 622 | You can use this log to reproduce the failure or timeout locally. |
| 623 | |
| 624 | * Prepare a log file and ensure each line contains one protocol message |
| 625 | in the JSON format. Strip any prefixes or non-protocol messages from the |
| 626 | original log. |
| 627 | * Make sure your local test file version matches the version that produced |
| 628 | the log file. |
| 629 | * Run the test using the log file: |
| 630 | |
| 631 | ```sh |
| 632 | third_party/blink/tools/run_web_tests.py -t Release \ |
| 633 | --additional-driver-flag="--inspector-protocol-log=/path/to/log.txt" \ |
| 634 | http/tests/inspector-protocol/network/url-fragment.js |
| 635 | ``` |
| 636 | |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 637 | ## Bisecting Regressions |
| 638 | |
| 639 | 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] | 640 | commit broke (or fixed!) a web test in a fully automated way. Unlike |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 641 | [bisect-builds.py](http://dev.chromium.org/developers/bisect-builds-py), which |
| 642 | downloads pre-built Chromium binaries, `git bisect` operates on your local |
| 643 | checkout, so it can run tests with `content_shell`. |
| 644 | |
| 645 | Bisecting can take several hours, but since it is fully automated you can leave |
| 646 | it running overnight and view the results the next day. |
| 647 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 648 | 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] | 649 | this: |
| 650 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 651 | ```bash |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 652 | #!/bin/bash |
| 653 | |
| 654 | # Exit code 125 tells git bisect to skip the revision. |
| 655 | gclient sync || exit 125 |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 656 | autoninja -C out/Debug -j100 blink_tests || exit 125 |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 657 | |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 658 | third_party/blink/tools/run_web_tests.py -t Debug \ |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 659 | --no-show-results --no-retry-failures \ |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 660 | path/to/web/test.html |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 661 | ``` |
| 662 | |
| 663 | Modify the `out` directory, ninja args, and test name as appropriate, and save |
| 664 | the script in `~/checkrev.sh`. Then run: |
| 665 | |
Mathias Bynens | 172fc6b | 2018-09-05 09:39:43 | [diff] [blame] | 666 | ```bash |
Steve Kobes | e123a3d4 | 2017-07-20 01:20:30 | [diff] [blame] | 667 | chmod u+x ~/checkrev.sh # mark script as executable |
| 668 | git bisect start <badrev> <goodrev> |
| 669 | git bisect run ~/checkrev.sh |
| 670 | git bisect reset # quit the bisect session |
| 671 | ``` |
| 672 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 673 | ## Rebaselining Web Tests |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 674 | |
Xianzhu Wang | 61d49d5 | 2021-07-31 16:44:53 | [diff] [blame] | 675 | See [How to rebaseline](./web_test_expectations.md#How-to-rebaseline). |
Xianzhu Wang | 95d0bac3 | 2017-06-05 21:09:39 | [diff] [blame] | 676 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 677 | ## Known Issues |
| 678 | |
| 679 | See |
| 680 | [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] | 681 | for issues related to Blink tools, include the web test runner. |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 682 | |
pwnall | ae101a5f | 2016-11-08 00:24:38 | [diff] [blame] | 683 | * If QuickTime is not installed, the plugin tests |
| 684 | `fast/dom/object-embed-plugin-scripting.html` and |
| 685 | `plugins/embed-attributes-setting.html` are expected to fail. |
Steve Kobes | 5636fff | 2024-12-05 15:04:50 | [diff] [blame] | 686 | * Fluent scrollbar rendering has some tweaks to geometry and behavior that are |
| 687 | just for web tests. These are described in the |
| 688 | [Fluent Scrollbars Visual Spec](https://bit.ly/fluent-scrollbars-visual-spec) |
| 689 | under "Special rendering - Web tests". We'd like to remove them eventually |
| 690 | ([crbug.com/382298324](https://crbug.com/382298324)). |