blob: 6228a8b092e4d9e8728f99cdc3ad93b08ad56d56 [file] [log] [blame] [view]
dmazzoni2f489752017-02-16 03:39:161# ChromeVox (for developers)
2
3ChromeVox is the built-in screen reader on Chrome OS. It was originally
Anastasia Helfinstein780f4c342023-07-16 04:49:114developed as a separate extension but over time it has been incorporated into
5the operating system itself. Now the code lives inside of the Chromium
6tree and it's built and shipped as part of Chrome OS.
dmazzoni2f489752017-02-16 03:39:167
David Tsengc4b43012018-04-11 04:10:278NOTE: ChromeVox ships also as an extension on the Chrome webstore. This version
9of 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
11OS.
12
Anastasia Helfinstein780f4c342023-07-16 04:49:1113To start or stop ChromeVox, press Ctrl+Alt+Z on your ChromeOS device at any
14time.
dmazzoni2f489752017-02-16 03:39:1615
16## Developer Info
17
Anastasia Helfinstein4bb719552019-11-21 19:02:5118Code location: ```chrome/browser/resources/chromeos/accessibility/chromevox```
dmazzoni2f489752017-02-16 03:39:1619
20Ninja target: it's built as part of "chrome", but you can build and run
James Cook1380ad162018-10-25 00:51:1921browser_tests to test it (Chrome OS target only - you must have target_os =
dmazzoni2f489752017-02-16 03:39:1622"chromeos" in your GN args first).
23
24## Developing On Linux
25
26ChromeVox for Chrome OS development is done on Linux.
27
28See [ChromeVox on Desktop Linux](chromevox_on_desktop_linux.md)
29for more information.
30
Anastasia Helfinstein780f4c342023-07-16 04:49:1131## Code Structure
32
33The `chromevox/` extension directory is broken into subdirectories, based on
34what context the code runs in. The different contexts are as follows:
35
36* The background context (`chromevox/background/`) contains the bulk of the
37ChromeVox logic, and runs in the background page (soon to be a background
38service worker). To group code by its logical function, it has the following
39subdirectories:
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 Helfinstein64e4676e2023-12-28 21:00:1954 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 Helfinstein780f4c342023-07-16 04:49:1156
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
61injected into web pages. At this point, this is only used to support the Google
62Docs workaround. When that is resolved, it is anticipated this directory will be
63removed.
64
65* The learn mode context (`chromevox/learn_mode/`) contains the code to render
66and 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
69the ChromeVox log page.
70
71* The options context (`chromevox/options/`) contains the code for the ChromeVox
72settings page. There is an ongoing effort to migrate this page into the ChromeOS
73settings app, after which this directory will be unneeded.
74
75* The panel context (`chromevox/panel/`) contains the code that renders and
76performs the logic of the ChromeVox panel, shown at the top of the screen. When
77the onscreen command menus are shown, that is also rendered in this context.
78
79* The tutorial context (`chromevox/tutorial/`) contains resources used
80exclusively by the ChromeVox tutorial.
81
82Other subdirectories also have specific purposes:
83
84* The common directory (`chromevox/common/`) contains files that can safely be
85shared between multiple contexts. These files must have no global state, as each
86context has its own global namespace. To get information between the contexts,
87bridge objects are used to pass structured messages. Any data passed through
88these bridges loses any and all class information, as it is converted to JSON in
89the 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
95short indicator sounds (earcons) used by ChromeVox to express information
96without words.
97
98* The images directory (`chromevox/images/`) contains any images used in any
99context.
100
101* The testing directory (`chromevox/testing/`) contains files that are used
102exclusively in testing.
103
104* The third_party directory (`chromevox/third_party`) contains open source code
105from other developers that is used in the ChromeVox extension.
106
107* The tools directory (`chromevox/tools`) contains python scrips used for
108building ChromeVox. Eventually these should be moved into the common
109accessibility directory.
110
dmazzoni2f489752017-02-16 03:39:16111## Debugging ChromeVox
112
113There are options available that may assist in debugging ChromeVox. Here are a
114few use cases.
115
116### Feature development
117
118When developing a new feature, it may be helpful to save time by not having to
119go through a compile cycle. This can be achieved by setting
120```chromevox_compress_js``` to 0 in
Anastasia Helfinstein4bb719552019-11-21 19:02:51121chrome/browser/resources/chromeos/accessibility/chromevox/BUILD.gn, or by using
122a debug build.
dmazzoni2f489752017-02-16 03:39:16123
124In a debug build or with chromevox_compress_js off, the unflattened files in the
Anastasia Helfinstein4bb719552019-11-21 19:02:51125Chrome out directory
126(e.g. out/Release/resources/chromeos/accessibility/chromevox/). Now you
dmazzoni2f489752017-02-16 03:39:16127can hack directly on the copy of ChromeVox in out/ and toggle ChromeVox to pick
128up your changes (via Ctrl+Alt+Z).
129
130### Fixing bugs
131
132The easiest way to debug ChromeVox is from an external browser. Start Chrome
133with this command-line flag:
134
135```out/Release/chrome --remote-debugging-port=9222```
136
137Now open http://localhost:9222 in a separate instance of the browser, and debug the ChromeVox extension background page from there.
138
David Landelld341c8deb2017-08-24 16:14:00139Another option is to use emacs indium (available through M-x
dmazzoni2f489752017-02-16 03:39:16140package-list-packages).
141
142It also talks to localhost:9222 but integrates more tightly into emacs instead.
143
144Another option is to use the built-in developer console. Go to the
145ChromeVox options page with Search+Shift+o, o; then, substitute the
146options.html path with background.html”, and then open up the
147inspector.
148
sahok608f2972021-02-04 05:16:13149### Debugging ChromeOS
150
151To debug ChromeVox in ChromeOS, you need to add the command-line flag to the
152config file in device under test(DUT) instead of starting chrome from command
153line.
154
155```
156(dut) $ echo " --remote-debugging-port=9222 " >> /etc/chrome_dev.conf
157(dut) $ restart ui
158```
159
160This 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
163You need to ssh from your development device into your DUT forwarding port 9222
164to open ChromeVox extension background page in your dev device, for example
165```
166ssh my_crbook -L 3333:localhost:9222
167```
168
169Then open the forwarded port in the development device, http://localhost:3333 in
170the example.
171
172You 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
180See
181[Chromium OS Doc](https://chromium.googlesource.com/chromiumos/docs/+/HEAD/developer_mode.md#disable-verity)
182for more information about removing rootfs verification.
183
dmazzoni2f489752017-02-16 03:39:16184### Running tests
185
James Cook1380ad162018-10-25 00:51:19186Build the browser_tests target. To run lots of tests in parallel, run it like
187this:
dmazzoni2f489752017-02-16 03:39:16188
James Cook1380ad162018-10-25 00:51:19189```
190out/Release/browser_tests --test-launcher-jobs=20 --gtest_filter=ChromeVox*
191```
dmazzoni2f489752017-02-16 03:39:16192
James Cook1380ad162018-10-25 00:51:19193Use a narrower test filter if you only want to run some of the tests. For
194example, most of the ChromeVox Next tests have "E2E" in them (for "end-to-end"),
195so to only run those:
dmazzoni2f489752017-02-16 03:39:16196
Anastasia Helfinsteinda15134f2022-11-21 23:42:49197```out/Release/browser_tests --test-launcher-jobs=20 --gtest_filter="*ChromeVox*E2E*"```