dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 1 | # ChromeVox (for developers) |
| 2 | |
| 3 | ChromeVox is the built-in screen reader on Chrome OS. It was originally |
Anastasia Helfinstein | 780f4c34 | 2023-07-16 04:49:11 | [diff] [blame] | 4 | developed as a separate extension but over time it has been incorporated into |
| 5 | the operating system itself. Now the code lives inside of the Chromium |
| 6 | tree and it's built and shipped as part of Chrome OS. |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 7 | |
David Tseng | c4b4301 | 2018-04-11 04:10:27 | [diff] [blame] | 8 | NOTE: ChromeVox ships also as an extension on the Chrome webstore. This version |
| 9 | of ChromeVox is known as ChromeVox Classic and is loosely related to ChromeVox |
| 10 | (on Chrome OS). All references to ChromeVox relate only to ChromeVox on Chrome |
| 11 | OS. |
| 12 | |
Anastasia Helfinstein | 780f4c34 | 2023-07-16 04:49:11 | [diff] [blame] | 13 | To start or stop ChromeVox, press Ctrl+Alt+Z on your ChromeOS device at any |
| 14 | time. |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 15 | |
| 16 | ## Developer Info |
| 17 | |
Anastasia Helfinstein | 4bb71955 | 2019-11-21 19:02:51 | [diff] [blame] | 18 | Code location: ```chrome/browser/resources/chromeos/accessibility/chromevox``` |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 19 | |
| 20 | Ninja target: it's built as part of "chrome", but you can build and run |
James Cook | 1380ad16 | 2018-10-25 00:51:19 | [diff] [blame] | 21 | browser_tests to test it (Chrome OS target only - you must have target_os = |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 22 | "chromeos" in your GN args first). |
| 23 | |
| 24 | ## Developing On Linux |
| 25 | |
| 26 | ChromeVox for Chrome OS development is done on Linux. |
| 27 | |
| 28 | See [ChromeVox on Desktop Linux](chromevox_on_desktop_linux.md) |
| 29 | for more information. |
| 30 | |
Anastasia Helfinstein | 780f4c34 | 2023-07-16 04:49:11 | [diff] [blame] | 31 | ## Code Structure |
| 32 | |
| 33 | The `chromevox/` extension directory is broken into subdirectories, based on |
| 34 | what context the code runs in. The different contexts are as follows: |
| 35 | |
| 36 | * The background context (`chromevox/background/`) contains the bulk of the |
| 37 | ChromeVox logic, and runs in the background page (soon to be a background |
| 38 | service worker). To group code by its logical function, it has the following |
| 39 | subdirectories: |
| 40 | |
| 41 | - `chromevox/background/braille/`, which contains logic around braille |
| 42 | input/output. |
| 43 | |
| 44 | - `chromevox/background/editing/`, which contains the logic to handle input |
| 45 | into text fields. |
| 46 | |
| 47 | - `chromevox/background/event/`, which contains the logic that handles |
| 48 | events from the various APIs. |
| 49 | |
| 50 | - `chromevox/background/logging/`, which contains logic to generate the |
| 51 | content shown on the log page. |
| 52 | |
| 53 | - `chromevox/background/output/`, which contains the logic to generate the |
Anastasia Helfinstein | 64e4676e | 2023-12-28 21:00:19 | [diff] [blame] | 54 | text that is spoken or sent to the braille display. More details are in |
| 55 | [the README.md file within that directory](/chrome/browser/resources/chromeos/accessibility/chromevox/background/output/). |
Anastasia Helfinstein | 780f4c34 | 2023-07-16 04:49:11 | [diff] [blame] | 56 | |
| 57 | - `chromevox/background/panel/`, which contains the logic to support the |
| 58 | ChromeVox panel. |
| 59 | |
| 60 | * The content script context (`chromevox/injected/`) contains the code that is |
| 61 | injected into web pages. At this point, this is only used to support the Google |
| 62 | Docs workaround. When that is resolved, it is anticipated this directory will be |
| 63 | removed. |
| 64 | |
| 65 | * The learn mode context (`chromevox/learn_mode/`) contains the code to render |
| 66 | and run the ChromeVox learn mode (which is different from the tutorial). |
| 67 | |
| 68 | * The log context (`chromevox/log_page/`) contains the code specific to showing |
| 69 | the ChromeVox log page. |
| 70 | |
| 71 | * The options context (`chromevox/options/`) contains the code for the ChromeVox |
| 72 | settings page. There is an ongoing effort to migrate this page into the ChromeOS |
| 73 | settings app, after which this directory will be unneeded. |
| 74 | |
| 75 | * The panel context (`chromevox/panel/`) contains the code that renders and |
| 76 | performs the logic of the ChromeVox panel, shown at the top of the screen. When |
| 77 | the onscreen command menus are shown, that is also rendered in this context. |
| 78 | |
| 79 | * The tutorial context (`chromevox/tutorial/`) contains resources used |
| 80 | exclusively by the ChromeVox tutorial. |
| 81 | |
| 82 | Other subdirectories also have specific purposes: |
| 83 | |
| 84 | * The common directory (`chromevox/common/`) contains files that can safely be |
| 85 | shared between multiple contexts. These files must have no global state, as each |
| 86 | context has its own global namespace. To get information between the contexts, |
| 87 | bridge objects are used to pass structured messages. Any data passed through |
| 88 | these bridges loses any and all class information, as it is converted to JSON in |
| 89 | the process of being sent. |
| 90 | |
| 91 | - The subdirectory `chromevox/common/braille/` contains common logic |
| 92 | specific to braille |
| 93 | |
| 94 | * The earcons directory (`chromevox/earcons/`) contains the audio files for any |
| 95 | short indicator sounds (earcons) used by ChromeVox to express information |
| 96 | without words. |
| 97 | |
| 98 | * The images directory (`chromevox/images/`) contains any images used in any |
| 99 | context. |
| 100 | |
| 101 | * The testing directory (`chromevox/testing/`) contains files that are used |
| 102 | exclusively in testing. |
| 103 | |
| 104 | * The third_party directory (`chromevox/third_party`) contains open source code |
| 105 | from other developers that is used in the ChromeVox extension. |
| 106 | |
| 107 | * The tools directory (`chromevox/tools`) contains python scrips used for |
| 108 | building ChromeVox. Eventually these should be moved into the common |
| 109 | accessibility directory. |
| 110 | |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 111 | ## Debugging ChromeVox |
| 112 | |
| 113 | There are options available that may assist in debugging ChromeVox. Here are a |
| 114 | few use cases. |
| 115 | |
| 116 | ### Feature development |
| 117 | |
| 118 | When developing a new feature, it may be helpful to save time by not having to |
| 119 | go through a compile cycle. This can be achieved by setting |
| 120 | ```chromevox_compress_js``` to 0 in |
Anastasia Helfinstein | 4bb71955 | 2019-11-21 19:02:51 | [diff] [blame] | 121 | chrome/browser/resources/chromeos/accessibility/chromevox/BUILD.gn, or by using |
| 122 | a debug build. |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 123 | |
| 124 | In a debug build or with chromevox_compress_js off, the unflattened files in the |
Anastasia Helfinstein | 4bb71955 | 2019-11-21 19:02:51 | [diff] [blame] | 125 | Chrome out directory |
| 126 | (e.g. out/Release/resources/chromeos/accessibility/chromevox/). Now you |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 127 | can hack directly on the copy of ChromeVox in out/ and toggle ChromeVox to pick |
| 128 | up your changes (via Ctrl+Alt+Z). |
| 129 | |
| 130 | ### Fixing bugs |
| 131 | |
| 132 | The easiest way to debug ChromeVox is from an external browser. Start Chrome |
| 133 | with this command-line flag: |
| 134 | |
| 135 | ```out/Release/chrome --remote-debugging-port=9222``` |
| 136 | |
| 137 | Now open http://localhost:9222 in a separate instance of the browser, and debug the ChromeVox extension background page from there. |
| 138 | |
David Landell | d341c8deb | 2017-08-24 16:14:00 | [diff] [blame] | 139 | Another option is to use emacs indium (available through M-x |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 140 | package-list-packages). |
| 141 | |
| 142 | It also talks to localhost:9222 but integrates more tightly into emacs instead. |
| 143 | |
| 144 | Another option is to use the built-in developer console. Go to the |
| 145 | ChromeVox options page with Search+Shift+o, o; then, substitute the |
| 146 | “options.html” path with “background.html”, and then open up the |
| 147 | inspector. |
| 148 | |
sahok | 608f297 | 2021-02-04 05:16:13 | [diff] [blame] | 149 | ### Debugging ChromeOS |
| 150 | |
| 151 | To debug ChromeVox in ChromeOS, you need to add the command-line flag to the |
| 152 | config file in device under test(DUT) instead of starting chrome from command |
| 153 | line. |
| 154 | |
| 155 | ``` |
| 156 | (dut) $ echo " --remote-debugging-port=9222 " >> /etc/chrome_dev.conf |
| 157 | (dut) $ restart ui |
| 158 | ``` |
| 159 | |
| 160 | This is also written in |
| 161 | [Simple Chrome Workflow Doc](https://chromium.googlesource.com/chromiumos/docs/+/HEAD/simple_chrome_workflow.md#command_line-flags-and-environment-variables). |
| 162 | |
| 163 | You need to ssh from your development device into your DUT forwarding port 9222 |
| 164 | to open ChromeVox extension background page in your dev device, for example |
| 165 | ``` |
| 166 | ssh my_crbook -L 3333:localhost:9222 |
| 167 | ``` |
| 168 | |
| 169 | Then open the forwarded port in the development device, http://localhost:3333 in |
| 170 | the example. |
| 171 | |
| 172 | You may need to remove rootfs verification to write to `/etc/chrome_dev.conf`. |
| 173 | |
| 174 | ``` |
| 175 | (dut) $ crossystem dev_boot_signed_only=0 |
| 176 | (dut) $ sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification |
| 177 | (dut) $ reboot |
| 178 | ``` |
| 179 | |
| 180 | See |
| 181 | [Chromium OS Doc](https://chromium.googlesource.com/chromiumos/docs/+/HEAD/developer_mode.md#disable-verity) |
| 182 | for more information about removing rootfs verification. |
| 183 | |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 184 | ### Running tests |
| 185 | |
James Cook | 1380ad16 | 2018-10-25 00:51:19 | [diff] [blame] | 186 | Build the browser_tests target. To run lots of tests in parallel, run it like |
| 187 | this: |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 188 | |
James Cook | 1380ad16 | 2018-10-25 00:51:19 | [diff] [blame] | 189 | ``` |
| 190 | out/Release/browser_tests --test-launcher-jobs=20 --gtest_filter=ChromeVox* |
| 191 | ``` |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 192 | |
James Cook | 1380ad16 | 2018-10-25 00:51:19 | [diff] [blame] | 193 | Use a narrower test filter if you only want to run some of the tests. For |
| 194 | example, most of the ChromeVox Next tests have "E2E" in them (for "end-to-end"), |
| 195 | so to only run those: |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 196 | |
Anastasia Helfinstein | da15134f | 2022-11-21 23:42:49 | [diff] [blame] | 197 | ```out/Release/browser_tests --test-launcher-jobs=20 --gtest_filter="*ChromeVox*E2E*"``` |