dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 1 | # Accessibility |
| 2 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 3 | Here's a quick overview of all of the locations in the codebase where you'll |
| 4 | find accessibility tests, and a brief overview of the purpose of all of them. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 5 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 6 | ## Web Tests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 7 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 8 | This is the primary place where we test accessibility code in Blink. This code |
| 9 | should have no platform-specific code. Use this to test anything where there's |
| 10 | any interesting web platform logic, or where you need to be able to query things |
| 11 | synchronously from the renderer thread to test them. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 12 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 13 | Don't add tests for trivial features like ARIA attributes that we just expose |
| 14 | directly to the next layer up. In those cases the Blink tests are trivial and |
| 15 | it's more valuable to test these features at a higher level where we can ensure |
| 16 | they actually work. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 17 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 18 | Note that many of these tests are inherited from WebKit and the coding style has |
| 19 | evolved a lot since then. Look for more recent tests as a guide if writing a new |
| 20 | one. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 21 | |
| 22 | Test files: |
Jacobo Aragunde Pérez | ae45fe8 | 2021-10-28 09:04:29 | [diff] [blame] | 23 | [third_party/blink/web_tests/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/accessibility/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 24 | |
| 25 | Source code to AccessibilityController and WebAXObjectProxy: |
Jacobo Aragunde Pérez | ae45fe8 | 2021-10-28 09:04:29 | [diff] [blame] | 26 | [content/web_test/renderer](https://source.chromium.org/chromium/chromium/src/+/main:content/web_test/renderer/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 27 | |
Josiah K | c405f43 | 2020-09-02 04:30:19 | [diff] [blame] | 28 | First, you'll need to build the tests: |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 29 | ``` |
Josiah K | c405f43 | 2020-09-02 04:30:19 | [diff] [blame] | 30 | autoninja -C out/release blink_tests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 31 | ``` |
| 32 | |
Josiah K | c405f43 | 2020-09-02 04:30:19 | [diff] [blame] | 33 | Then, to run all accessibility web tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 34 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 35 | ``` |
Josiah K | c405f43 | 2020-09-02 04:30:19 | [diff] [blame] | 36 | third_party/blink/tools/run_web_tests.py --build-directory=out --target=release accessibility/ |
| 37 | ``` |
| 38 | |
| 39 | Or, to run just one test by itself, without invoking the `run_web_tests.py` script: |
| 40 | |
| 41 | ``` |
| 42 | out/release/content_shell \ |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 43 | --run-web-tests third_party/blink/web_tests/accessibility/name-calc-inputs.html |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 44 | ``` |
| 45 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 46 | For information on modifying or adding web tests, see the main |
Kyungjun Lee | 91806c6 | 2022-10-10 22:24:57 | [diff] [blame] | 47 | [web tests documentation](../../testing/web_tests.md). |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 48 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 49 | ## DumpAccessibilityTree tests |
| 50 | |
| 51 | This is the best way to write both cross-platform and platform-specific tests |
| 52 | using only an input HTML file, some magic strings to describe what attributes |
| 53 | you're interested in, and one or more expectation files to enable checking |
| 54 | whether the resulting accessibility tree is correct or not. In particular, |
| 55 | almost no test code is required. |
| 56 | |
Kyungjun Lee | 91806c6 | 2022-10-10 22:24:57 | [diff] [blame] | 57 | [More documentation on DumpAccessibilityTree](../../../content/test/data/accessibility/readme.md) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 58 | |
| 59 | Test files: |
Jacobo Aragunde Pérez | ae45fe8 | 2021-10-28 09:04:29 | [diff] [blame] | 60 | [content/test/data/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:content/test/data/accessibility/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 61 | |
| 62 | Test runner: |
Jacobo Aragunde Pérez | ae45fe8 | 2021-10-28 09:04:29 | [diff] [blame] | 63 | [content/browser/accessibility/dump_accessibility_tree_browsertest.h](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/accessibility/dump_accessibility_tree_browsertest.h) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 64 | |
| 65 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 66 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 67 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 68 | autoninja -C out/release content_browsertests && \ |
Mark Schillaci | 00c48fb | 2019-12-06 18:46:02 | [diff] [blame] | 69 | out/release/content_browsertests --gtest_filter="All/DumpAccessibilityTree*" |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 70 | ``` |
| 71 | |
Chris Harrelson | 5a4f78f | 2024-01-11 21:06:03 | [diff] [blame] | 72 | Expectation baselines for each OS can be generated via: |
| 73 | |
| 74 | ``` |
Jonny Wang | 90ee8a6 | 2024-07-01 23:29:06 | [diff] [blame^] | 75 | tools/accessibility/rebase_dump_accessibility_tree_tests.py |
Chris Harrelson | 5a4f78f | 2024-01-11 21:06:03 | [diff] [blame] | 76 | ``` |
| 77 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 78 | ## Other content_browsertests |
| 79 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 80 | There are many other tests in content/ that relate to accessibility. All of |
| 81 | these tests work by launching a full multi-process browser shell, loading a web |
| 82 | page in a renderer, then accessing the resulting accessibility tree from the |
| 83 | browser process, and running some test from there. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 84 | |
| 85 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 86 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 87 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 88 | autoninja -C out/release content_browsertests && \ |
| 89 | out/release/content_browsertests --gtest_filter="*ccessib*" |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 90 | ``` |
| 91 | |
| 92 | ## Accessibility unittests |
| 93 | |
| 94 | This tests the core accessibility code that's shared by both web and non-web |
| 95 | accessibility infrastructure. |
| 96 | |
| 97 | Code location: |
Jacobo Aragunde Pérez | ae45fe8 | 2021-10-28 09:04:29 | [diff] [blame] | 98 | [ui/accessibility](https://source.chromium.org/chromium/chromium/src/+/main:ui/accessibility/) |
| 99 | and 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), |
| 101 | next to every file that it's being tested. |
| 102 | |
| 103 | List 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) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 105 | |
| 106 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 107 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 108 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 109 | autoninja -C out/release accessibility_unittests && \ |
| 110 | out/release/accessibility_unittests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 111 | ``` |
| 112 | |
| 113 | ## ChromeVox tests |
| 114 | |
James Cook | 1380ad16 | 2018-10-25 00:51:19 | [diff] [blame] | 115 | ChromeVox tests are part of the browser_tests suite. You must build with |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 116 | `target_os = "chromeos"` in your GN args. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 117 | |
| 118 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 119 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 120 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 121 | autoninja -C out/release browser_tests && \ |
| 122 | out/release/browser_tests --test-launcher-jobs=20 --gtest_filter=ChromeVox* |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 123 | ``` |
| 124 | |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 125 | ### Select-To-Speak tests |
| 126 | |
| 127 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 128 | autoninja -C out/Default unit_tests browser_tests && \ |
| 129 | out/Default/unit_tests --gtest_filter=*SelectToSpeak* && \ |
| 130 | out/Default/browser_tests --gtest_filter=*SelectToSpeak* |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 131 | ``` |
| 132 | |
Dominic Mazzoni | b11c82d | 2018-08-29 17:01:58 | [diff] [blame] | 133 | ## Performance tests |
| 134 | |
Kyungjun Lee | 91806c6 | 2022-10-10 22:24:57 | [diff] [blame] | 135 | We also have a page on [Performance Tests](./perf.md). |
Dominic Mazzoni | b11c82d | 2018-08-29 17:01:58 | [diff] [blame] | 136 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 137 | ## Other locations of accessibility tests: |
| 138 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 139 | Even this isn't a complete list. The tests described above cover more than 90% |
| 140 | of the accessibility tests, and the remainder are scattered throughout the |
| 141 | codebase. Here are a few other locations to check: |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 142 | |
Jacobo Aragunde Pérez | ae45fe8 | 2021-10-28 09:04:29 | [diff] [blame] | 143 | * [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/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 148 | |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 149 | ## Helpful flags: |
| 150 | |
| 151 | Across all tests there are some helpful flags that will make testing easier. |
| 152 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 153 | * Run tests multiple times in parallel (useful for finding flakes): |
| 154 | `--test-launcher-jobs=10` |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 155 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 156 | * Filter which tests to run: `--gtest_filter="*Cats*"` |