Bug 1766238 - Stop using the target argument for ChromeUtils.import in accessibility tests. r=Jamie

Depends on D144561

Differential Revision: https://phabricator.services.mozilla.com/D144562
This commit is contained in:
Mark Banner 2022-04-27 08:38:35 +00:00
Родитель ddd93b8250
Коммит 1f8462cfdd
6 изменённых файлов: 34 добавлений и 19 удалений

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

@ -25,7 +25,10 @@ add_task(async function() {
"Creating a service in parent and waiting for service to be created " +
"in content"
);
await loadContentScripts(browser, "Common.jsm");
await loadContentScripts(browser, {
script: "Common.jsm",
symbol: "CommonUtils",
});
// Create a11y service in the main process. This will trigger creating of
// the a11y service in parent as well.
const [parentA11yInitObserver, parentA11yInit] = initAccService();

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

@ -25,7 +25,10 @@ add_task(async function() {
"Creating a service in parent and waiting for service to be created " +
"in content"
);
await loadContentScripts(browser, "Common.jsm");
await loadContentScripts(browser, {
script: "Common.jsm",
symbol: "CommonUtils",
});
// Create a11y service in the main process. This will trigger creating of
// the a11y service in parent as well.
const [parentA11yInitObserver, parentA11yInit] = initAccService();

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

@ -22,7 +22,10 @@ add_task(async function() {
},
async function(browser) {
info("Creating a service in content");
await loadContentScripts(browser, "Common.jsm");
await loadContentScripts(browser, {
script: "Common.jsm",
symbol: "CommonUtils",
});
// Create a11y service in the content process.
const [a11yInitObserver, a11yInit] = initAccService(browser);
await a11yInitObserver;

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

@ -25,7 +25,10 @@ add_task(async function() {
"Creating a service in parent and waiting for service to be created " +
"in content"
);
await loadContentScripts(browser, "Common.jsm");
await loadContentScripts(browser, {
script: "Common.jsm",
symbol: "CommonUtils",
});
// Create a11y service in the main process. This will trigger creating of
// the a11y service in parent as well.
const [parentA11yInitObserver, parentA11yInit] = initAccService();

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

@ -8,7 +8,10 @@
loadScripts({ name: "layout.js", dir: MOCHITESTS_DIR });
async function runTests(browser, accDoc) {
await loadContentScripts(browser, "Layout.jsm");
await loadContentScripts(browser, {
script: "Layout.jsm",
symbol: "Layout",
});
let paragraph = findAccessibleChildByID(accDoc, "paragraph", [
nsIAccessibleText,

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

@ -323,16 +323,8 @@ function loadScripts(...scripts) {
* a list of scripts to load into content
*/
async function loadContentScripts(target, ...scripts) {
for (let script of scripts) {
let contentScript;
if (typeof script === "string") {
// If script string includes a .jsm extention, assume it is a module path.
contentScript = `${CURRENT_DIR}${script}`;
} else {
// Script is a object that has { dir, name } format.
contentScript = `${script.dir}${script.name}`;
}
for (let { script, symbol } of scripts) {
let contentScript = `${CURRENT_DIR}${script}`;
let loadedScriptSet = LOADED_CONTENT_SCRIPTS.get(contentScript);
if (!loadedScriptSet) {
loadedScriptSet = new WeakSet();
@ -341,9 +333,14 @@ async function loadContentScripts(target, ...scripts) {
continue;
}
await SpecialPowers.spawn(target, [contentScript], async _contentScript => {
ChromeUtils.import(_contentScript, content.window);
});
await SpecialPowers.spawn(
target,
[contentScript, symbol],
async (_contentScript, importSymbol) => {
let module = ChromeUtils.import(_contentScript);
content.window[importSymbol] = module[importSymbol];
}
);
loadedScriptSet.add(target);
}
}
@ -519,7 +516,10 @@ function accessibleTask(doc, task, options = {}) {
}
await SimpleTest.promiseFocus(browser);
await loadContentScripts(browser, "Common.jsm");
await loadContentScripts(browser, {
script: "Common.jsm",
symbol: "CommonUtils",
});
if (options.chrome) {
ok(!browser.isRemoteBrowser, "Not remote browser");