1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
loader.lazyRequireGetter(
this,
"isWebRenderEnabled",
"devtools/server/actors/utils/accessibility",
true
);
const PREF_ACCESSIBILITY_FORCE_DISABLED = "accessibility.force_disabled";
function checkAccessibilityState(accessibility, parentAccessibility, expected) {
const { enabled } = accessibility;
const { canBeDisabled, canBeEnabled } = parentAccessibility;
is(enabled, expected.enabled, "Enabled state is correct.");
is(canBeDisabled, expected.canBeDisabled, "canBeDisabled state is correct.");
is(canBeEnabled, expected.canBeEnabled, "canBeEnabled state is correct.");
}
// Simple checks for the AccessibilityActor and AccessibleWalkerActor
add_task(async function() {
const {
walker: domWalker,
target,
accessibility,
parentAccessibility,
a11yWalker,
} = await initAccessibilityFrontsForUrl(
"data:text/html;charset=utf-8,<title>test</title><div></div>",
{ enableByDefault: false }
);
ok(accessibility, "The AccessibilityFront was created");
ok(accessibility.getWalker, "The getWalker method exists");
ok(accessibility.getSimulator, "The getSimulator method exists");
ok(accessibility.accessibleWalkerFront, "Accessible walker was initialized");
is(
a11yWalker,
accessibility.accessibleWalkerFront,
"The AccessibleWalkerFront was returned"
);
const a11ySimulator = accessibility.simulatorFront;
const webRenderEnabled = isWebRenderEnabled(window);
is(
!!a11ySimulator,
webRenderEnabled,
`The SimulatorFront was${webRenderEnabled ? "" : " not"} returned.`
);
if (webRenderEnabled) {
ok(accessibility.simulatorFront, "Accessible simulator was initialized");
is(
a11ySimulator,
accessibility.simulatorFront,
"The SimulatorFront was returned"
);
}
checkAccessibilityState(accessibility, parentAccessibility, {
enabled: false,
canBeDisabled: true,
canBeEnabled: true,
});
info("Force disable accessibility service: updates canBeEnabled flag");
let onEvent = parentAccessibility.once("can-be-enabled-change");
Services.prefs.setIntPref(PREF_ACCESSIBILITY_FORCE_DISABLED, 1);
await onEvent;
checkAccessibilityState(accessibility, parentAccessibility, {
enabled: false,
canBeDisabled: true,
canBeEnabled: false,
});
info("Clear force disable accessibility service: updates canBeEnabled flag");
onEvent = parentAccessibility.once("can-be-enabled-change");
Services.prefs.clearUserPref(PREF_ACCESSIBILITY_FORCE_DISABLED);
await onEvent;
checkAccessibilityState(accessibility, parentAccessibility, {
enabled: false,
canBeDisabled: true,
canBeEnabled: true,
});
info("Initialize accessibility service");
const initEvent = accessibility.once("init");
await parentAccessibility.enable();
await waitForA11yInit();
await initEvent;
checkAccessibilityState(accessibility, parentAccessibility, {
enabled: true,
canBeDisabled: true,
canBeEnabled: true,
});
const rootNode = await domWalker.getRootNode();
const a11yDoc = await accessibility.accessibleWalkerFront.getAccessibleFor(
rootNode
);
ok(a11yDoc, "Accessible document actor is created");
info("Shutdown accessibility service");
const shutdownEvent = accessibility.once("shutdown");
await waitForA11yShutdown(parentAccessibility);
await shutdownEvent;
checkAccessibilityState(accessibility, parentAccessibility, {
enabled: false,
canBeDisabled: true,
canBeEnabled: true,
});
await target.destroy();
gBrowser.removeCurrentTab();
});
|