blob: dfecb666555f7b4cc4bbe11190538596df4d3690 [file] [log] [blame]
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/features.gni")
import(
"//chrome/browser/resources/chromeos/accessibility/common/run_jsbundler.gni")
import(
"//chrome/browser/resources/chromeos/accessibility/strings/accessibility_strings.gni")
import("//chrome/common/features.gni")
import("//chrome/test/base/js2gtest.gni")
import("//chrome/test/base/js2gtest.gni")
import("//testing/test.gni")
import("//testing/test.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/liblouis/liblouis_library.gni")
closure_library_dir =
"//third_party/chromevox/third_party/closure-library/closure/goog"
# List of all modules that are included in one or more of the production
# chromevox scripts.
chromevox_modules = [
"braille/braille_display_manager.js",
"braille/braille_input_handler.js",
"braille/braille_key_types.js",
"braille/braille_table.js",
"braille/braille_translator_manager.js",
"braille/expanding_braille_translator.js",
"braille/liblouis.js",
"braille/nav_braille.js",
"braille/pan_strategy.js",
"braille/spans.js",
"chromevox/background/background.js",
"chromevox/background/braille_captions_background.js",
"chromevox/background/injected_script_loader.js",
"chromevox/background/kbexplorer.js",
"chromevox/background/keymaps/key_map.js",
"chromevox/background/mathmaps/math_map.js",
"chromevox/background/options.js",
"chromevox/background/prefs.js",
"chromevox/background/tabs_api_handler.js",
"chromevox/injected/active_indicator.js",
"chromevox/injected/api.js",
"chromevox/injected/api_implementation.js",
"chromevox/injected/api_util.js",
"chromevox/injected/console_tts.js",
"chromevox/injected/event_suspender.js",
"chromevox/injected/event_watcher.js",
"chromevox/injected/history.js",
"chromevox/injected/init_document.js",
"chromevox/injected/init_globals.js",
"chromevox/injected/initial_speech.js",
"chromevox/injected/keyboard_handler.js",
"chromevox/injected/live_regions.js",
"chromevox/injected/mathjax.js",
"chromevox/injected/mathjax_external_util.js",
"chromevox/injected/navigation_history.js",
"chromevox/injected/navigation_manager.js",
"chromevox/injected/navigation_shifter.js",
"chromevox/injected/navigation_speaker.js",
"chromevox/injected/node_breadcrumb.js",
"chromevox/injected/pdf_processor.js",
"chromevox/injected/script_installer.js",
"chromevox/injected/serializer.js",
"chromevox/injected/ui/braille_overlay_widget.js",
"chromevox/injected/ui/context_menu_widget.js",
"chromevox/injected/ui/keyboard_help_widget.js",
"chromevox/injected/ui/node_search_widget.js",
"chromevox/injected/ui/overlay_widget.js",
"chromevox/injected/ui/search_widget.js",
"chromevox/injected/ui/select_widget.js",
"chromevox/injected/ui/spoken_messages.js",
"chromevox/injected/ui/widget.js",
"chromevox/injected/user_commands.js",
"chromevox/injected/user_event_detail.js",
"common/aria_util.js",
"common/aural_style_util.js",
"common/braille_text_handler.js",
"common/braille_util.js",
"common/buildinfo.js",
"common/chromevox.js",
"common/chromevox_json.js",
"common/command_store.js",
"common/composite_tts.js",
"common/content_editable_extractor.js",
"common/cursor.js",
"common/cursor_selection.js",
"common/date_widget.js",
"common/description_util.js",
"common/dom_predicates.js",
"common/dom_util.js",
"common/earcon_util.js",
"common/editable_text.js",
"common/editable_text_area_shadow.js",
"common/editable_text_base.js",
"common/find_util.js",
"common/focus_util.js",
"common/focuser.js",
"common/group_util.js",
"common/interframe.js",
"common/key_sequence.js",
"common/key_util.js",
"common/math_semantic_attr.js",
"common/math_semantic_tree.js",
"common/math_semantic_util.js",
"common/math_util.js",
"common/media_widget.js",
"common/memoize.js",
"common/msgs.js",
"common/nav_description.js",
"common/nav_math_description.js",
"common/node_state.js",
"common/page_selection.js",
"common/platform_util.js",
"common/selection_util.js",
"common/spannable.js",
"common/string_util.js",
"common/table_util.js",
"common/time_widget.js",
"common/traverse_content.js",
"common/traverse_math.js",
"common/traverse_table.js",
"common/traverse_util.js",
"common/xpath_util.js",
"cvox2/background/automation_object_constructor_installer.js",
"cvox2/background/automation_predicate.js",
"cvox2/background/automation_util.js",
"cvox2/background/background.js",
"cvox2/background/base_automation_handler.js",
"cvox2/background/chromevox_state.js",
"cvox2/background/constants.js",
"cvox2/background/cursors.js",
"cvox2/background/desktop_automation_handler.js",
"cvox2/background/earcon_engine.js",
"cvox2/background/editing.js",
"cvox2/background/i_search.js",
"cvox2/background/live_regions.js",
"cvox2/background/next_earcons.js",
"cvox2/background/notifications.js",
"cvox2/background/output.js",
"cvox2/background/panel.js",
"cvox2/background/panel_command.js",
"cvox2/background/panel_menu.js",
"cvox2/background/panel_menu_item.js",
"cvox2/background/sre_browser.js",
"cvox2/background/tabs_automation_handler.js",
"cvox2/background/tree_walker.js",
"cvox2/injected/keyboard_handler.js",
"cvox2/injected/loader.js",
"extensions/searchvox/abstract_result.js",
"extensions/searchvox/constants.js",
"extensions/searchvox/context_menu.js",
"extensions/searchvox/loader.js",
"extensions/searchvox/results.js",
"extensions/searchvox/search.js",
"extensions/searchvox/search_tools.js",
"extensions/searchvox/util.js",
"host/chrome/braille.js",
"host/chrome/braille_background.js",
"host/chrome/classic_earcons.js",
"host/chrome/earcons.js",
"host/chrome/extension_bridge.js",
"host/chrome/host.js",
"host/chrome/mathjax.js",
"host/chrome/tts.js",
"host/chrome/tts_background.js",
"host/chrome/tts_base.js",
"host/interface/abstract_earcons.js",
"host/interface/abstract_host.js",
"host/interface/abstract_mathjax.js",
"host/interface/abstract_tts.js",
"host/interface/braille_interface.js",
"host/interface/mathjax_interface.js",
"host/interface/host_factory.js",
"host/interface/tts_interface.js",
"speech_rules/base_rule_store.js",
"speech_rules/mathml_store.js",
"speech_rules/mathml_store_rules.js",
"speech_rules/mathml_store_util.js",
"speech_rules/math_simple_store.js",
"speech_rules/math_store.js",
"speech_rules/speech_rule_engine.js",
"speech_rules/speech_rule_evaluator.js",
"speech_rules/speech_rule_functions.js",
"speech_rules/speech_rule.js",
"speech_rules/speech_rule_store.js",
"speech_rules/store_util.js",
"walkers/abstract_node_walker.js",
"walkers/abstract_selection_walker.js",
"walkers/abstract_shifter.js",
"walkers/abstract_walker.js",
"walkers/bare_object_walker.js",
"walkers/character_walker.js",
"walkers/column_walker.js",
"walkers/group_walker.js",
"walkers/layout_line_walker.js",
"walkers/math_shifter.js",
"walkers/object_walker.js",
"walkers/row_walker.js",
"walkers/sentence_walker.js",
"walkers/structural_line_walker.js",
"walkers/table_shifter.js",
"walkers/table_walker.js",
"walkers/word_walker.js",
]
# Closure library modules neede by chromevox.
relative_closure_library_modules = [
"i18n/pluralrules.js",
"i18n/ordinalrules.js",
"i18n/messageformat.js",
"string/string.js",
"dom/nodetype.js",
"base.js",
"asserts/asserts.js",
"debug/error.js",
"object/object.js",
]
closure_library_modules =
rebase_path(relative_closure_library_modules, ".", closure_library_dir)
chromevox_out_dir = "$root_out_dir/chromevoxclassic"
group("chromevox") {
deps = [
":accessibility_strings",
":chromevox_background_script",
":chromevox_content_script",
":chromevox_copied_files",
":chromevox_kbexplorer_script",
":chromevox_manifest",
":chromevox_options_script",
":chromevoxclassic_liblouis",
]
}
chromevox_background_script_loader_file = "cvox2/background/loader.js"
chromevox_content_script_loader_file = "chromevox/injected/loader.js"
chromevox_kbexplorer_loader_file = "chromevox/background/kbexplorer_loader.js"
chromevox_options_script_loader_file = "chromevox/background/options_loader.js"
# Instead of setting up one copy target for each subdirectory, use a script
# to copy all files.
run_jsbundler("chromevox_copied_files") {
mode = "copy"
dest_dir = chromevox_out_dir
sources = [
"chromevox/background/background.html",
"chromevox/background/chrome_shared2.css",
"chromevox/background/earcons/alert_modal.ogg",
"chromevox/background/earcons/alert_nonmodal.ogg",
"chromevox/background/earcons/button.ogg",
"chromevox/background/earcons/check_off.ogg",
"chromevox/background/earcons/check_on.ogg",
"chromevox/background/earcons/editable_text.ogg",
"chromevox/background/earcons/invalid_keypress.ogg",
"chromevox/background/earcons/link.ogg",
"chromevox/background/earcons/list_item.ogg",
"chromevox/background/earcons/listbox.ogg",
"chromevox/background/earcons/long_desc.ogg",
"chromevox/background/earcons/math.ogg",
"chromevox/background/earcons/object_close.ogg",
"chromevox/background/earcons/object_enter.ogg",
"chromevox/background/earcons/object_exit.ogg",
"chromevox/background/earcons/object_open.ogg",
"chromevox/background/earcons/object_select.ogg",
"chromevox/background/earcons/page_finish_loading.ogg",
"chromevox/background/earcons/page_start_loading.ogg",
"chromevox/background/earcons/recover_focus.ogg",
"chromevox/background/earcons/selection.ogg",
"chromevox/background/earcons/selection_reverse.ogg",
"chromevox/background/earcons/skip.ogg",
"chromevox/background/earcons/wrap.ogg",
"chromevox/background/earcons/wrap_edge.ogg",
"chromevox/background/kbexplorer.html",
"chromevox/background/keymaps/classic_keymap.json",
"chromevox/background/keymaps/experimental.json",
"chromevox/background/keymaps/flat_keymap.json",
"chromevox/background/keymaps/next_keymap.json",
"chromevox/background/mathmaps/functions/algebra.json",
"chromevox/background/mathmaps/functions/elementary.json",
"chromevox/background/mathmaps/functions/hyperbolic.json",
"chromevox/background/mathmaps/functions/trigonometry.json",
"chromevox/background/mathmaps/symbols/greek-capital.json",
"chromevox/background/mathmaps/symbols/greek-mathfonts.json",
"chromevox/background/mathmaps/symbols/greek-scripts.json",
"chromevox/background/mathmaps/symbols/greek-small.json",
"chromevox/background/mathmaps/symbols/greek-symbols.json",
"chromevox/background/mathmaps/symbols/hebrew_letters.json",
"chromevox/background/mathmaps/symbols/latin-lower-double-accent.json",
"chromevox/background/mathmaps/symbols/latin-lower-normal.json",
"chromevox/background/mathmaps/symbols/latin-lower-phonetic.json",
"chromevox/background/mathmaps/symbols/latin-lower-single-accent.json",
"chromevox/background/mathmaps/symbols/latin-mathfonts.json",
"chromevox/background/mathmaps/symbols/latin-rest.json",
"chromevox/background/mathmaps/symbols/latin-upper-double-accent.json",
"chromevox/background/mathmaps/symbols/latin-upper-normal.json",
"chromevox/background/mathmaps/symbols/latin-upper-single-accent.json",
"chromevox/background/mathmaps/symbols/math_angles.json",
"chromevox/background/mathmaps/symbols/math_arrows.json",
"chromevox/background/mathmaps/symbols/math_characters.json",
"chromevox/background/mathmaps/symbols/math_delimiters.json",
"chromevox/background/mathmaps/symbols/math_digits.json",
"chromevox/background/mathmaps/symbols/math_geometry.json",
"chromevox/background/mathmaps/symbols/math_harpoons.json",
"chromevox/background/mathmaps/symbols/math_non_characters.json",
"chromevox/background/mathmaps/symbols/math_symbols.json",
"chromevox/background/mathmaps/symbols/math_whitespace.json",
"chromevox/background/mathmaps/symbols/other_stars.json",
"chromevox/background/options.css",
"chromevox/background/options.html",
"chromevox/background/options_widgets.css",
"chromevox/injected/api.js",
"chromevox/injected/api_util.js",
"chromevox/injected/mathjax.js",
"chromevox/injected/mathjax_external_util.js",
"cvox2/background/background.html",
"cvox2/background/earcons/control.wav",
"cvox2/background/earcons/selection.wav",
"cvox2/background/earcons/selection_reverse.wav",
"cvox2/background/earcons/skim.wav",
"cvox2/background/earcons/small_room_2.wav",
"cvox2/background/earcons/static.wav",
"cvox2/background/panel.css",
"cvox2/background/panel.html",
"images/chromevox-128.png",
"images/chromevox-16.png",
"images/chromevox-19.png",
"images/chromevox-48.png",
"images/chromevox.svg",
"images/close-19.png",
"images/close-hover-19.png",
"images/options-19.png",
"images/options-hover-19.png",
"images/triangle-6.png",
]
rewrite_rules = [
rebase_path(".", root_build_dir) + ":",
rebase_path(closure_library_dir, root_build_dir) + ":closure",
]
}
liblouis_library("chromevoxclassic_liblouis") {
dest_dir = chromevox_out_dir + "/braille"
}
# TODO(crbug/978200): refactor this into another file like generate_manifest.gni
# to share with other extensions.
template("manifest") {
version_file = "//chrome/VERSION"
version_script = "//build/util/version.py"
template_file = "manifest.json.jinja2"
output_file = invoker.output_file
key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEGBi/oD7Yl/Y16w3+gee/95/EUpRZ2U6c+8orV5ei+3CRsBsoXI/DPGBauZ3rWQ47aQnfoG00sXigFdJA2NhNK9OgmRA2evnsRRbjYm2BG1twpaLsgQPPus3PyczbDCvhFu8k24wzFyEtxLrfxAGBseBPb9QrCz7B4k2QgxD/CwIDAQAB"
action(target_name) {
script = "//chrome/browser/resources/chromeos/accessibility/chromevox/tools/generate_manifest.py"
inputs = [
version_file,
version_script,
]
sources = [ template_file ]
outputs = [ output_file ]
args = [
"--key=$key",
"--version_file=" + rebase_path(version_file, root_build_dir),
"--output_manifest=" + rebase_path(output_file, root_build_dir),
]
args += rebase_path(sources, root_build_dir)
}
}
manifest("chromevox_manifest") {
output_file = "$chromevox_out_dir/manifest.json"
}
template("generate_deps_js") {
if (defined(invoker.rewrite_rules)) {
rewrite_rules = invoker.rewrite_rules
} else {
rewrite_rules = []
}
action(target_name) {
if (defined(invoker.testonly)) {
testonly = invoker.testonly
}
script = "//chrome/browser/resources/chromeos/accessibility/chromevox/tools/generate_deps.py"
inputs = jsbundler_modules
sources = invoker.sources
outputs = [ invoker.output_file ]
args = [
"-o",
rebase_path(invoker.output_file, root_build_dir),
]
foreach(rule, rewrite_rules) {
args += [
"-w",
rule,
]
}
args += rebase_path(sources, root_build_dir)
if (defined(invoker.deps)) {
deps = invoker.deps
}
}
}
template("compress_js") {
run_jsbundler(target_name) {
assert(defined(invoker.output_file))
mode = "compressed_bundle"
modules = chromevox_modules + closure_library_modules
sources = invoker.sources
output_file = invoker.output_file
}
}
compress_js("chromevox_content_script") {
sources = [ chromevox_content_script_loader_file ]
output_file = "$chromevox_out_dir/chromeVoxChromePageScript.js"
}
compress_js("chromevox_kbexplorer_script") {
sources = [ chromevox_kbexplorer_loader_file ]
output_file = "$chromevox_out_dir/chromeVoxKbExplorerScript.js"
}
compress_js("chromevox_options_script") {
sources = [ chromevox_options_script_loader_file ]
output_file = "$chromevox_out_dir/chromeVoxChromeOptionsScript.js"
}
compress_js("chromevox_background_script") {
sources = [ chromevox_background_script_loader_file ]
output_file = "$chromevox_out_dir/chromeVox2ChromeBackgroundScript.js"
}
accessibility_strings("accessibility_strings") {
out_dir = chromevox_out_dir
}
action("chromevox_test_messages_js") {
script = "//chrome/browser/resources/chromeos/accessibility/chromevox/tools/generate_test_messages.py"
sources = [ "$chromevox_out_dir/_locales/en/messages.json.gz" ]
output_file = "$root_out_dir/test_data/ui/accessibility/extensions/chromevoxclassic/host/testing/test_messages.js"
outputs = [ output_file ]
deps = [ ":accessibility_strings" ]
args = [
"-o",
rebase_path(output_file, root_build_dir),
] + rebase_path(sources, root_build_dir)
}
chromevox_test_modules = [
"walkers/walker_unittest_base.js",
"host/testing/earcons.js",
"host/testing/host.js",
"host/testing/tts.js",
"testing/spoken_list_builder.js",
"testing/test_msgs.js",
"testing/tester.js",
] + get_target_outputs(":chromevox_test_messages_js")
generate_deps_js("chromevox_test_deps_js") {
sources = closure_library_modules + chromevox_modules + chromevox_test_modules
output_file = "$target_gen_dir/test_deps.js"
rewrite_rules = [
rebase_path("//", root_build_dir) + ":",
rebase_path("$root_out_dir/test_data", root_build_dir) + ":",
]
deps = [ ":chromevox_test_messages_js" ]
}
js_library("tree_walker") {
sources = [ "cvox2/background/tree_walker.js" ]
deps = [
":automation_predicate",
":constants",
]
externs_list = [
"$externs_path/automation.js",
"$externs_path/chrome_extensions.js",
]
}
js_library("automation_predicate") {
sources = [ "cvox2/background/automation_predicate.js" ]
deps = [ ":constants" ]
externs_list = [
"$externs_path/automation.js",
"$externs_path/chrome_extensions.js",
]
}
js_library("constants") {
sources = [ "cvox2/background/constants.js" ]
}
test("chromevox_tests") {
sources = [
"//chrome/browser/extensions/browsertest_util.cc",
"//chrome/browser/extensions/browsertest_util.h",
"//chrome/browser/ui/webui/web_ui_test_handler.cc",
"//chrome/browser/ui/webui/web_ui_test_handler.h",
"//chrome/test/base/extension_js_browser_test.cc",
"//chrome/test/base/extension_js_browser_test.h",
"//chrome/test/base/extension_load_waiter_one_shot.cc",
"//chrome/test/base/extension_load_waiter_one_shot.h",
"//chrome/test/base/javascript_browser_test.cc",
"//chrome/test/base/javascript_browser_test.h",
"//chrome/test/base/test_chrome_web_ui_controller_factory.cc",
"//chrome/test/base/test_chrome_web_ui_controller_factory.h",
"//chrome/test/base/web_ui_browser_test.cc",
"//chrome/test/base/web_ui_browser_test.h",
]
deps = [
":chromevox_unitjs_tests",
"//base",
"//base:i18n",
"//base/test:test_support",
"//chrome:browser_tests_pak",
"//chrome:packed_resources",
"//chrome:resources",
"//chrome:strings",
"//chrome/browser",
"//chrome/browser/web_applications/components:components",
"//chrome/renderer",
"//chrome/test:browser_tests_runner",
"//chrome/test:test_support",
"//chrome/test:test_support_ui",
"//chrome/test/data:web_ui_test_bindings",
"//chromeos/constants:constants",
"//content/test:test_support",
"//extensions/browser:test_support",
"//testing/gmock",
"//testing/gtest",
]
data = [
"$root_out_dir/chrome_100_percent.pak",
"$root_out_dir/chrome_200_percent.pak",
"$root_out_dir/locales/en-US.pak",
"$root_out_dir/locales/fr.pak",
"$root_out_dir/resources.pak",
"$root_out_dir/chromevoxclassic/",
"$root_out_dir/test_data/ui/accessibility/extensions/chromevoxclassic/",
# Surprisingly, the test uses data from the original location, not the
# copied one.
"//ui/accessibility/extensions/chromevoxclassic",
"//third_party/chromevox/",
]
data += js2gtest_js_libraries
}
js2gtest("chromevox_unitjs_tests") {
test_type = "webui"
sources = [
"chromevox/injected/navigation_manager_test.unitjs",
"chromevox/injected/user_commands_test.unitjs",
"common/aria_util_test.unitjs",
"common/braille_text_handler_test.unitjs",
"common/braille_util_test.unitjs",
"common/content_editable_extractor_test.unitjs",
"common/cursor_selection_test.unitjs",
"common/dom_util_test.unitjs",
"common/editable_text_area_shadow_test.unitjs",
"common/editable_text_test.unitjs",
"common/find_util_test.unitjs",
"common/math_semantic_tree_test.unitjs",
"common/page_selection_test.unitjs",
"common/selection_util_test.unitjs",
"common/string_util_test.unitjs",
"walkers/character_walker_test.unitjs",
"walkers/group_walker_test.unitjs",
"walkers/layout_line_walker_test.unitjs",
"walkers/math_shifter_test.unitjs",
"walkers/object_walker_test.unitjs",
"walkers/sentence_walker_test.unitjs",
"walkers/structural_line_walker_test.unitjs",
"walkers/table_walker_test.unitjs",
"walkers/word_walker_test.unitjs",
]
gen_include_files = [
"//chrome/browser/resources/chromeos/accessibility/common/testing/assert_additions.js",
"//chrome/browser/resources/chromeos/accessibility/common/testing/callback_helper.js",
"//ui/accessibility/extensions/chromevoxclassic/testing/chromevox_unittest_base.js",
]
test_deps_js_outputs = get_target_outputs(":chromevox_test_deps_js")
deps_js = test_deps_js_outputs[0]
deps = [ ":chromevox_test_deps_js" ]
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
}