1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 add_task(async function () {
8 await BrowserTestUtils.withNewTab(
14 <meta charset="utf-8"/>
15 <title>Accessibility Test</title>
20 async function (browser) {
22 "Creating a service in parent and waiting for service to be created " +
25 await loadContentScripts(browser, {
26 script: "Common.sys.mjs",
27 symbol: "CommonUtils",
29 // Create a11y service in the main process. This will trigger creating of
30 // the a11y service in parent as well.
31 const [parentA11yInitObserver, parentA11yInit] = initAccService();
32 const [contentA11yInitObserver, contentA11yInit] =
33 initAccService(browser);
34 let [parentConsumersChangedObserver, parentConsumersChanged] =
35 accConsumersChanged();
36 let [contentConsumersChangedObserver, contentConsumersChanged] =
37 accConsumersChanged(browser);
40 parentA11yInitObserver,
41 contentA11yInitObserver,
42 parentConsumersChangedObserver,
43 contentConsumersChangedObserver,
46 let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
47 Ci.nsIAccessibilityService
49 ok(accService, "Service initialized in parent");
50 await Promise.all([parentA11yInit, contentA11yInit]);
51 await parentConsumersChanged.then(data =>
59 "Accessibility service consumers in parent are correct."
62 await contentConsumersChanged.then(data =>
70 "Accessibility service consumers in content are correct."
75 JSON.parse(accService.getConsumers()),
81 "Accessibility service consumers in parent are correct."
85 "Removing a service in parent and waiting for service to be shut " +
88 // Remove a11y service reference in the main process.
89 const [parentA11yShutdownObserver, parentA11yShutdown] =
91 const [contentA11yShutdownObserver, contentA11yShutdown] =
92 shutdownAccService(browser);
93 [parentConsumersChangedObserver, parentConsumersChanged] =
94 accConsumersChanged();
95 [contentConsumersChangedObserver, contentConsumersChanged] =
96 accConsumersChanged(browser);
99 parentA11yShutdownObserver,
100 contentA11yShutdownObserver,
101 parentConsumersChangedObserver,
102 contentConsumersChangedObserver,
106 ok(!accService, "Service is removed in parent");
107 // Force garbage collection that should trigger shutdown in both main and
110 await Promise.all([parentA11yShutdown, contentA11yShutdown]);
111 await parentConsumersChanged.then(data =>
119 "Accessibility service consumers are correct."
122 await contentConsumersChanged.then(data =>
130 "Accessibility service consumers are correct."