blob: 8fcde45de4660f9fc52c8206137e0efe0f67df6d [file] [log] [blame] [view]
Kent Tamura59ffb022018-11-27 05:30:561# Running web tests using the content shell
pwnalld8a250722016-11-09 18:24:032
Xianzhu Wang0a37e9d2019-03-27 21:27:293## Compiling
pwnalld8a250722016-11-09 18:24:034
Kent Tamura59ffb022018-11-27 05:30:565If you want to run web tests,
6[build the target `blink_tests`](web_tests.md); this includes all the other
pwnalld8a250722016-11-09 18:24:037binaries required to run the tests.
8
Xianzhu Wang0a37e9d2019-03-27 21:27:299## Running
10
11### Using `run_web_tests.py`
pwnalld8a250722016-11-09 18:24:0312
Kent Tamura59ffb022018-11-27 05:30:5613You can run web tests using `run_web_tests.py` (in
Kent Tamuraa045a7f2018-04-25 05:08:1114`src/third_party/blink/tools`).
pwnalld8a250722016-11-09 18:24:0315
16```bash
Xianzhu Wang0a37e9d2019-03-27 21:27:2917python third_party/blink/tools/run_web_tests.py storage/indexeddb
pwnalld8a250722016-11-09 18:24:0318```
Xianzhu Wang0a37e9d2019-03-27 21:27:2919To see a complete list of arguments supported, run with `--help`.
pwnalld8a250722016-11-09 18:24:0320
Xianzhu Wang0a37e9d2019-03-27 21:27:2921***promo
22You can add `<path>/third_party/blink/tools` into `PATH` so that you can
23run it from anywhere without the full path.
24***
25
26### Run Web Tests Directly with Content Shell
27
28In some cases (e.g. for debugging), you can run web tests directly with
29Content Shell executable, with the `--run-web-tests` flag:
pwnalld8a250722016-11-09 18:24:0330
31```bash
Xianzhu Wang0a37e9d2019-03-27 21:27:2932out/Default/content_shell --run-web-tests <url>|<full_test_source_path>|<relative_test_path>
pwnalld8a250722016-11-09 18:24:0333```
34
Xianzhu Wang0a37e9d2019-03-27 21:27:2935`<relative_test_path>` is relative to the [web_tests](../../third_party/blink/web_tests)
36directory, regardless of the current directory.
37
38For example:
39
40```bash
41out/Default/content_shell --run-web-tests fast/forms/001.html
42```
43or
44
45```bash
46out/Default/content_shell --run-web-tests \
47 /home/user/chrome/src/third_party/blink/web_tests/fast/forms/001.html
48```
49or
50
51```bash
52out/Default/content_shell --run-web-tests ~/test/temp-test.html
53```
54
55By default, it dumps the text result only (as the dump of pixels and audio
Robert Ma0d0b6642019-07-18 19:12:0056binary data is not human readable) and quits. This can meet the requirement of
57most 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
59browser](#As-a-simple-browser).
Xianzhu Wang0a37e9d2019-03-27 21:27:2960
Robert Ma0d0b6642019-07-18 19:12:0061In rare cases, to run Content Shell in the exact same way as
Xianzhu Wang0a37e9d2019-03-27 21:27:2962`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).
pwnalld8a250722016-11-09 18:24:0364
65*** note
66On the Mac, use `Content Shell.app`, not `content_shell`.
67
68```bash
Xianzhu Wang0a37e9d2019-03-27 21:27:2969out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell ...
pwnalld8a250722016-11-09 18:24:0370```
Xianzhu Wang0a37e9d2019-03-27 21:27:2971On Windows, use `content_shell.exe`.
pwnalld8a250722016-11-09 18:24:0372***
73
Xianzhu Wang0a37e9d2019-03-27 21:27:2974#### Running HTTP Tests in Content Shell
pwnalld8a250722016-11-09 18:24:0375
Xianzhu Wang0a37e9d2019-03-27 21:27:2976HTTP tests reside under [web_tests/http/tests](../../third_party/blink/web_tests/http/tests).
77You need to start a web server first:
pwnalld8a250722016-11-09 18:24:0378
79```bash
Xianzhu Wang0a37e9d2019-03-27 21:27:2980python third_party/blink/tools/run_blink_httpd.py
81```
82Then run the test with a localhost URL:
83
84```bash
85out/Default/content_shell --run-web-tests http://localhost:8000/<test>
86```
87
88#### Running WPT Tests in Content Shell
89
90Similar 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)
92tests require some setup before running in Content Shell:
93
94```bash
95python third_party/blink/tools/run_blink_wptserve.py
96```
97Then run the test:
98
99```bash
100out/Default/content_shell --run-web-tests http://localhost:8001/<test>
101```
Robert Ma0d0b6642019-07-18 19:12:00102
103If the test requires HTTPS (e.g. the file name contains ".https."), use the
104following command instead:
105
106```bash
107out/Default/content_shell --run-web-tests https://localhost:8444/<test>
108```
Xianzhu Wang0a37e9d2019-03-27 21:27:29109
110### As a simple browser
111
112You can run the shell directly as a simple browser:
113
114```bash
115out/Default/content_shell
116```
117
118This allows you see how your changes look in Chromium. You can inspect the page
119by right clicking and selecting 'Inspect Element'.
120
121You can also use `--remote-debugging-port`
122
123```bash
124out/Default/content_shell --remote-debugging-port=9222
125```
126and open `http://localhost:9222` from another browser to inspect the page.
127This is useful when you don't want DevTools to run in the same Content Shell,
128e.g. when you are logging a lot and don't want the log from DevTools
129or when DevTools is unstable in the current revision due to some bugs.
130
Robert Ma0d0b6642019-07-18 19:12:00131#### Debug WPT
132
133If you want to debug WPT with devtools in Content Shell, you will first need to
134start the server:
135
136```bash
137python third_party/blink/tools/run_blink_wptserve.py
138```
139
140Then start Content Shell with some additional flags:
141
142```bash
143out/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 Wang0a37e9d2019-03-27 21:27:29146## Debugging
147
148### `--single-process`
149
150The command line switch `--single-process` is useful for starting
151content_shell in gdb. In most cases, `--single-process` is good for debugging
152except when you want to debug the multiple process behavior or when we have
153some bug breaking `--single-process` in particular cases.
154
155### Web tests
156
157See [Run Web Tests Directly with Content Shell](#Run-Web-Tests-Directly-with-Content-Shell).
158In most cases you don't need `--single-process` because `content_shell` is
159in single process mode when running most web tests.
160
161See [DevTools frontend](../../third_party/blink/renderer/devtools/readme.md#basics)
162for the commands that are useful for debugging devtools web tests.
163
164### In The Default Multiple Process Mode
165
166In rare cases, you need to debug Content Shell in multiple process mode.
167You can ask Content Shell to wait for you to attach a debugger once it spawns a
168renderer process by adding the `--renderer-startup-dialog` flag:
169
170```bash
171out/Default/content_shell --renderer-startup-dialog --no-sandbox
pwnalld8a250722016-11-09 18:24:03172```
173
174Debugging 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
182To avoid writing (and maintaining!) yet another test controller, it is desirable
183to reuse an existing test controller. A possible solution would be to change
184DRT's test controller to not depend on DRT's implementation of the Blink
185objects, but rather on the Blink interfaces. In addition, we would need to
186extract an interface from the test shell object that can be implemented by
187content shell. This would allow for directly using DRT's test controller in
188content shell.