blob: a23739386cccb91e9c6fec7d05fe5de0993141a8 [file] [log] [blame] [view]
dmazzoni9cd171242017-03-02 06:58:461# Accessibility
2
Aran Gilmane7035589cd2019-05-01 23:47:303Here's a quick overview of all of the locations in the codebase where you'll
4find accessibility tests, and a brief overview of the purpose of all of them.
dmazzoni9cd171242017-03-02 06:58:465
Aran Gilmane7035589cd2019-05-01 23:47:306## Web Tests
dmazzoni9cd171242017-03-02 06:58:467
Aran Gilmane7035589cd2019-05-01 23:47:308This is the primary place where we test accessibility code in Blink. This code
9should have no platform-specific code. Use this to test anything where there's
10any interesting web platform logic, or where you need to be able to query things
11synchronously from the renderer thread to test them.
dmazzoni9cd171242017-03-02 06:58:4612
Aran Gilmane7035589cd2019-05-01 23:47:3013Don't add tests for trivial features like ARIA attributes that we just expose
14directly to the next layer up. In those cases the Blink tests are trivial and
15it's more valuable to test these features at a higher level where we can ensure
16they actually work.
dmazzoni9cd171242017-03-02 06:58:4617
Aran Gilmane7035589cd2019-05-01 23:47:3018Note that many of these tests are inherited from WebKit and the coding style has
19evolved a lot since then. Look for more recent tests as a guide if writing a new
20one.
dmazzoni9cd171242017-03-02 06:58:4621
22Test files:
Jacobo Aragunde Pérezae45fe82021-10-28 09:04:2923[third_party/blink/web_tests/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/accessibility/)
dmazzoni9cd171242017-03-02 06:58:4624
25Source code to AccessibilityController and WebAXObjectProxy:
Jacobo Aragunde Pérezae45fe82021-10-28 09:04:2926[content/web_test/renderer](https://source.chromium.org/chromium/chromium/src/+/main:content/web_test/renderer/)
dmazzoni9cd171242017-03-02 06:58:4627
Josiah Kc405f432020-09-02 04:30:1928First, you'll need to build the tests:
dmazzoni9cd171242017-03-02 06:58:4629```
Josiah Kc405f432020-09-02 04:30:1930autoninja -C out/release blink_tests
dmazzoni9cd171242017-03-02 06:58:4631```
32
Josiah Kc405f432020-09-02 04:30:1933Then, to run all accessibility web tests:
Aran Gilmane7035589cd2019-05-01 23:47:3034
dmazzoni9cd171242017-03-02 06:58:4635```
Josiah Kc405f432020-09-02 04:30:1936third_party/blink/tools/run_web_tests.py --build-directory=out --target=release accessibility/
37```
38
39Or, to run just one test by itself, without invoking the `run_web_tests.py` script:
40
41```
42out/release/content_shell \
Aran Gilmane7035589cd2019-05-01 23:47:3043 --run-web-tests third_party/blink/web_tests/accessibility/name-calc-inputs.html
dmazzoni9cd171242017-03-02 06:58:4644```
45
Aran Gilmane7035589cd2019-05-01 23:47:3046For information on modifying or adding web tests, see the main
Kyungjun Lee91806c62022-10-10 22:24:5747[web tests documentation](../../testing/web_tests.md).
Aran Gilmane7035589cd2019-05-01 23:47:3048
dmazzoni9cd171242017-03-02 06:58:4649## DumpAccessibilityTree tests
50
51This is the best way to write both cross-platform and platform-specific tests
52using only an input HTML file, some magic strings to describe what attributes
53you're interested in, and one or more expectation files to enable checking
54whether the resulting accessibility tree is correct or not. In particular,
55almost no test code is required.
56
Kyungjun Lee91806c62022-10-10 22:24:5757[More documentation on DumpAccessibilityTree](../../../content/test/data/accessibility/readme.md)
dmazzoni9cd171242017-03-02 06:58:4658
59Test files:
Jacobo Aragunde Pérezae45fe82021-10-28 09:04:2960[content/test/data/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:content/test/data/accessibility/)
dmazzoni9cd171242017-03-02 06:58:4661
62Test runner:
Jacobo Aragunde Pérezae45fe82021-10-28 09:04:2963[content/browser/accessibility/dump_accessibility_tree_browsertest.h](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/accessibility/dump_accessibility_tree_browsertest.h)
dmazzoni9cd171242017-03-02 06:58:4664
65To run all tests:
Aran Gilmane7035589cd2019-05-01 23:47:3066
dmazzoni9cd171242017-03-02 06:58:4667```
Aran Gilmane7035589cd2019-05-01 23:47:3068autoninja -C out/release content_browsertests && \
Mark Schillaci00c48fb2019-12-06 18:46:0269 out/release/content_browsertests --gtest_filter="All/DumpAccessibilityTree*"
dmazzoni9cd171242017-03-02 06:58:4670```
71
Chris Harrelson5a4f78f2024-01-11 21:06:0372Expectation baselines for each OS can be generated via:
73
74```
Jonny Wang90ee8a62024-07-01 23:29:0675tools/accessibility/rebase_dump_accessibility_tree_tests.py
Chris Harrelson5a4f78f2024-01-11 21:06:0376```
77
dmazzoni9cd171242017-03-02 06:58:4678## Other content_browsertests
79
Aran Gilmane7035589cd2019-05-01 23:47:3080There are many other tests in content/ that relate to accessibility. All of
81these tests work by launching a full multi-process browser shell, loading a web
82page in a renderer, then accessing the resulting accessibility tree from the
83browser process, and running some test from there.
dmazzoni9cd171242017-03-02 06:58:4684
85To run all tests:
Aran Gilmane7035589cd2019-05-01 23:47:3086
dmazzoni9cd171242017-03-02 06:58:4687```
Aran Gilmane7035589cd2019-05-01 23:47:3088autoninja -C out/release content_browsertests && \
89 out/release/content_browsertests --gtest_filter="*ccessib*"
dmazzoni9cd171242017-03-02 06:58:4690```
91
92## Accessibility unittests
93
94This tests the core accessibility code that's shared by both web and non-web
95accessibility infrastructure.
96
97Code location:
Jacobo Aragunde Pérezae45fe82021-10-28 09:04:2998[ui/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:ui/accessibility/)
99and subdirectories; check the
100[`*_unittest.cc` files](https://source.chromium.org/search?q=path:accessibility%20path:_unittest&sq=&ss=chromium%2Fchromium%2Fsrc:ui%2Faccessibility%2F),
101next to every file that it's being tested.
102
103List of sources:
104[ui/accessibility/BUILD.gn](https://source.chromium.org/chromium/chromium/src/+/main:ui/accessibility/BUILD.gn?q=%22test(%22accessibility_unittests%22)%20%7B%22)
dmazzoni9cd171242017-03-02 06:58:46105
106To run all tests:
Aran Gilmane7035589cd2019-05-01 23:47:30107
dmazzoni9cd171242017-03-02 06:58:46108```
Aran Gilmane7035589cd2019-05-01 23:47:30109autoninja -C out/release accessibility_unittests && \
110 out/release/accessibility_unittests
dmazzoni9cd171242017-03-02 06:58:46111```
112
113## ChromeVox tests
114
James Cook1380ad162018-10-25 00:51:19115ChromeVox tests are part of the browser_tests suite. You must build with
Aran Gilmane7035589cd2019-05-01 23:47:30116`target_os = "chromeos"` in your GN args.
dmazzoni9cd171242017-03-02 06:58:46117
118To run all tests:
Aran Gilmane7035589cd2019-05-01 23:47:30119
dmazzoni9cd171242017-03-02 06:58:46120```
Aran Gilmane7035589cd2019-05-01 23:47:30121autoninja -C out/release browser_tests && \
122 out/release/browser_tests --test-launcher-jobs=20 --gtest_filter=ChromeVox*
dmazzoni9cd171242017-03-02 06:58:46123```
124
Katie Dektar4a165e1b2017-09-27 16:15:13125### Select-To-Speak tests
126
127```
Aran Gilmane7035589cd2019-05-01 23:47:30128autoninja -C out/Default unit_tests browser_tests && \
129 out/Default/unit_tests --gtest_filter=*SelectToSpeak* && \
130 out/Default/browser_tests --gtest_filter=*SelectToSpeak*
Katie Dektar4a165e1b2017-09-27 16:15:13131```
132
Dominic Mazzonib11c82d2018-08-29 17:01:58133## Performance tests
134
Kyungjun Lee91806c62022-10-10 22:24:57135We also have a page on [Performance Tests](./perf.md).
Dominic Mazzonib11c82d2018-08-29 17:01:58136
dmazzoni9cd171242017-03-02 06:58:46137## Other locations of accessibility tests:
138
Aran Gilmane7035589cd2019-05-01 23:47:30139Even this isn't a complete list. The tests described above cover more than 90%
140of the accessibility tests, and the remainder are scattered throughout the
141codebase. Here are a few other locations to check:
dmazzoni9cd171242017-03-02 06:58:46142
Jacobo Aragunde Pérezae45fe82021-10-28 09:04:29143* [chrome/android/javatests/src/org/chromium/chrome/browser/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/javatests/src/org/chromium/chrome/browser/accessibility/)
144* [chrome/browser/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/accessibility/)
145* [chrome/browser/ash/accessibility/](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ash/accessibility/)
146* [ui/chromeos](https://source.chromium.org/chromium/chromium/src/+/main:ui/chromeos/)
147* [ui/views/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/accessibility/)
dmazzoni9cd171242017-03-02 06:58:46148
Katie Dektar4a165e1b2017-09-27 16:15:13149## Helpful flags:
150
151Across all tests there are some helpful flags that will make testing easier.
152
Aran Gilmane7035589cd2019-05-01 23:47:30153* Run tests multiple times in parallel (useful for finding flakes):
154 `--test-launcher-jobs=10`
Katie Dektar4a165e1b2017-09-27 16:15:13155
Aran Gilmane7035589cd2019-05-01 23:47:30156* Filter which tests to run: `--gtest_filter="*Cats*"`