зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1596918: Part 2 - Add ESLint support for SpecialPowers.spawn globals. r=Standard8
This patch updates the existing ContentTask.spawn rule to do similar things for SpecialPowers.spawn calls, only with a slightly different set of globals. Differential Revision: https://phabricator.services.mozilla.com/D53739 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7593e70946
Коммит
64dd29e2b8
|
@ -18,6 +18,9 @@ ChromeUtils.defineModuleGetter(
|
||||||
"resource://testing-common/Assert.jsm"
|
"resource://testing-common/Assert.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Note: When updating the set of globals exposed to sandboxes by
|
||||||
|
// default, please also update the ESLint plugin rule defined in
|
||||||
|
// import-content-task-globals.js.
|
||||||
const SANDBOX_GLOBALS = [
|
const SANDBOX_GLOBALS = [
|
||||||
"Blob",
|
"Blob",
|
||||||
"ChromeUtils",
|
"ChromeUtils",
|
||||||
|
@ -25,6 +28,10 @@ const SANDBOX_GLOBALS = [
|
||||||
"TextEncoder",
|
"TextEncoder",
|
||||||
"URL",
|
"URL",
|
||||||
];
|
];
|
||||||
|
const EXTRA_IMPORTS = {
|
||||||
|
EventUtils: "resource://specialpowers/SpecialPowersEventUtils.jsm",
|
||||||
|
Services: "resource://gre/modules/Services.jsm",
|
||||||
|
};
|
||||||
|
|
||||||
let expectFail = false;
|
let expectFail = false;
|
||||||
function expectingFail(fn) {
|
function expectingFail(fn) {
|
||||||
|
@ -62,14 +69,16 @@ class SpecialPowersSandbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
let imports = {
|
let imports = {
|
||||||
EventUtils: "resource://specialpowers/SpecialPowersEventUtils.jsm",
|
...EXTRA_IMPORTS,
|
||||||
Services: "resource://gre/modules/Services.jsm",
|
|
||||||
...opts.imports,
|
...opts.imports,
|
||||||
};
|
};
|
||||||
for (let [symbol, url] of Object.entries(imports)) {
|
for (let [symbol, url] of Object.entries(imports)) {
|
||||||
ChromeUtils.defineModuleGetter(this.sandbox, symbol, url);
|
ChromeUtils.defineModuleGetter(this.sandbox, symbol, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: When updating the set of globals exposed to sandboxes by
|
||||||
|
// default, please also update the ESLint plugin rule defined in
|
||||||
|
// import-content-task-globals.js.
|
||||||
Object.assign(this.sandbox, {
|
Object.assign(this.sandbox, {
|
||||||
BrowsingContext,
|
BrowsingContext,
|
||||||
InspectorUtils,
|
InspectorUtils,
|
||||||
|
|
|
@ -36,5 +36,38 @@ module.exports = function(context) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"CallExpression[callee.object.name='SpecialPowers'][callee.property.name='spawn']": function(
|
||||||
|
node
|
||||||
|
) {
|
||||||
|
// The global environment of SpecialPowers.spawn tasks is
|
||||||
|
// controlled by the Sandbox environment created by
|
||||||
|
// SpecialPowersSandbox.jsm. This list should be kept in sync with
|
||||||
|
// that module.
|
||||||
|
let globals = [
|
||||||
|
"Assert",
|
||||||
|
"Blob",
|
||||||
|
"BrowsingContext",
|
||||||
|
"ChromeUtils",
|
||||||
|
"ContentTaskUtils",
|
||||||
|
"EventUtils",
|
||||||
|
"Services",
|
||||||
|
"SpecialPowers",
|
||||||
|
"TextDecoder",
|
||||||
|
"TextEncoder",
|
||||||
|
"URL",
|
||||||
|
"assert",
|
||||||
|
"content",
|
||||||
|
"docShell",
|
||||||
|
"info",
|
||||||
|
"is",
|
||||||
|
"isnot",
|
||||||
|
"ok",
|
||||||
|
"todo",
|
||||||
|
"todo_is",
|
||||||
|
];
|
||||||
|
for (let global of globals) {
|
||||||
|
helpers.addVarToScope(global, context.getScope(), false);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче