зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1531368 - Use `ChromeUtils.import` with one parameter in extensions code. r=robwu
Simplify some instances where modules were lazy loaded. Differential Revision: https://phabricator.services.mozilla.com/D118569
This commit is contained in:
Родитель
d4299b893d
Коммит
adfcd3644a
36
.eslintrc.js
36
.eslintrc.js
|
@ -558,23 +558,6 @@ module.exports = {
|
|||
"browser/components/enterprisepolicies/tests/xpcshell/head.js",
|
||||
"browser/components/enterprisepolicies/tests/xpcshell/test_proxy.js",
|
||||
"browser/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_browserAction_context.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_currentWindow.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_getViews.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_management.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_pageAction_context.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_pageAction_show_matches.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_sessions_getRecentlyClosed_private.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_sessions_restore.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_tabs_audio.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_tabs_zoom.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_windows.js",
|
||||
"browser/components/extensions/test/browser/browser_ext_windows_events.js",
|
||||
"browser/components/extensions/test/browser/head.js",
|
||||
"browser/components/extensions/test/xpcshell/test_ext_url_overrides_newtab.js",
|
||||
"browser/components/migration/tests/unit/test_Edge_db_migration.js",
|
||||
"browser/components/translation/test/unit/test_cld2.js",
|
||||
"browser/extensions/formautofill/test/unit/test_sync.js",
|
||||
|
@ -600,25 +583,6 @@ module.exports = {
|
|||
"toolkit/components/crashes/tests/xpcshell/test_crash_service.js",
|
||||
"toolkit/components/crashes/tests/xpcshell/test_crash_store.js",
|
||||
"toolkit/components/enterprisepolicies/tests/EnterprisePolicyTesting.jsm",
|
||||
"toolkit/components/extensions/ExtensionPreferencesManager.jsm",
|
||||
"toolkit/components/extensions/ExtensionXPCShellUtils.jsm",
|
||||
"toolkit/components/extensions/parent/ext-management.js",
|
||||
"toolkit/components/extensions/test/mochitest/test_ext_contentscript_cache.html",
|
||||
"toolkit/components/extensions/test/xpcshell/head_native_messaging.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_api_permissions.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_background_early_shutdown.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_background_teardown.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_contentscript_context.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_contentscript_context_isolation.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_contentscript_teardown.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_contexts_gc.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_privacy_disable.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_schemas_interactive.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_shutdown_cleanup.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_storage_sync_kinto.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_storage_sync_kinto_crypto.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_ext_tab_teardown.js",
|
||||
"toolkit/components/extensions/test/xpcshell/test_native_manifests.js",
|
||||
"toolkit/components/featuregates/test/unit/test_FeatureGate.js",
|
||||
"toolkit/components/normandy/test/browser/browser_actions_ShowHeartbeatAction.js",
|
||||
"toolkit/components/osfile/modules/osfile_async_front.jsm",
|
||||
|
|
|
@ -1047,11 +1047,11 @@ add_task(async function testNavigationClearsData() {
|
|||
let default_title = "Default title";
|
||||
let tab_title = "Tab title";
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
let extension,
|
||||
tabs = [];
|
||||
async function addTab(...args) {
|
||||
|
|
|
@ -39,7 +39,7 @@ add_task(async function testBrowserActionClickCanceled() {
|
|||
Management: {
|
||||
global: { browserActionFor },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let ext = WebExtensionPolicy.getByID(extension.id)?.extension;
|
||||
let browserAction = browserActionFor(ext);
|
||||
|
@ -184,7 +184,7 @@ add_task(async function testBrowserActionDisabled() {
|
|||
Management: {
|
||||
global: { browserActionFor },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let ext = WebExtensionPolicy.getByID(extension.id)?.extension;
|
||||
let browserAction = browserActionFor(ext);
|
||||
|
@ -350,7 +350,7 @@ add_task(async function testClosePopupDuringPreload() {
|
|||
Management: {
|
||||
global: { browserActionFor },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let ext = WebExtensionPolicy.getByID(extension.id)?.extension;
|
||||
let browserAction = browserActionFor(ext);
|
||||
|
|
|
@ -105,11 +105,11 @@ add_task(async function() {
|
|||
extension.awaitMessage("background-ready"),
|
||||
]);
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { windowTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let winId1 = windowTracker.getId(win1);
|
||||
let winId2 = windowTracker.getId(win2);
|
||||
|
|
|
@ -15,9 +15,10 @@ function frameScript() {
|
|||
}
|
||||
|
||||
let range = selection.getRangeAt(0);
|
||||
let scope = {};
|
||||
ChromeUtils.import("resource://gre/modules/FindContent.jsm", scope);
|
||||
let highlighter = new scope.FindContent(docShell).highlighter;
|
||||
const { FindContent } = ChromeUtils.import(
|
||||
"resource://gre/modules/FindContent.jsm"
|
||||
);
|
||||
let highlighter = new FindContent(docShell).highlighter;
|
||||
let r1 = content.parent.frameElement.getBoundingClientRect();
|
||||
let f1 = highlighter._getFrameElementOffsets(content.parent);
|
||||
let r2 = content.frameElement.getBoundingClientRect();
|
||||
|
|
|
@ -161,11 +161,11 @@ add_task(async function() {
|
|||
|
||||
info("started");
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { windowTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let winId1 = windowTracker.getId(win1);
|
||||
let winId2 = windowTracker.getId(win2);
|
||||
|
|
|
@ -191,13 +191,12 @@ add_task(async function overrideContext_permissions() {
|
|||
SidebarUI.browser.contentDocument.getElementById("webext-panels-browser"),
|
||||
[],
|
||||
() => {
|
||||
let { withHandlingUserInput } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionCommon.jsm",
|
||||
{}
|
||||
).ExtensionCommon;
|
||||
const { ExtensionCommon } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionCommon.jsm"
|
||||
);
|
||||
Cu.exportFunction(
|
||||
fn => {
|
||||
return withHandlingUserInput(content, fn);
|
||||
return ExtensionCommon.withHandlingUserInput(content, fn);
|
||||
},
|
||||
content,
|
||||
{
|
||||
|
|
|
@ -345,11 +345,11 @@ add_task(async function testNavigationClearsData() {
|
|||
let default_title = "Default title";
|
||||
let tab_title = "Tab title";
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
let extension,
|
||||
tabs = [];
|
||||
async function addTab(...args) {
|
||||
|
|
|
@ -59,11 +59,11 @@ let tests = [
|
|||
let urls = ["http://example.com/", "http://mochi.test:8888/", "about:rights"];
|
||||
|
||||
function getId(tab) {
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
getId = tabTracker.getId.bind(tabTracker); // eslint-disable-line no-func-assign
|
||||
return getId(tab);
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ async function run_test_extension(incognitoOverride) {
|
|||
|
||||
await extension.startup();
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { windowTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
let privateWinId = windowTracker.getId(privateWin);
|
||||
|
||||
extension.sendMessage("check-sessions");
|
||||
|
|
|
@ -68,11 +68,11 @@ add_task(async function test_sessions_restore() {
|
|||
|
||||
await extension.startup();
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { windowTracker, tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
function checkLocalTab(tab, expectedUrl) {
|
||||
let realTab = tabTracker.getTab(tab.id);
|
||||
|
|
|
@ -209,11 +209,11 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
extension.onMessage("change-tab", (tabId, attr, on) => {
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let tab = tabTracker.getTab(tabId);
|
||||
|
||||
|
|
|
@ -114,11 +114,11 @@ add_task(async function testDuplicateTabLazily() {
|
|||
});
|
||||
|
||||
extension.onMessage("duplicate-tab", tabId => {
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let tab = tabTracker.getTab(tabId);
|
||||
// This is a bit of a hack to load a tab in the background.
|
||||
|
|
|
@ -254,11 +254,11 @@ add_task(async function test_zoom_api() {
|
|||
});
|
||||
|
||||
extension.onMessage("msg", (id, msg, ...args) => {
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { tabTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let resp;
|
||||
if (msg == "get-zoom") {
|
||||
|
|
|
@ -123,11 +123,11 @@ add_task(async function testWindowTitle() {
|
|||
});
|
||||
|
||||
await extension.startup();
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { windowTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
async function createApiWin(options) {
|
||||
let promiseLoaded = BrowserTestUtils.waitForNewWindow({ url: START_URL });
|
||||
|
|
|
@ -83,11 +83,11 @@ add_task(async function test_windows_events_not_allowed() {
|
|||
return windowInfo.winId;
|
||||
}
|
||||
|
||||
let {
|
||||
const {
|
||||
Management: {
|
||||
global: { windowTracker },
|
||||
},
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
} = ChromeUtils.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
let currentWindow = window;
|
||||
let currentWindowId = windowTracker.getId(currentWindow);
|
||||
|
|
|
@ -65,13 +65,11 @@ const { ClientEnvironmentBase } = ChromeUtils.import(
|
|||
"resource://gre/modules/components-utils/ClientEnvironment.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "Management", () => {
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
);
|
||||
return Management;
|
||||
});
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Management",
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
|
||||
var {
|
||||
makeWidgetId,
|
||||
|
|
|
@ -2,21 +2,18 @@
|
|||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "Management", () => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
);
|
||||
return Management;
|
||||
});
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"AddonManager",
|
||||
"resource://gre/modules/AddonManager.jsm"
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Management",
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
|
||||
const { AboutNewTab } = ChromeUtils.import(
|
||||
"resource:///modules/AboutNewTab.jsm"
|
||||
);
|
||||
|
|
|
@ -65,14 +65,11 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
Schemas: "resource://gre/modules/Schemas.jsm",
|
||||
ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
|
||||
XPIProvider: "resource://gre/modules/addons/XPIProvider.jsm",
|
||||
});
|
||||
|
||||
// This is used for manipulating jar entry paths, which always use Unix
|
||||
// separators.
|
||||
XPCOMUtils.defineLazyGetter(this, "OSPath", () => {
|
||||
let obj = {};
|
||||
ChromeUtils.import("resource://gre/modules/osfile/ospath_unix.jsm", obj);
|
||||
return obj;
|
||||
// These are used for manipulating jar entry paths, which always use Unix
|
||||
// separators.
|
||||
basename: "resource://gre/modules/osfile/ospath_unix.jsm",
|
||||
dirname: "resource://gre/modules/osfile/ospath_unix.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "resourceProtocol", () =>
|
||||
|
@ -1256,11 +1253,11 @@ class ExtensionData {
|
|||
for (let [lang, path] of Object.entries(manifest.dictionaries)) {
|
||||
path = path.replace(/^\/+/, "");
|
||||
|
||||
let dir = OSPath.dirname(path);
|
||||
let dir = dirname(path);
|
||||
if (dir === ".") {
|
||||
dir = "";
|
||||
}
|
||||
let leafName = OSPath.basename(path);
|
||||
let leafName = basename(path);
|
||||
let affixPath = leafName.slice(0, -3) + "aff";
|
||||
|
||||
let entries = await this._readDirectory(dir);
|
||||
|
|
|
@ -25,8 +25,7 @@ var EXPORTED_SYMBOLS = ["ExtensionPreferencesManager"];
|
|||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
|
|
|
@ -37,14 +37,11 @@ XPCOMUtils.defineLazyGetter(this, "storageSvc", () =>
|
|||
);
|
||||
|
||||
// We might end up falling back to kinto...
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
XPCOMUtils.defineLazyModuleGetter(
|
||||
this,
|
||||
"extensionStorageSyncKinto",
|
||||
() =>
|
||||
ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionStorageSyncKinto.jsm",
|
||||
{}
|
||||
).extensionStorageSync
|
||||
"resource://gre/modules/ExtensionStorageSyncKinto.jsm",
|
||||
"extensionStorageSync"
|
||||
);
|
||||
|
||||
// The interfaces which define the callbacks used by the bridge. There's a
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["ExtensionTestUtils"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
|
@ -37,6 +34,11 @@ ChromeUtils.defineModuleGetter(
|
|||
"FileUtils",
|
||||
"resource://gre/modules/FileUtils.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Management",
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Schemas",
|
||||
|
@ -48,14 +50,6 @@ ChromeUtils.defineModuleGetter(
|
|||
"resource://gre/modules/Services.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "Management", () => {
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
);
|
||||
return Management;
|
||||
});
|
||||
|
||||
let BASE_MANIFEST = Object.freeze({
|
||||
applications: Object.freeze({
|
||||
gecko: Object.freeze({
|
||||
|
|
|
@ -18,7 +18,7 @@ XPCOMUtils.defineLazyGetter(this, "extensionStorageSync", () => {
|
|||
? "resource://gre/modules/ExtensionStorageSyncKinto.jsm"
|
||||
: "resource://gre/modules/ExtensionStorageSync.jsm";
|
||||
|
||||
const { extensionStorageSync } = ChromeUtils.import(url, {});
|
||||
const { extensionStorageSync } = ChromeUtils.import(url);
|
||||
return extensionStorageSync;
|
||||
});
|
||||
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
/* exported AppConstants, Assert, AppTestDelegate */
|
||||
|
||||
var { AppConstants } = SpecialPowers.Cu.import(
|
||||
"resource://gre/modules/AppConstants.jsm",
|
||||
{}
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
var { AppTestDelegate } = SpecialPowers.Cu.import(
|
||||
"resource://specialpowers/AppTestDelegate.jsm",
|
||||
{}
|
||||
"resource://specialpowers/AppTestDelegate.jsm"
|
||||
);
|
||||
|
||||
let remote = SpecialPowers.getBoolPref("extensions.webextensions.remote");
|
||||
|
@ -85,7 +83,7 @@ function waitForLoad(win) {
|
|||
/* exported loadChromeScript */
|
||||
function loadChromeScript(fn) {
|
||||
let wrapper = `
|
||||
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
const { Services } = Cu.import("resource://gre/modules/Services.jsm");
|
||||
(${fn.toString()})();`;
|
||||
|
||||
return SpecialPowers.loadChromeScript(new Function(wrapper));
|
||||
|
|
|
@ -8,10 +8,7 @@ function mockServicesChromeScript() {
|
|||
);
|
||||
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
|
||||
|
||||
const { setTimeout } = ChromeUtils.import(
|
||||
"resource://gre/modules/Timer.jsm",
|
||||
{}
|
||||
);
|
||||
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||
const registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
|
||||
let activeNotifications = Object.create(null);
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
const { Services } = SpecialPowers;
|
||||
const { NetUtil } = SpecialPowers.Cu.import(
|
||||
"resource://gre/modules/NetUtil.jsm",
|
||||
{}
|
||||
"resource://gre/modules/NetUtil.jsm"
|
||||
);
|
||||
|
||||
function checkSitePermissions(uuid, expectedPermAction, assertMessage) {
|
||||
|
|
|
@ -65,7 +65,7 @@ add_task(async function test_contentscript_cache() {
|
|||
}
|
||||
|
||||
let chromeScript, chromeScriptDone;
|
||||
let {appinfo} = SpecialPowers.Services;
|
||||
let { appinfo } = SpecialPowers.Services;
|
||||
if (appinfo.processType === appinfo.PROCESS_TYPE_CONTENT) {
|
||||
/* globals addMessageListener, assert */
|
||||
chromeScript = SpecialPowers.loadChromeScript(() => {
|
||||
|
|
|
@ -52,8 +52,8 @@ add_task(async function test_contentscript_devtools_sandbox_metadata() {
|
|||
|
||||
await extension.awaitFinish("contentScript.executed");
|
||||
|
||||
const {ExtensionContent} = SpecialPowers.Cu.import(
|
||||
"resource://gre/modules/ExtensionContent.jsm", {}
|
||||
const { ExtensionContent } = SpecialPowers.Cu.import(
|
||||
"resource://gre/modules/ExtensionContent.jsm"
|
||||
);
|
||||
|
||||
let res = ExtensionContent.getContentScriptGlobals(win);
|
||||
|
|
|
@ -42,7 +42,8 @@ add_task(async function setup() {
|
|||
let cache = imgTools.getImgCacheForDocument(document);
|
||||
cache.clearCache(false);
|
||||
function clearCache() {
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm", {}).Services.cache2.clear();
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.cache2.clear();
|
||||
}
|
||||
SpecialPowers.loadChromeScript(clearCache);
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ let windowData, testWindow;
|
|||
|
||||
add_task(async function setup() {
|
||||
let chromeScript = SpecialPowers.loadChromeScript(function() {
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm", {}).Services.cache2.clear();
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.cache2.clear();
|
||||
});
|
||||
chromeScript.destroy();
|
||||
|
||||
|
|
|
@ -185,7 +185,8 @@ add_task(async function test_webRequest_main_frame() {
|
|||
let cache = imgTools.getImgCacheForDocument(document);
|
||||
cache.clearCache(false);
|
||||
function clearCache() {
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm", {}).Services.cache2.clear();
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.cache2.clear();
|
||||
}
|
||||
SpecialPowers.loadChromeScript(clearCache);
|
||||
|
||||
|
|
|
@ -11,10 +11,22 @@ ChromeUtils.defineModuleGetter(
|
|||
"resource://testing-common/MockRegistry.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
if (AppConstants.platform == "win") {
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"SubprocessImpl",
|
||||
"resource://gre/modules/subprocess/subprocess_win.jsm"
|
||||
);
|
||||
} else {
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"SubprocessImpl",
|
||||
"resource://gre/modules/subprocess/subprocess_unix.jsm"
|
||||
);
|
||||
}
|
||||
|
||||
let { Subprocess, SubprocessImpl } = ChromeUtils.import(
|
||||
"resource://gre/modules/Subprocess.jsm",
|
||||
null
|
||||
const { Subprocess } = ChromeUtils.import(
|
||||
"resource://gre/modules/Subprocess.jsm"
|
||||
);
|
||||
|
||||
// It's important that we use a space in this directory name to make sure we
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
let { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
function getNextContext() {
|
||||
return new Promise(resolve => {
|
||||
|
|
|
@ -26,9 +26,8 @@ Services.prefs.setBoolPref(
|
|||
true
|
||||
);
|
||||
|
||||
let { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
|
||||
// Crashes a <browser>'s remote process.
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
add_task(async function test_background_reload_and_unload() {
|
||||
let events = [];
|
||||
{
|
||||
let { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
let record = (type, extensionContext) => {
|
||||
let eventType = type == "proxy-context-load" ? "load" : "unload";
|
||||
|
|
|
@ -26,9 +26,8 @@ add_task(async function test_contentscript_reload_and_unload() {
|
|||
|
||||
let events = [];
|
||||
{
|
||||
let { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
let record = (type, extensionContext) => {
|
||||
let eventType = type == "proxy-context-load" ? "load" : "unload";
|
||||
|
|
|
@ -2,15 +2,6 @@
|
|||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "Management", () => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
);
|
||||
return Management;
|
||||
});
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"AddonManager",
|
||||
|
@ -21,6 +12,11 @@ ChromeUtils.defineModuleGetter(
|
|||
"ExtensionPreferencesManager",
|
||||
"resource://gre/modules/ExtensionPreferencesManager.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Management",
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Preferences",
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { GlobalManager } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
);
|
||||
const {
|
||||
ExtensionParent: { GlobalManager },
|
||||
} = ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm");
|
||||
|
||||
add_task(async function test_global_manager_shutdown_cleanup() {
|
||||
equal(
|
||||
|
|
|
@ -657,10 +657,9 @@ add_task(async function test_setup() {
|
|||
});
|
||||
|
||||
add_task(async function test_single_initialization() {
|
||||
// Grab access to this via the backstage pass to check if we're calling openConnection too often.
|
||||
// Check if we're calling openConnection too often.
|
||||
const { FirefoxAdapter } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionStorageSyncKinto.jsm",
|
||||
null
|
||||
"resource://services-common/kinto-storage-adapter.js"
|
||||
);
|
||||
const origOpenConnection = FirefoxAdapter.openConnection;
|
||||
let callCount = 0;
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
add_task(async function test_extension_page_tabs_create_reload_and_close() {
|
||||
let events = [];
|
||||
{
|
||||
let { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
let record = (type, extensionContext) => {
|
||||
let eventType = type == "proxy-context-load" ? "load" : "unload";
|
||||
|
|
|
@ -19,7 +19,7 @@ add_task(async function test_unknown_permissions() {
|
|||
let { messages } = await promiseConsoleOutput(() => extension.startup());
|
||||
|
||||
const { WebExtensionPolicy } = Cu.getGlobalForObject(
|
||||
ChromeUtils.import("resource://gre/modules/Extension.jsm", {})
|
||||
ChromeUtils.import("resource://gre/modules/Extension.jsm")
|
||||
);
|
||||
|
||||
let policy = WebExtensionPolicy.getByID(extension.id);
|
||||
|
|
|
@ -10,9 +10,8 @@ const { FileUtils } = ChromeUtils.import(
|
|||
"resource://gre/modules/FileUtils.jsm"
|
||||
);
|
||||
const { Schemas } = ChromeUtils.import("resource://gre/modules/Schemas.jsm");
|
||||
const { Subprocess, SubprocessImpl } = ChromeUtils.import(
|
||||
"resource://gre/modules/Subprocess.jsm",
|
||||
null
|
||||
const { Subprocess } = ChromeUtils.import(
|
||||
"resource://gre/modules/Subprocess.jsm"
|
||||
);
|
||||
const { NativeApp } = ChromeUtils.import(
|
||||
"resource://gre/modules/NativeMessaging.jsm"
|
||||
|
@ -28,6 +27,17 @@ if (AppConstants.platform == "win") {
|
|||
registerCleanupFunction(() => {
|
||||
registry.shutdown();
|
||||
});
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"SubprocessImpl",
|
||||
"resource://gre/modules/subprocess/subprocess_win.jsm"
|
||||
);
|
||||
} else {
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"SubprocessImpl",
|
||||
"resource://gre/modules/subprocess/subprocess_unix.jsm"
|
||||
);
|
||||
}
|
||||
|
||||
const REGPATH = "Software\\Mozilla\\NativeMessagingHosts";
|
||||
|
|
Загрузка…
Ссылка в новой задаче