Commit 8e2f8002 authored by David Tseng's avatar David Tseng Committed by Chromium LUCI CQ

Convert accessibility common to use ES6 modules

R=dmazzoni@chromium.org, josiahk@chromium.org

AX-Relnotes: n/a
Test: existing browser_tests
Change-Id: Ifc2b85ac0903903f8cc526e4a2154121da8346f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602108Reviewed-by: default avatarJosiah Krutz <josiahk@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839141}
parent e1c02494
...@@ -26,6 +26,7 @@ run_jsbundler("accessibility_common_copied_files") { ...@@ -26,6 +26,7 @@ run_jsbundler("accessibility_common_copied_files") {
sources = [ sources = [
"accessibility_common_loader.js", "accessibility_common_loader.js",
"autoclick/autoclick.js", "autoclick/autoclick.js",
"background.html",
"magnifier/magnifier.js", "magnifier/magnifier.js",
] ]
rewrite_rules = [ rewrite_rules = [
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import {Autoclick} from './autoclick/autoclick.js';
import {Magnifier} from './magnifier/magnifier.js';
/** /**
* Class to manage loading resources depending on which Accessibility features * Class to manage loading resources depending on which Accessibility features
* are enabled. * are enabled.
*/ */
class AccessibilityCommon { export class AccessibilityCommon {
constructor() { constructor() {
/** @private {Autoclick} */ /** @private {Autoclick} */
this.autoclick_ = null; this.autoclick_ = null;
...@@ -86,4 +89,4 @@ class AccessibilityCommon { ...@@ -86,4 +89,4 @@ class AccessibilityCommon {
InstanceChecker.closeExtraInstances(); InstanceChecker.closeExtraInstances();
// Initialize the AccessibilityCommon extension. // Initialize the AccessibilityCommon extension.
var accessibilityCommon = new AccessibilityCommon(); window.accessibilityCommon = new AccessibilityCommon();
...@@ -19,7 +19,7 @@ const AUTOCLICK_FOCUS_RING_DISPLAY_TIME_MS = 250; ...@@ -19,7 +19,7 @@ const AUTOCLICK_FOCUS_RING_DISPLAY_TIME_MS = 250;
/** /**
* Class to manage Automatic Clicks' interaction with the accessibility tree. * Class to manage Automatic Clicks' interaction with the accessibility tree.
*/ */
class Autoclick { export class Autoclick {
constructor() { constructor() {
/** /**
* Whether to blink the focus rings. Disabled during tests due to * Whether to blink the focus rings. Disabled during tests due to
......
...@@ -18,12 +18,16 @@ AutoclickE2ETest = class extends E2ETestBase { ...@@ -18,12 +18,16 @@ AutoclickE2ETest = class extends E2ETestBase {
window.RoleType = chrome.automation.RoleType; window.RoleType = chrome.automation.RoleType;
// Re-initialize AccessibilityCommon with mock AccessibilityPrivate API. // Re-initialize AccessibilityCommon with mock AccessibilityPrivate API.
accessibilityCommon = new AccessibilityCommon(); const reinit = module => {
accessibilityCommon = new module.AccessibilityCommon();
chrome.accessibilityFeatures.autoclick.get({}, () => { chrome.accessibilityFeatures.autoclick.get({}, () => {
// Turn off focus ring blinking for test after autoclick is initialized. // Turn off focus ring blinking for test after autoclick is initialized.
accessibilityCommon.getAutoclickForTest().setNoBlinkFocusRingsForTest(); accessibilityCommon.getAutoclickForTest().setNoBlinkFocusRingsForTest();
}); });
};
// TODO: Clang-format does this and below wrong.
import('/accessibility_common/accessibility_common_loader.js').then(reinit);
} }
/** @override */ /** @override */
......
<!-- Global scripts. -->
<script src="/common/closure_shim.js"></script>
<script src="/common/instance_checker.js"></script>
<script src="/common/event_handler.js"></script>
<!-- Module entry point. -->
<script type="module" src="accessibility_common_loader.js"></script>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/** /**
* Main class for the Chrome OS magnifier. * Main class for the Chrome OS magnifier.
*/ */
class Magnifier { export class Magnifier {
/** /**
* @param {!Magnifier.Type} type The type of magnifier in use. * @param {!Magnifier.Type} type The type of magnifier in use.
*/ */
......
...@@ -174,6 +174,9 @@ TEST_F( ...@@ -174,6 +174,9 @@ TEST_F(
TEST_F('MagnifierE2ETest', 'ScreenMagnifierFocusFollowingPref', function() { TEST_F('MagnifierE2ETest', 'ScreenMagnifierFocusFollowingPref', function() {
this.newCallback(async () => { this.newCallback(async () => {
const module = await import('/accessibility_common/magnifier/magnifier.js');
const Magnifier = module.Magnifier;
// Disable focus following for full screen magnifier, and verify prefs and // Disable focus following for full screen magnifier, and verify prefs and
// state. // state.
await this.setPref(Magnifier.Prefs.SCREEN_MAGNIFIER_FOCUS_FOLLOWING, false); await this.setPref(Magnifier.Prefs.SCREEN_MAGNIFIER_FOCUS_FOLLOWING, false);
......
...@@ -10,14 +10,7 @@ ...@@ -10,14 +10,7 @@
"incognito": "split", "incognito": "split",
{% endif %} {% endif %}
"background": { "background": {
"scripts": [ "page": "accessibility_common/background.html"
"common/closure_shim.js",
"common/instance_checker.js",
"accessibility_common/autoclick/autoclick.js",
"accessibility_common/magnifier/magnifier.js",
"accessibility_common/accessibility_common_loader.js",
"common/event_handler.js"
]
}, },
"permissions": [ "permissions": [
"accessibilityPrivate", "accessibilityPrivate",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment