Bug 1543575 - stop using ContentTask across accessible/ browser chrome tests. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D47387

--HG--
extra : rebase_source : bb1618e0b351f48da2750a93c9f46842d79f2cbd
extra : source : 5e5a6ce39829f7a176fa2de181db7cef60534522
This commit is contained in:
Yura Zenevich 2019-10-17 15:14:41 +00:00
Родитель 7ad8ffc6bb
Коммит de89df5cc3
46 изменённых файлов: 479 добавлений и 265 удалений

Просмотреть файл

@ -41,6 +41,94 @@ const CommonUtils = {
Cu.forceGC();
},
/**
* Adds an observer for an 'a11y-consumers-changed' event.
*/
addAccConsumersChangedObserver() {
const deferred = {};
this._accConsumersChanged = new Promise(resolve => {
deferred.resolve = resolve;
});
const observe = (subject, topic, data) => {
Services.obs.removeObserver(observe, "a11y-consumers-changed");
deferred.resolve(JSON.parse(data));
};
Services.obs.addObserver(observe, "a11y-consumers-changed");
},
/**
* Returns a promise that resolves when 'a11y-consumers-changed' event is
* fired.
*
* @return {Promise}
* event promise evaluating to event's data
*/
observeAccConsumersChanged() {
return this._accConsumersChanged;
},
/**
* Adds an observer for an 'a11y-init-or-shutdown' event with a value of "1"
* which indicates that an accessibility service is initialized in the current
* process.
*/
addAccServiceInitializedObserver() {
const deferred = {};
this._accServiceInitialized = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
const observe = (subject, topic, data) => {
if (data === "1") {
Services.obs.removeObserver(observe, "a11y-init-or-shutdown");
deferred.resolve();
} else {
deferred.reject("Accessibility service is shutdown unexpectedly.");
}
};
Services.obs.addObserver(observe, "a11y-init-or-shutdown");
},
/**
* Returns a promise that resolves when an accessibility service is
* initialized in the current process. Otherwise (if the service is shutdown)
* the promise is rejected.
*/
observeAccServiceInitialized() {
return this._accServiceInitialized;
},
/**
* Adds an observer for an 'a11y-init-or-shutdown' event with a value of "0"
* which indicates that an accessibility service is shutdown in the current
* process.
*/
addAccServiceShutdownObserver() {
const deferred = {};
this._accServiceShutdown = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
const observe = (subject, topic, data) => {
if (data === "0") {
Services.obs.removeObserver(observe, "a11y-init-or-shutdown");
deferred.resolve();
} else {
deferred.reject("Accessibility service is initialized unexpectedly.");
}
};
Services.obs.addObserver(observe, "a11y-init-or-shutdown");
},
/**
* Returns a promise that resolves when an accessibility service is shutdown
* in the current process. Otherwise (if the service is initialized) the
* promise is rejected.
*/
observeAccServiceShutdown() {
return this._accServiceShutdown;
},
/**
* Extract DOMNode id from an accessible. If the accessible is in the remote
* process, DOMNode is not present in parent process. However, if specified by

Просмотреть файл

@ -18,7 +18,7 @@ async function testScaledBounds(browser, accDoc, scale, id, type = "object") {
? getRangeExtents(acc, 0, -1, COORDTYPE_SCREEN_RELATIVE)
: getBounds(acc);
await ContentTask.spawn(browser, scale, _scale => {
await SpecialPowers.spawn(browser, [scale], _scale => {
content.Layout.setResolution(content.document, _scale);
});
@ -33,7 +33,7 @@ async function testScaledBounds(browser, accDoc, scale, id, type = "object") {
isWithin(scaledX - docX, (x - docX) * scale, 2, "Wrong scaled x of " + name);
isWithin(scaledY - docY, (y - docY) * scale, 2, "Wrong scaled y of " + name);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.Layout.setResolution(content.document, 1.0);
});
}

Просмотреть файл

@ -9,10 +9,9 @@
/* global getContentDPR */
async function getContentBoundsForDOMElm(browser, id) {
return ContentTask.spawn(browser, id, contentId => {
this.ok = ok;
return content.Layout.getBoundsForDOMElm(contentId, content.document);
});
return SpecialPowers.spawn(browser, [id], contentId =>
content.Layout.getBoundsForDOMElm(contentId, content.document)
);
}
async function testContentBounds(browser, acc) {
@ -50,7 +49,7 @@ async function runTests(browser, accDoc) {
await testContentBounds(browser, p2);
await testContentBounds(browser, area);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.Layout.zoomDocument(content.document, 2.0);
});

Просмотреть файл

@ -50,13 +50,13 @@ async function runTests(browser, accDoc) {
await testTextNode("p2");
await testEmptyInputNode("i1");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.Layout.zoomDocument(content.document, 2.0);
});
await testTextNode("p1");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.Layout.zoomDocument(content.document, 1.0);
});
}

Просмотреть файл

@ -26,9 +26,9 @@ loadScripts(
* Get content window DPR that can be different from parent window DPR.
*/
async function getContentDPR(browser) {
return ContentTask.spawn(
return SpecialPowers.spawn(
browser,
null,
[],
() => content.window.devicePixelRatio
);
}

Просмотреть файл

@ -6,7 +6,9 @@
add_task(async function() {
// Create a11y service.
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -31,8 +33,10 @@ add_task(async function() {
// This promise will resolve only if canShutdown flag is set to true. If
// 'a11y-init-or-shutdown' event with '0' flag comes before it can be shut
// down, the promise will reject.
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -6,7 +6,9 @@
add_task(async function() {
// Create a11y service.
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -23,8 +25,10 @@ add_task(async function() {
// This promise will resolve only if canShutdown flag is set to true. If
// 'a11y-init-or-shutdown' event with '0' flag comes before it can be shut
// down, the promise will reject.
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -6,7 +6,9 @@
add_task(async function() {
// Create a11y service.
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -34,8 +36,10 @@ add_task(async function() {
// This promise will resolve only if canShutdown flag is set to true. If
// 'a11y-init-or-shutdown' event with '0' flag comes before it can be shut
// down, the promise will reject.
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -6,7 +6,9 @@
add_task(async function() {
// Create a11y service.
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -34,8 +36,10 @@ add_task(async function() {
// This promise will resolve only if canShutdown flag is set to true. If
// 'a11y-init-or-shutdown' event with '0' flag comes before it can be shut
// down, the promise will reject.
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -12,7 +12,9 @@ add_task(async function() {
Ci.nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE,
"body"
);
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -44,8 +46,10 @@ add_task(async function() {
ok(acc, "Accessible proxy is created");
let canShutdown = false;
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -12,7 +12,9 @@ add_task(async function() {
Ci.nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE,
"body"
);
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -44,8 +46,10 @@ add_task(async function() {
ok(acc, "Accessible proxy is created");
let canShutdown = false;
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -7,7 +7,9 @@
add_task(async function() {
info("Creating a service");
// Create a11y service.
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService1 = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -26,8 +28,10 @@ add_task(async function() {
// This promise will resolve only if canShutdown flag is set to true. If
// 'a11y-init-or-shutdown' event with '0' flag comes before it can be shut
// down, the promise will reject.
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -21,15 +21,20 @@ add_task(async function() {
</html>`,
},
async function(browser) {
await loadContentScripts(browser, "Common.jsm");
info(
"Creating a service in parent and waiting for service to be created " +
"in content"
);
await loadContentScripts(browser, "Common.jsm");
// Create a11y service in the main process. This will trigger creating of
// the a11y service in parent as well.
let parentA11yInit = initPromise();
let contentA11yInit = initPromise(browser);
const [parentA11yInitObserver, parentA11yInit] = initAccService();
const [contentA11yInitObserver, contentA11yInit] = initAccService(
browser
);
await Promise.all([parentA11yInitObserver, contentA11yInitObserver]);
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -41,7 +46,7 @@ add_task(async function() {
"process"
);
// Add a new reference to the a11y service inside the content process.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.CommonUtils.accService;
});
@ -53,8 +58,13 @@ add_task(async function() {
// This promise will resolve only if contentCanShutdown flag is set to true.
// If 'a11y-init-or-shutdown' event with '0' flag (in content) comes before
// it can be shut down, the promise will reject.
let contentA11yShutdown = new Promise((resolve, reject) =>
shutdownPromise(browser).then(flag =>
const [
contentA11yShutdownObserver,
contentA11yShutdownPromise,
] = shutdownAccService(browser);
await contentA11yShutdownObserver;
const contentA11yShutdown = new Promise((resolve, reject) =>
contentA11yShutdownPromise.then(flag =>
contentCanShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")
@ -63,7 +73,7 @@ add_task(async function() {
// Remove a11y service reference in content and force garbage collection.
// This should not trigger shutdown since a11y was originally initialized by
// the main process.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.CommonUtils.clearAccService();
});
@ -74,7 +84,12 @@ add_task(async function() {
// Now allow a11y service to shutdown in content.
contentCanShutdown = true;
// Remove the a11y service reference in the main process.
let parentA11yShutdown = shutdownPromise();
const [
parentA11yShutdownObserver,
parentA11yShutdown,
] = shutdownAccService();
await parentA11yShutdownObserver;
accService = null;
ok(!accService, "Service is removed in parent");
// Force garbage collection that should trigger shutdown in both parent and

Просмотреть файл

@ -16,7 +16,9 @@ add_task(async function testForceDisable() {
Services.prefs.clearUserPref(PREF_ACCESSIBILITY_FORCE_DISABLED);
info("Enable accessibility service via XPCOM");
let a11yInit = initPromise();
let [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -24,7 +26,9 @@ add_task(async function testForceDisable() {
ok(Services.appinfo.accessibilityEnabled, "Accessibility is enabled");
info("Force disable a11y service via preference");
let a11yShutdown = shutdownPromise();
let [a11yShutdownObserver, a11yShutdown] = shutdownAccService();
await a11yShutdownObserver;
Services.prefs.setIntPref(PREF_ACCESSIBILITY_FORCE_DISABLED, 1);
await a11yShutdown;
ok(!Services.appinfo.accessibilityEnabled, "Accessibility is disabled");
@ -48,7 +52,9 @@ add_task(async function testForceDisable() {
Services.prefs.clearUserPref(PREF_ACCESSIBILITY_FORCE_DISABLED);
info("Create a11y service again");
a11yInit = initPromise();
[a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -56,7 +62,9 @@ add_task(async function testForceDisable() {
ok(Services.appinfo.accessibilityEnabled, "Accessibility is enabled");
info("Remove all references to a11y service");
a11yShutdown = shutdownPromise();
[a11yShutdownObserver, a11yShutdown] = shutdownAccService();
await a11yShutdownObserver;
accService = null;
forceGC();
await a11yShutdown;

Просмотреть файл

@ -8,7 +8,9 @@ add_task(async function() {
// Making sure that the e10s is enabled on Windows for testing.
await setE10sPrefs();
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -39,8 +41,10 @@ add_task(async function() {
forceGC();
let canShutdown = false;
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -12,7 +12,9 @@ add_task(async function() {
Ci.nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE,
"body"
);
let a11yInit = initPromise();
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -41,8 +43,10 @@ add_task(async function() {
forceGC();
let canShutdown = false;
let a11yShutdown = new Promise((resolve, reject) =>
shutdownPromise().then(flag =>
const [a11yShutdownObserver, a11yShutdownPromise] = shutdownAccService();
await a11yShutdownObserver;
const a11yShutdown = new Promise((resolve, reject) =>
a11yShutdownPromise.then(flag =>
canShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")

Просмотреть файл

@ -25,16 +25,29 @@ add_task(async function() {
"Creating a service in parent and waiting for service to be created " +
"in content"
);
await loadContentScripts(browser, "Common.jsm");
// Create a11y service in the main process. This will trigger creating of
// the a11y service in parent as well.
let parentA11yInit = initPromise();
let contentA11yInit = initPromise(browser);
let parentConsumersChanged = a11yConsumersChangedPromise();
let contentConsumersChanged = ContentTask.spawn(
browser,
{},
a11yConsumersChangedPromise
const [parentA11yInitObserver, parentA11yInit] = initAccService();
const [contentA11yInitObserver, contentA11yInit] = initAccService(
browser
);
let [
parentConsumersChangedObserver,
parentConsumersChanged,
] = accConsumersChanged();
let [
contentConsumersChangedObserver,
contentConsumersChanged,
] = accConsumersChanged(browser);
await Promise.all([
parentA11yInitObserver,
contentA11yInitObserver,
parentConsumersChangedObserver,
contentConsumersChangedObserver,
]);
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -78,14 +91,30 @@ add_task(async function() {
"down in content"
);
// Remove a11y service reference in the main process.
let parentA11yShutdown = shutdownPromise();
let contentA11yShutdown = shutdownPromise(browser);
parentConsumersChanged = a11yConsumersChangedPromise();
contentConsumersChanged = ContentTask.spawn(
browser,
{},
a11yConsumersChangedPromise
);
const [
parentA11yShutdownObserver,
parentA11yShutdown,
] = shutdownAccService();
const [
contentA11yShutdownObserver,
contentA11yShutdown,
] = shutdownAccService(browser);
[
parentConsumersChangedObserver,
parentConsumersChanged,
] = accConsumersChanged();
[
contentConsumersChangedObserver,
contentConsumersChanged,
] = accConsumersChanged(browser);
await Promise.all([
parentA11yShutdownObserver,
contentA11yShutdownObserver,
parentConsumersChangedObserver,
contentConsumersChangedObserver,
]);
accService = null;
ok(!accService, "Service is removed in parent");
// Force garbage collection that should trigger shutdown in both main and

Просмотреть файл

@ -21,23 +21,33 @@ add_task(async function() {
</html>`,
},
async function(browser) {
await loadContentScripts(browser, "Common.jsm");
info("Creating a service in content");
await loadContentScripts(browser, "Common.jsm");
// Create a11y service in the content process.
let a11yInit = initPromise(browser);
await ContentTask.spawn(browser, {}, () => {
const [a11yInitObserver, a11yInit] = initAccService(browser);
await a11yInitObserver;
await SpecialPowers.spawn(browser, [], () => {
content.CommonUtils.accService;
});
await a11yInit;
ok(
true,
"Accessibility service is started in content process correctly."
);
info("Removing a service in content");
// Remove a11y service reference from the content process.
let a11yShutdown = shutdownPromise(browser);
const [a11yShutdownObserver, a11yShutdown] = shutdownAccService(browser);
await a11yShutdownObserver;
// Force garbage collection that should trigger shutdown.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.CommonUtils.clearAccService();
});
await a11yShutdown;
ok(
true,
"Accessibility service is shutdown in content process correctly."
);
// Unsetting e10s related preferences.
await unsetE10sPrefs();

Просмотреть файл

@ -21,20 +21,28 @@ add_task(async function() {
</html>`,
},
async function(browser) {
await loadContentScripts(browser, "Common.jsm");
info(
"Creating a service in parent and waiting for service to be created " +
"in content"
);
await loadContentScripts(browser, "Common.jsm");
// Create a11y service in the main process. This will trigger creating of
// the a11y service in parent as well.
let parentA11yInit = initPromise();
let contentA11yInit = initPromise(browser);
let contentConsumersChanged = ContentTask.spawn(
browser,
{},
a11yConsumersChangedPromise
const [parentA11yInitObserver, parentA11yInit] = initAccService();
const [contentA11yInitObserver, contentA11yInit] = initAccService(
browser
);
let [
contentConsumersChangedObserver,
contentConsumersChanged,
] = accConsumersChanged(browser);
await Promise.all([
parentA11yInitObserver,
contentA11yInitObserver,
contentConsumersChangedObserver,
]);
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -56,13 +64,13 @@ add_task(async function() {
"Adding additional reference to accessibility service in content " +
"process"
);
contentConsumersChanged = ContentTask.spawn(
browser,
{},
a11yConsumersChangedPromise
);
[
contentConsumersChangedObserver,
contentConsumersChanged,
] = accConsumersChanged(browser);
await contentConsumersChangedObserver;
// Add a new reference to the a11y service inside the content process.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.CommonUtils.accService;
});
await contentConsumersChanged.then(data =>
@ -77,7 +85,7 @@ add_task(async function() {
)
);
const contentConsumers = await ContentTask.spawn(browser, {}, () =>
const contentConsumers = await SpecialPowers.spawn(browser, [], () =>
content.CommonUtils.accService.getConsumers()
);
Assert.deepEqual(
@ -95,22 +103,34 @@ add_task(async function() {
"content stays alive"
);
let contentCanShutdown = false;
let parentA11yShutdown = shutdownPromise();
contentConsumersChanged = ContentTask.spawn(
browser,
{},
a11yConsumersChangedPromise
);
const [
parentA11yShutdownObserver,
parentA11yShutdown,
] = shutdownAccService();
[
contentConsumersChangedObserver,
contentConsumersChanged,
] = accConsumersChanged(browser);
// This promise will resolve only if contentCanShutdown flag is set to true.
// If 'a11y-init-or-shutdown' event with '0' flag (in content) comes before
// it can be shut down, the promise will reject.
let contentA11yShutdown = new Promise((resolve, reject) =>
shutdownPromise(browser).then(flag =>
const [
contentA11yShutdownObserver,
contentA11yShutdownPromise,
] = shutdownAccService(browser);
const contentA11yShutdown = new Promise((resolve, reject) =>
contentA11yShutdownPromise.then(flag =>
contentCanShutdown
? resolve()
: reject("Accessible service was shut down incorrectly")
)
);
await Promise.all([
parentA11yShutdownObserver,
contentA11yShutdownObserver,
contentConsumersChangedObserver,
]);
// Remove a11y service reference in the main process and force garbage
// collection. This should not trigger shutdown in content since a11y
// service is used by XPCOM.
@ -141,14 +161,14 @@ add_task(async function() {
info("Removing a service in content");
// Now allow a11y service to shutdown in content.
contentCanShutdown = true;
contentConsumersChanged = ContentTask.spawn(
browser,
{},
a11yConsumersChangedPromise
);
[
contentConsumersChangedObserver,
contentConsumersChanged,
] = accConsumersChanged(browser);
await contentConsumersChangedObserver;
// Remove last reference to a11y service in content and force garbage
// collection that should trigger shutdown.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.CommonUtils.clearAccService();
});
await contentA11yShutdown;

Просмотреть файл

@ -7,7 +7,13 @@
add_task(async function() {
// Create a11y service inside of the function scope. Its reference should be
// released once the anonimous function is called.
let a11yInitThenShutdown = initPromise().then(shutdownPromise);
const [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
const a11yInitThenShutdown = a11yInit.then(async () => {
const [a11yShutdownObserver, a11yShutdown] = shutdownAccService();
await a11yShutdownObserver;
return a11yShutdown;
});
(function() {
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(

Просмотреть файл

@ -7,7 +7,9 @@
add_task(async function() {
info("Creating a service");
// Create a11y service.
let a11yInit = initPromise();
let [a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -16,7 +18,9 @@ add_task(async function() {
info("Removing a service");
// Remove the only reference to an a11y service.
let a11yShutdown = shutdownPromise();
let [a11yShutdownObserver, a11yShutdown] = shutdownAccService();
await a11yShutdownObserver;
accService = null;
ok(!accService, "Service is removed");
// Force garbage collection that should trigger shutdown.
@ -25,7 +29,9 @@ add_task(async function() {
info("Recreating a service");
// Re-create a11y service.
a11yInit = initPromise();
[a11yInitObserver, a11yInit] = initAccService();
await a11yInitObserver;
accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService
);
@ -34,7 +40,9 @@ add_task(async function() {
info("Removing a service again");
// Remove the only reference to an a11y service again.
a11yShutdown = shutdownPromise();
[a11yShutdownObserver, a11yShutdown] = shutdownAccService();
await a11yShutdownObserver;
accService = null;
ok(!accService, "Service is removed again");
// Force garbage collection that should trigger shutdown.

Просмотреть файл

@ -412,7 +412,7 @@ async function testAttrRule(browser, target, rule, expected) {
{
expected: [[waitFor, waitFor === EVENT_REORDER ? parent : id]],
},
([contentId, contentAttr]) =>
(contentId, contentAttr) =>
content.document.getElementById(contentId).removeAttribute(contentAttr),
[id, attr]
);
@ -447,7 +447,7 @@ async function testElmRule(browser, target, rule, expected) {
expected: [[EVENT_REORDER, isSibling ? parent : id]],
},
contentElm => content.document.querySelector(`${contentElm}`).remove(),
elm
[elm]
);
// Update accessible just in case it is now defunct.
@ -481,7 +481,7 @@ async function testSubtreeRule(browser, target, rule, expected) {
elm.firstChild.remove();
}
},
id
[id]
);
// Update accessible just in case it is now defunct.

Просмотреть файл

@ -47,7 +47,7 @@ addAccessibleTask(
// Test state change
let onStateChange = waitForEvent(EVENT_STATE_CHANGE, "checkbox");
// Set checked for a checkbox.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("checkbox").checked = true;
});
let event = await onStateChange;
@ -58,7 +58,7 @@ addAccessibleTask(
// Test extra state
onStateChange = waitForEvent(EVENT_STATE_CHANGE, "iframe");
// Set design mode on.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("iframe").contentDocument.designMode =
"on";
});

Просмотреть файл

@ -41,7 +41,7 @@ async function changeText(browser, id, value, events) {
})
);
// Change text in the subtree.
await ContentTask.spawn(browser, [id, value], ([contentId, contentValue]) => {
await SpecialPowers.spawn(browser, [id, value], (contentId, contentValue) => {
content.document.getElementById(
contentId
).firstChild.textContent = contentValue;
@ -64,10 +64,10 @@ async function changeText(browser, id, value, events) {
async function removeTextFromInput(browser, id, value, start, end) {
let onTextRemoved = waitForEvent(EVENT_TEXT_REMOVED, id);
// Select text and delete it.
await ContentTask.spawn(
await SpecialPowers.spawn(
browser,
[id, start, end],
([contentId, contentStart, contentEnd]) => {
(contentId, contentStart, contentEnd) => {
let el = content.document.getElementById(contentId);
el.focus();
el.setSelectionRange(contentStart, contentEnd);

Просмотреть файл

@ -11,7 +11,7 @@ addAccessibleTask(
async function(browser, accDoc) {
await loadContentScripts(browser, "Common.jsm");
let onVCChanged = waitForEvent(EVENT_VIRTUALCURSOR_CHANGED, accDoc);
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
const { CommonUtils } = content;
let vc = CommonUtils.getAccessible(
content.document,
@ -35,7 +35,7 @@ addAccessibleTask(
ok(!vccEvent.isFromUserInput, "not user initiated");
onVCChanged = waitForEvent(EVENT_VIRTUALCURSOR_CHANGED, accDoc);
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
let vc = content.CommonUtils.getAccessible(
content.document,
Ci.nsIAccessibleDocument
@ -51,7 +51,7 @@ addAccessibleTask(
ok(vccEvent.isFromUserInput, "user initiated");
onVCChanged = waitForEvent(EVENT_VIRTUALCURSOR_CHANGED, accDoc);
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
const { CommonUtils } = content;
let vc = CommonUtils.getAccessible(
content.document,

Просмотреть файл

@ -19,7 +19,7 @@ addAccessibleTask("doc_treeupdate_ariadialog.html", async function(
// Make dialog visible and update its inner content.
let onShow = waitForEvent(EVENT_SHOW, "dialog");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("dialog").style.display = "block";
});
await onShow;

Просмотреть файл

@ -86,7 +86,7 @@ async function testContainer1(browser, accDoc) {
/* ================ Append element ======================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
let div = content.document.createElement("div");
div.setAttribute("id", "t1_child3");
div.setAttribute("role", "radio");
@ -109,9 +109,9 @@ async function testContainer1(browser, accDoc) {
/* ================ Remove element ======================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () =>
content.document.getElementById("t1_span").remove()
);
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("t1_span").remove();
});
await onReorder;
// subdiv should go away
@ -167,11 +167,11 @@ async function removeContainer(browser, accDoc) {
testAccessibleTree(acc, tree);
let onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () =>
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("t2_container2")
.removeChild(content.document.getElementById("t2_container3"))
);
.removeChild(content.document.getElementById("t2_container3"));
});
await onReorder;
tree = {
@ -189,7 +189,7 @@ async function stealAndRecacheChildren(browser, accDoc) {
/* ================ Attempt to steal from other ARIA owns ================= */
let onReorder = waitForEvent(EVENT_REORDER, id2);
await invokeSetAttribute(browser, id2, "aria-owns", "t3_child");
await ContentTask.spawn(browser, id2, id => {
await SpecialPowers.spawn(browser, [id2], id => {
let div = content.document.createElement("div");
div.setAttribute("role", "radio");
content.document.getElementById(id).appendChild(div);
@ -267,7 +267,7 @@ async function removeNotARIAOwnedEl(browser, accDoc) {
testAccessibleTree(acc, tree);
let onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
content.document
.getElementById(contentId)
.removeChild(content.document.getElementById("t6_span"));

Просмотреть файл

@ -31,7 +31,7 @@ addAccessibleTask(
testAccessibleTree(container, tree);
let onReorder = waitForEvent(EVENT_REORDER, id1);
await ContentTask.spawn(browser, id1, id => {
await SpecialPowers.spawn(browser, [id1], id => {
let doc = content.document;
doc.getElementById("scrollarea").style.width = "20px";
doc.getElementById(id).appendChild(doc.createElement("input"));

Просмотреть файл

@ -34,7 +34,7 @@ addAccessibleTask(
/* ================= Write iframe document ================================ */
let reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
let docNode = content.document.getElementById("iframe").contentDocument;
let newHTMLNode = docNode.createElement("html");
let newBodyNode = docNode.createElement("body");
@ -59,7 +59,7 @@ addAccessibleTask(
/* ================= Replace iframe HTML element ========================== */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
let docNode = content.document.getElementById("iframe").contentDocument;
// We can't use open/write/close outside of iframe document because of
// security error.
@ -85,7 +85,7 @@ addAccessibleTask(
/* ================= Replace iframe body ================================== */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
let docNode = content.document.getElementById("iframe").contentDocument;
let newBodyNode = docNode.createElement("body");
let newTextNode = docNode.createTextNode("New Hello");
@ -109,7 +109,7 @@ addAccessibleTask(
/* ================= Open iframe document ================================= */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
// Open document.
let docNode = content.document.getElementById("iframe").contentDocument;
let script = docNode.createElement("script");
@ -133,7 +133,7 @@ addAccessibleTask(
/* ================= Close iframe document ================================ */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
// Write and close document.
let docNode = content.document.getElementById("iframe").contentDocument;
docNode.write("Works?");
@ -154,7 +154,7 @@ addAccessibleTask(
/* ================= Remove HTML from iframe document ===================== */
reorderEventPromise = waitForEvent(EVENT_REORDER, iframe);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
// Remove HTML element.
let docNode = content.document.getElementById("iframe").contentDocument;
docNode.firstChild.remove();
@ -173,7 +173,7 @@ addAccessibleTask(
/* ================= Insert HTML to iframe document ======================= */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
// Insert HTML element.
let docNode = content.document.getElementById("iframe").contentDocument;
let html = docNode.createElement("html");
@ -199,7 +199,7 @@ addAccessibleTask(
/* ================= Remove body from iframe document ===================== */
reorderEventPromise = waitForEvent(EVENT_REORDER, iframe);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
// Remove body element.
let docNode = content.document.getElementById("iframe").contentDocument;
docNode.documentElement.removeChild(docNode.body);
@ -218,7 +218,7 @@ addAccessibleTask(
/* ================ Insert element under document element while body missed */
reorderEventPromise = waitForEvent(EVENT_REORDER, iframe);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let docNode = content.document.getElementById("iframe").contentDocument;
let inputNode = (content.window.inputNode = docNode.createElement(
"input"
@ -237,7 +237,7 @@ addAccessibleTask(
testAccessibleTree(iframe, tree);
reorderEventPromise = waitForEvent(EVENT_REORDER, iframe);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let docEl = content.document.getElementById("iframe").contentDocument
.documentElement;
// Remove aftermath of this test before next test starts.
@ -253,7 +253,7 @@ addAccessibleTask(
/* ================= Insert body to iframe document ======================= */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
// Write and close document.
let docNode = content.document.getElementById("iframe").contentDocument;
// Insert body element.
@ -294,7 +294,7 @@ addAccessibleTask(
/* ================= Replace iframe body on ARIA role body ================ */
reorderEventPromise = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
let docNode = content.document.getElementById("iframe").contentDocument;
let newBodyNode = docNode.createElement("body");
let newTextNode = docNode.createTextNode("New Hello");

Просмотреть файл

@ -47,7 +47,7 @@ addAccessibleTask(
let onReorder = waitForEvent(EVENT_REORDER, id1);
// Create and add an element with CSS generated content to container1
await ContentTask.spawn(browser, id1, id => {
await SpecialPowers.spawn(browser, [id1], id => {
let node = content.document.createElement("div");
node.textContent = "text";
node.setAttribute("class", "gentext");

Просмотреть файл

@ -19,7 +19,7 @@ async function testImageMap(browser, accDoc) {
/* ================= Insert area ========================================== */
let onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let areaElm = content.document.createElement("area");
let mapNode = content.document.getElementById("map");
areaElm.setAttribute(
@ -43,7 +43,7 @@ async function testImageMap(browser, accDoc) {
/* ================= Append area ========================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let areaElm = content.document.createElement("area");
let mapNode = content.document.getElementById("map");
areaElm.setAttribute(
@ -68,7 +68,7 @@ async function testImageMap(browser, accDoc) {
/* ================= Remove area ========================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let mapNode = content.document.getElementById("map");
mapNode.removeChild(mapNode.firstElementChild);
});
@ -120,7 +120,7 @@ async function testContainer(browser) {
/* ================= Remove map =========================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let mapNode = content.document.getElementById("map");
mapNode.remove();
});
@ -133,7 +133,7 @@ async function testContainer(browser) {
/* ================= Insert map =========================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
let map = content.document.createElement("map");
let area = content.document.createElement("area");

Просмотреть файл

@ -17,7 +17,7 @@ addAccessibleTask('<ol id="list"></ol>', async function(browser, accDoc) {
await invokeSetAttribute(browser, "body", "contentEditable", "true");
let onReorder = waitForEvent(EVENT_REORDER, "list");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let li = content.document.createElement("li");
li.textContent = "item";
content.document.getElementById("list").appendChild(li);

Просмотреть файл

@ -23,7 +23,7 @@ addAccessibleTask(
let onReorder = waitForEvent(EVENT_REORDER, "body");
// Add an event listener to parent.
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.window.dummyListener = () => {};
content.document
.getElementById("parent")

Просмотреть файл

@ -15,7 +15,7 @@ addAccessibleTask('<select id="select"></select>', async function(
let onEvent = waitForEvent(EVENT_REORDER, "select");
// Create a combobox with grouping and 2 standalone options
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
let contentSelect = doc.getElementById("select");
let optGroup = doc.createElement("optgroup");
@ -62,7 +62,7 @@ addAccessibleTask('<select id="select"></select>', async function(
onEvent = waitForEvent(EVENT_REORDER, "select");
// Remove grouping from combobox
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let contentSelect = content.document.getElementById("select");
contentSelect.firstChild.remove();
});
@ -80,7 +80,7 @@ addAccessibleTask('<select id="select"></select>', async function(
onEvent = waitForEvent(EVENT_REORDER, "select");
// Remove all options from combobox
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let contentSelect = content.document.getElementById("select");
while (contentSelect.length) {
contentSelect.remove(0);

Просмотреть файл

@ -18,11 +18,11 @@ addAccessibleTask("doc_treeupdate_removal.xhtml", async function(
// Move the_table element into hidden subtree.
let onReorder = waitForEvent(EVENT_REORDER, "body");
await ContentTask.spawn(browser, {}, () =>
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("the_displaynone")
.appendChild(content.document.getElementById("the_table"))
);
.appendChild(content.document.getElementById("the_table"));
});
await onReorder;
ok(
@ -35,11 +35,11 @@ addAccessibleTask("doc_treeupdate_removal.xhtml", async function(
);
// Remove the_row element (since it did not have accessible, no event needed).
await ContentTask.spawn(browser, {}, () =>
await SpecialPowers.spawn(browser, [], () => {
content.document.body.removeChild(
content.document.getElementById("the_row")
)
);
);
});
// make sure no accessibles have stuck around.
ok(

Просмотреть файл

@ -26,7 +26,7 @@ addAccessibleTask(
testAccessibleTree(table, tree);
let onReorder = waitForEvent(EVENT_REORDER, "table");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
// append a caption, it should appear as a first element in the
// accessible tree.
let doc = content.document;

Просмотреть файл

@ -15,7 +15,7 @@ async function removeTextData(browser, accessible, id, role) {
testAccessibleTree(accessible, tree);
let onReorder = waitForEvent(EVENT_REORDER, id);
await ContentTask.spawn(browser, id, contentId => {
await SpecialPowers.spawn(browser, [id], contentId => {
content.document.getElementById(contentId).firstChild.textContent = "";
});
await onReorder;

Просмотреть файл

@ -49,7 +49,7 @@ async function test3(browser, accessible) {
testAccessibleTree(accessible, tree);
let onReorder = waitForEvent(EVENT_REORDER, "t3_container");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
doc.getElementById("t3_container").style.color = "red";
doc.getElementById("t3_parent").style.visibility = "hidden";
@ -84,7 +84,7 @@ async function test4(browser, accessible) {
testAccessibleTree(accessible, tree);
let onReorder = waitForEvent(EVENT_REORDER, "t4_parent");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
doc.getElementById("t4_container").style.color = "red";
doc.getElementById("t4_child").style.visibility = "visible";

Просмотреть файл

@ -27,7 +27,7 @@ addAccessibleTask("doc_treeupdate_whitespace.html", async function(
let onReorder = waitForEvent(EVENT_REORDER, "container1");
// Remove img1 from container1
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
doc.getElementById("container1").removeChild(doc.getElementById("img1"));
});
@ -45,7 +45,7 @@ addAccessibleTask("doc_treeupdate_whitespace.html", async function(
onReorder = waitForEvent(EVENT_REORDER, "container2-parent");
// Append an img with valid src to container2
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
let img = doc.createElement("img");
img.setAttribute(

Просмотреть файл

@ -13,7 +13,7 @@ loadScripts(
async function runTests(browser, accDoc) {
let onFocus = waitForEvent(EVENT_FOCUS, "button");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("button").focus();
});
let button = (await onFocus).accessible;
@ -33,7 +33,7 @@ async function runTests(browser, accDoc) {
testStates((await onFocus).accessible, STATE_FOCUSED);
onFocus = waitForEvent(EVENT_FOCUS, "body2");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("editabledoc")
.contentWindow.document.body.focus();
@ -47,7 +47,7 @@ async function runTests(browser, accDoc) {
let onShow = waitForEvent(EVENT_SHOW, "alertdialog");
onFocus = waitForEvent(EVENT_FOCUS, "alertdialog");
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let alertDialog = content.document.getElementById("alertdialog");
alertDialog.style.display = "block";
alertDialog.focus();

Просмотреть файл

@ -14,7 +14,7 @@ addAccessibleTask(
[EVENT_SCROLLING, accDoc],
[EVENT_SCROLLING_END, accDoc],
]);
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
content.location.hash = "#two";
});
let [scrollEvent1, scrollEndEvent1] = await onScrolling;
@ -33,7 +33,7 @@ addAccessibleTask(
[EVENT_SCROLLING, accDoc],
[EVENT_SCROLLING_END, accDoc],
]);
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
content.location.hash = "#three";
});
let [scrollEvent2, scrollEndEvent2] = await onScrolling;
@ -52,7 +52,7 @@ addAccessibleTask(
[EVENT_SCROLLING, accDoc],
[EVENT_SCROLLING_END, accDoc],
]);
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
content.scrollTo(10, 0);
});
let [scrollEvent3, scrollEndEvent3] = await onScrolling;

Просмотреть файл

@ -36,11 +36,11 @@ add_task(async function testDocumentCreation() {
info("Verifying that each tab content document is in accessible cache.");
for (const browser of [...gBrowser.browsers]) {
await ContentTask.spawn(browser, null, async () => {
await SpecialPowers.spawn(browser, [], async () => {
let accServiceContent = Cc[
"@mozilla.org/accessibilityService;1"
].getService(Ci.nsIAccessibilityService);
ok(
Assert.ok(
!!accServiceContent.getAccessibleFromCache(content.document),
"Document accessible is in cache."
);

Просмотреть файл

@ -4,8 +4,19 @@
"use strict";
/* exported initPromise, shutdownPromise, waitForEvent, setE10sPrefs,
unsetE10sPrefs, a11yConsumersChangedPromise */
/* exported initAccService, shutdownAccService, waitForEvent, setE10sPrefs,
unsetE10sPrefs, accConsumersChanged */
// Load the shared-head file first.
/* import-globals-from shared-head.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js",
this
);
const { CommonUtils } = ChromeUtils.import(
"chrome://mochitests/content/browser/accessible/tests/browser/Common.jsm"
);
/**
* Set e10s related preferences in the test environment.
@ -32,98 +43,82 @@ function unsetE10sPrefs() {
});
}
// Load the shared-head file first.
/* import-globals-from shared-head.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js",
this
);
/**
* Returns a promise that resolves when 'a11y-consumers-changed' event is fired.
* @return {Promise} event promise evaluating to event's data
* Capture when 'a11y-consumers-changed' event is fired.
*
* @param {?Object} target
* [optional] browser object that indicates that accessibility service
* is in content process.
* @return {Array}
* List of promises where first one is the promise for when the event
* observer is added and the second one for when the event is observed.
*/
function a11yConsumersChangedPromise() {
return new Promise(resolve => {
let observe = (subject, topic, data) => {
Services.obs.removeObserver(observe, "a11y-consumers-changed");
resolve(JSON.parse(data));
};
Services.obs.addObserver(observe, "a11y-consumers-changed");
});
function accConsumersChanged(target) {
return target
? [
SpecialPowers.spawn(target, [], () =>
content.CommonUtils.addAccConsumersChangedObserver()
),
SpecialPowers.spawn(target, [], () =>
content.CommonUtils.observeAccConsumersChanged()
),
]
: [
CommonUtils.addAccConsumersChangedObserver(),
CommonUtils.observeAccConsumersChanged(),
];
}
/**
* Returns a promise that resolves when 'a11y-init-or-shutdown' event is fired.
* @return {Promise} event promise evaluating to event's data
* Capture when accessibility service is initialized.
*
* @param {?Object} target
* [optional] browser object that indicates that accessibility service
* is expected to be initialized in content process.
* @return {Array}
* List of promises where first one is the promise for when the event
* observer is added and the second one for when the event is observed.
*/
function a11yInitOrShutdownPromise() {
return new Promise(resolve => {
let observe = (subject, topic, data) => {
Services.obs.removeObserver(observe, "a11y-init-or-shutdown");
resolve(data);
};
Services.obs.addObserver(observe, "a11y-init-or-shutdown");
});
function initAccService(target) {
return target
? [
SpecialPowers.spawn(target, [], () =>
content.CommonUtils.addAccServiceInitializedObserver()
),
SpecialPowers.spawn(target, [], () =>
content.CommonUtils.observeAccServiceInitialized()
),
]
: [
CommonUtils.addAccServiceInitializedObserver(),
CommonUtils.observeAccServiceInitialized(),
];
}
/**
* Returns a promise that resolves when 'a11y-init-or-shutdown' event is fired
* in content.
* @param {Object} browser current "tabbrowser" element
* @return {Promise} event promise evaluating to event's data
* Capture when accessibility service is shutdown.
*
* @param {?Object} target
* [optional] browser object that indicates that accessibility service
* is expected to be shutdown in content process.
* @return {Array}
* List of promises where first one is the promise for when the event
* observer is added and the second one for when the event is observed.
*/
function contentA11yInitOrShutdownPromise(browser) {
return ContentTask.spawn(browser, {}, a11yInitOrShutdownPromise);
}
/**
* A helper function that maps 'a11y-init-or-shutdown' event to a promise that
* resovles or rejects depending on whether accessibility service is expected to
* be initialized or shut down.
*/
function promiseOK(promise, expected) {
return promise.then(flag =>
flag === expected ? Promise.resolve() : Promise.reject()
);
}
/**
* Checks and returns a promise that resolves when accessibility service is
* initialized with the correct flag.
* @param {?Object} contentBrowser optinal remove browser object that indicates
* that accessibility service is expected to be
* initialized in content process.
* @return {Promise} promise that resolves when the accessibility
* service initialized correctly.
*/
function initPromise(contentBrowser) {
let a11yInitPromise = contentBrowser
? contentA11yInitOrShutdownPromise(contentBrowser)
: a11yInitOrShutdownPromise();
return promiseOK(a11yInitPromise, "1").then(
() => ok(true, "Service initialized correctly"),
() => ok(false, "Service shutdown incorrectly")
);
}
/**
* Checks and returns a promise that resolves when accessibility service is
* shut down with the correct flag.
* @param {?Object} contentBrowser optinal remove browser object that indicates
* that accessibility service is expected to be
* shut down in content process.
* @return {Promise} promise that resolves when the accessibility
* service shuts down correctly.
*/
function shutdownPromise(contentBrowser) {
let a11yShutdownPromise = contentBrowser
? contentA11yInitOrShutdownPromise(contentBrowser)
: a11yInitOrShutdownPromise();
return promiseOK(a11yShutdownPromise, "0").then(
() => ok(true, "Service shutdown correctly"),
() => ok(false, "Service initialized incorrectly")
);
function shutdownAccService(target) {
return target
? [
SpecialPowers.spawn(target, [], () =>
content.CommonUtils.addAccServiceShutdownObserver()
),
SpecialPowers.spawn(target, [], () =>
content.CommonUtils.observeAccServiceShutdown()
),
]
: [
CommonUtils.addAccServiceShutdownObserver(),
CommonUtils.observeAccServiceShutdown(),
];
}
/**

Просмотреть файл

@ -8,7 +8,7 @@
loadScripts({ name: "layout.js", dir: MOCHITESTS_DIR });
async function waitForContentPaint(browser) {
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
return new Promise(function(r) {
content.requestAnimationFrame(() => content.setTimeout(r));
});
@ -37,7 +37,7 @@ async function runTests(browser, accDoc) {
await waitForContentPaint(browser);
testTextPos(paragraph, offset, [x, docY], COORDTYPE_SCREEN_RELATIVE);
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.Layout.zoomDocument(content.document, 2.0);
});

Просмотреть файл

@ -98,10 +98,10 @@ function invokeSetAttribute(browser, id, attr, value) {
} else {
Logger.log(`Removing ${attr} attribute from node with id: ${id}`);
}
return ContentTask.spawn(
return SpecialPowers.spawn(
browser,
[id, attr, value],
([contentId, contentAttr, contentValue]) => {
(contentId, contentAttr, contentValue) => {
let elm = content.document.getElementById(contentId);
if (contentValue) {
elm.setAttribute(contentAttr, contentValue);
@ -128,10 +128,10 @@ function invokeSetStyle(browser, id, style, value) {
} else {
Logger.log(`Removing ${style} style from node with id: ${id}`);
}
return ContentTask.spawn(
return SpecialPowers.spawn(
browser,
[id, style, value],
([contentId, contentStyle, contentValue]) => {
(contentId, contentStyle, contentValue) => {
let elm = content.document.getElementById(contentId);
if (contentValue) {
elm.style[contentStyle] = contentValue;
@ -151,7 +151,7 @@ function invokeSetStyle(browser, id, style, value) {
*/
function invokeFocus(browser, id) {
Logger.log(`Setting focus on a node with id: ${id}`);
return ContentTask.spawn(browser, id, contentId => {
return SpecialPowers.spawn(browser, [id], contentId => {
let elm = content.document.getElementById(contentId);
if (elm.editor) {
elm.selectionStart = elm.selectionEnd = elm.value.length;
@ -388,7 +388,7 @@ function forceGC() {
* do this advancing the layout refresh to flush the relocations/insertions
* queue.
*/
async function contentSpawnMutation(browser, waitFor, func, args = null) {
async function contentSpawnMutation(browser, waitFor, func, args = []) {
let onReorders = waitForEvents({ expected: waitFor.expected || [] });
let unexpectedListener = new UnexpectedEvents(waitFor.unexpected || []);
@ -401,20 +401,20 @@ async function contentSpawnMutation(browser, waitFor, func, args = null) {
// This stops the refreh driver from doing its regular ticks, and leaves
// us in control.
await ContentTask.spawn(browser, null, tick);
await SpecialPowers.spawn(browser, [], tick);
// Perform the tree mutation.
await ContentTask.spawn(browser, args, func);
await SpecialPowers.spawn(browser, args, func);
// Do one tick to flush our queue (insertions, relocations, etc.)
await ContentTask.spawn(browser, null, tick);
await SpecialPowers.spawn(browser, [], tick);
let events = await onReorders;
unexpectedListener.stop();
// Go back to normal refresh driver ticks.
await ContentTask.spawn(browser, null, function() {
await SpecialPowers.spawn(browser, [], function() {
content.windowUtils.restoreNormalRefresh();
});

Просмотреть файл

@ -24,7 +24,7 @@ async function runTest(browser, accDoc) {
testStates(lastLi, STATE_OFFSCREEN, 0, STATE_INVISIBLE);
// scroll into view the item
await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("li_last").scrollIntoView(true);
});
testStates(lastLi, 0, 0, STATE_OFFSCREEN | STATE_INVISIBLE);