Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 1 | # Running web tests using the content shell |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 2 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 3 | ## Compiling |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 4 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 5 | If you want to run web tests, |
| 6 | [build the target `blink_tests`](web_tests.md); this includes all the other |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 7 | binaries required to run the tests. |
| 8 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 9 | ## Running |
| 10 | |
| 11 | ### Using `run_web_tests.py` |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 12 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 13 | You can run web tests using `run_web_tests.py` (in |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 14 | `src/third_party/blink/tools`). |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 15 | |
| 16 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 17 | python third_party/blink/tools/run_web_tests.py storage/indexeddb |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 18 | ``` |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 19 | To see a complete list of arguments supported, run with `--help`. |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 20 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 21 | ***promo |
| 22 | You can add `<path>/third_party/blink/tools` into `PATH` so that you can |
| 23 | run it from anywhere without the full path. |
| 24 | *** |
| 25 | |
| 26 | ### Run Web Tests Directly with Content Shell |
| 27 | |
| 28 | In some cases (e.g. for debugging), you can run web tests directly with |
| 29 | Content Shell executable, with the `--run-web-tests` flag: |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 30 | |
| 31 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 32 | out/Default/content_shell --run-web-tests <url>|<full_test_source_path>|<relative_test_path> |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 33 | ``` |
| 34 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 35 | `<relative_test_path>` is relative to the [web_tests](../../third_party/blink/web_tests) |
| 36 | directory, regardless of the current directory. |
| 37 | |
| 38 | For example: |
| 39 | |
| 40 | ```bash |
| 41 | out/Default/content_shell --run-web-tests fast/forms/001.html |
| 42 | ``` |
| 43 | or |
| 44 | |
| 45 | ```bash |
| 46 | out/Default/content_shell --run-web-tests \ |
| 47 | /home/user/chrome/src/third_party/blink/web_tests/fast/forms/001.html |
| 48 | ``` |
| 49 | or |
| 50 | |
| 51 | ```bash |
| 52 | out/Default/content_shell --run-web-tests ~/test/temp-test.html |
| 53 | ``` |
| 54 | |
| 55 | By default, it dumps the text result only (as the dump of pixels and audio |
Robert Ma | 0d0b664 | 2019-07-18 19:12:00 | [diff] [blame] | 56 | binary data is not human readable) and quits. This can meet the requirement of |
| 57 | most debugging requirements. If you need to interactively debug the test page |
| 58 | (e.g. using devtools), you'll need to run Content Shell [as a simple |
| 59 | browser](#As-a-simple-browser). |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 60 | |
Robert Ma | 0d0b664 | 2019-07-18 19:12:00 | [diff] [blame] | 61 | In rare cases, to run Content Shell in the exact same way as |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 62 | `run_web_tests.py` runs it, you need to run it in the |
| 63 | [protocol mode](../../content_shell/browser/web_test/test_info_extractor.h). |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 64 | |
| 65 | *** note |
| 66 | On the Mac, use `Content Shell.app`, not `content_shell`. |
| 67 | |
| 68 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 69 | out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell ... |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 70 | ``` |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 71 | On Windows, use `content_shell.exe`. |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 72 | *** |
| 73 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 74 | #### Running HTTP Tests in Content Shell |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 75 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 76 | HTTP tests reside under [web_tests/http/tests](../../third_party/blink/web_tests/http/tests). |
| 77 | You need to start a web server first: |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 78 | |
| 79 | ```bash |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 80 | python third_party/blink/tools/run_blink_httpd.py |
| 81 | ``` |
| 82 | Then run the test with a localhost URL: |
| 83 | |
| 84 | ```bash |
| 85 | out/Default/content_shell --run-web-tests http://localhost:8000/<test> |
| 86 | ``` |
| 87 | |
| 88 | #### Running WPT Tests in Content Shell |
| 89 | |
| 90 | Similar to HTTP tests, many WPT (a.k.a. web-platform-tests under |
| 91 | [web_tests/external/wpt](../../third_party/blink/web_tests/external/wpt) directory) |
| 92 | tests require some setup before running in Content Shell: |
| 93 | |
| 94 | ```bash |
| 95 | python third_party/blink/tools/run_blink_wptserve.py |
| 96 | ``` |
| 97 | Then run the test: |
| 98 | |
| 99 | ```bash |
| 100 | out/Default/content_shell --run-web-tests http://localhost:8001/<test> |
| 101 | ``` |
Robert Ma | 0d0b664 | 2019-07-18 19:12:00 | [diff] [blame] | 102 | |
| 103 | If the test requires HTTPS (e.g. the file name contains ".https."), use the |
| 104 | following command instead: |
| 105 | |
| 106 | ```bash |
| 107 | out/Default/content_shell --run-web-tests https://localhost:8444/<test> |
| 108 | ``` |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 109 | |
| 110 | ### As a simple browser |
| 111 | |
| 112 | You can run the shell directly as a simple browser: |
| 113 | |
| 114 | ```bash |
| 115 | out/Default/content_shell |
| 116 | ``` |
| 117 | |
| 118 | This allows you see how your changes look in Chromium. You can inspect the page |
| 119 | by right clicking and selecting 'Inspect Element'. |
| 120 | |
| 121 | You can also use `--remote-debugging-port` |
| 122 | |
| 123 | ```bash |
| 124 | out/Default/content_shell --remote-debugging-port=9222 |
| 125 | ``` |
| 126 | and open `http://localhost:9222` from another browser to inspect the page. |
| 127 | This is useful when you don't want DevTools to run in the same Content Shell, |
| 128 | e.g. when you are logging a lot and don't want the log from DevTools |
| 129 | or when DevTools is unstable in the current revision due to some bugs. |
| 130 | |
Robert Ma | 0d0b664 | 2019-07-18 19:12:00 | [diff] [blame] | 131 | #### Debug WPT |
| 132 | |
| 133 | If you want to debug WPT with devtools in Content Shell, you will first need to |
| 134 | start the server: |
| 135 | |
| 136 | ```bash |
| 137 | python third_party/blink/tools/run_blink_wptserve.py |
| 138 | ``` |
| 139 | |
| 140 | Then start Content Shell with some additional flags: |
| 141 | |
| 142 | ```bash |
| 143 | out/Default/content_shell --enable-experimental-web-platform-features --ignore-certificate-errors --host-resolver-rules="MAP nonexistent.*.test ~NOTFOUND, MAP *.test. 127.0.0.1, MAP *.test 127.0.0.1" |
| 144 | ``` |
| 145 | |
Xianzhu Wang | 0a37e9d | 2019-03-27 21:27:29 | [diff] [blame] | 146 | ## Debugging |
| 147 | |
| 148 | ### `--single-process` |
| 149 | |
| 150 | The command line switch `--single-process` is useful for starting |
| 151 | content_shell in gdb. In most cases, `--single-process` is good for debugging |
| 152 | except when you want to debug the multiple process behavior or when we have |
| 153 | some bug breaking `--single-process` in particular cases. |
| 154 | |
| 155 | ### Web tests |
| 156 | |
| 157 | See [Run Web Tests Directly with Content Shell](#Run-Web-Tests-Directly-with-Content-Shell). |
| 158 | In most cases you don't need `--single-process` because `content_shell` is |
| 159 | in single process mode when running most web tests. |
| 160 | |
| 161 | See [DevTools frontend](../../third_party/blink/renderer/devtools/readme.md#basics) |
| 162 | for the commands that are useful for debugging devtools web tests. |
| 163 | |
| 164 | ### In The Default Multiple Process Mode |
| 165 | |
| 166 | In rare cases, you need to debug Content Shell in multiple process mode. |
| 167 | You can ask Content Shell to wait for you to attach a debugger once it spawns a |
| 168 | renderer process by adding the `--renderer-startup-dialog` flag: |
| 169 | |
| 170 | ```bash |
| 171 | out/Default/content_shell --renderer-startup-dialog --no-sandbox |
pwnall | d8a25072 | 2016-11-09 18:24:03 | [diff] [blame] | 172 | ``` |
| 173 | |
| 174 | Debugging workers and other subprocesses is simpler with |
| 175 | `--wait-for-debugger-children`, which can have one of two values: `plugin` or |
| 176 | `renderer`. |
| 177 | |
| 178 | ## Future Work |
| 179 | |
| 180 | ### Reusing existing testing objects |
| 181 | |
| 182 | To avoid writing (and maintaining!) yet another test controller, it is desirable |
| 183 | to reuse an existing test controller. A possible solution would be to change |
| 184 | DRT's test controller to not depend on DRT's implementation of the Blink |
| 185 | objects, but rather on the Blink interfaces. In addition, we would need to |
| 186 | extract an interface from the test shell object that can be implemented by |
| 187 | content shell. This would allow for directly using DRT's test controller in |
| 188 | content shell. |