mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 06:09:19 +00:00
Bug 1929002 - Correct extension-specific globals in eslintrc r=geckoview-reviewers,frontend-codestyle-reviewers,Standard8
- Add all current globals from _createExtGlobal in .eslintrc.js. - Remove non-existing globals. - State the sources of the extension-specific globals in .eslintrc.js. - Move extension-specific globals from common mobile/shared/ to a deeper level at mobile/shared/components/extensions/. - Remove obsolete globals/exported/import-globals-from comments from various ext-*.js files. - Fix linting errors in some tests due to use of non-global globals, that have become apparent due to the corrected linter definitions. Differential Revision: https://phabricator.services.mozilla.com/D228308
This commit is contained in:
parent
7cb9fed3a0
commit
b2f3a7b8c9
@ -8,25 +8,36 @@ module.exports = {
|
||||
extends: "../../../../toolkit/components/extensions/parent/.eslintrc.js",
|
||||
|
||||
globals: {
|
||||
// These are defined in browser/components/extensions/parent/ext-browser.js
|
||||
Tab: true,
|
||||
TabContext: true,
|
||||
Window: true,
|
||||
actionContextMenu: true,
|
||||
browserActionFor: true,
|
||||
clickModifiersFromEvent: true,
|
||||
getContainerForCookieStoreId: true,
|
||||
getTargetTabIdForToolbox: true,
|
||||
getToolboxEvalOptions: true,
|
||||
isContainerCookieStoreId: true,
|
||||
isPrivateCookieStoreId: true,
|
||||
isValidCookieStoreId: true,
|
||||
makeWidgetId: true,
|
||||
openOptionsPage: true,
|
||||
pageActionFor: true,
|
||||
replaceUrlInTab: true,
|
||||
sidebarActionFor: true,
|
||||
tabTracker: true,
|
||||
waitForTabLoaded: true,
|
||||
windowTracker: true,
|
||||
|
||||
// NOTE: Unlike ext-browser.js (and ext-toolkit.js, ext-tabs-base.js), the
|
||||
// files mentioned below are not loaded unconditionally. In practice,
|
||||
// because all ext-*.js files share the same global scope, they are likely
|
||||
// available when a dependent API is available. Before using these globals,
|
||||
// make sure that the dependent module (API) has been loaded, e.g. by only
|
||||
// using these globals when you know that an extension is using one of these
|
||||
// APIs.
|
||||
|
||||
// This is defined in browser/components/extensions/parent/ext-browserAction.js
|
||||
browserActionFor: true,
|
||||
// This is defined in browser/components/extensions/parent/ext-menus.js
|
||||
actionContextMenu: true,
|
||||
// This is defined in browser/components/extensions/parent/ext-devtools.js
|
||||
getTargetTabIdForToolbox: true,
|
||||
getToolboxEvalOptions: true,
|
||||
// This is defined in browser/components/extensions/parent/ext-pageAction.js
|
||||
pageActionFor: true,
|
||||
// This is defined in browser/components/extensions/parent/ext-sidebarAction.js
|
||||
sidebarActionFor: true,
|
||||
},
|
||||
};
|
||||
|
@ -21,6 +21,7 @@ add_task(async function test_autoDiscardable() {
|
||||
const { TabUnloader } = ChromeUtils.importESModule(
|
||||
"resource:///modules/TabUnloader.sys.mjs"
|
||||
);
|
||||
/* globals ExtensionAPI, ExtensionUtils */
|
||||
const { ExtensionError } = ExtensionUtils;
|
||||
this.experiments = class extends ExtensionAPI {
|
||||
getAPI() {
|
||||
|
@ -4,27 +4,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
globals,
|
||||
} = require("../../toolkit/components/extensions/parent/.eslintrc.js");
|
||||
|
||||
module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: ["components/extensions/ext-*.js"],
|
||||
excludedFiles: ["components/extensions/ext-c-*.js"],
|
||||
globals: {
|
||||
...globals,
|
||||
// These globals are defined in ext-android.js and can only be used in
|
||||
// the extension files that run in the parent process.
|
||||
EventDispatcher: true,
|
||||
ExtensionError: true,
|
||||
makeGlobalEvent: true,
|
||||
TabContext: true,
|
||||
tabTracker: true,
|
||||
windowTracker: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
"chrome/geckoview/**",
|
||||
|
@ -4,6 +4,43 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
globals: globalsParent,
|
||||
} = require("../../../../toolkit/components/extensions/parent/.eslintrc.js");
|
||||
|
||||
const {
|
||||
globals: globalsChild,
|
||||
} = require("../../../../toolkit/components/extensions/child/.eslintrc.js");
|
||||
|
||||
module.exports = {
|
||||
extends: "../../../../toolkit/components/extensions/.eslintrc.js",
|
||||
// Ideally mobile should also follow the convention of
|
||||
// parent/ext-*.js for parent scripts and
|
||||
// child/ext-*.js for child scripts,
|
||||
// but the current file structure predates the parent/ vs child/ separation.
|
||||
overrides: [
|
||||
{
|
||||
files: ["ext-*.js"],
|
||||
excludedFiles: ["ext-c-*.js"],
|
||||
globals: {
|
||||
...globalsParent,
|
||||
// These globals are defined in ext-android.js and can only be used in
|
||||
// the extension files that run in the parent process.
|
||||
EventDispatcher: true,
|
||||
ExtensionError: true,
|
||||
makeGlobalEvent: true,
|
||||
TabContext: true,
|
||||
tabTracker: true,
|
||||
windowTracker: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["ext-c-*.js"],
|
||||
globals: {
|
||||
...globalsChild,
|
||||
// If there were ever globals exported in ext-c-android.js for common
|
||||
// use, then they would appear here.
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -5,24 +5,6 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
globals: {
|
||||
// These are defined in the WebExtension script scopes by ExtensionCommon.sys.mjs
|
||||
Cc: true,
|
||||
Ci: true,
|
||||
Cr: true,
|
||||
Cu: true,
|
||||
AppConstants: true,
|
||||
ExtensionAPI: true,
|
||||
ExtensionAPIPersistent: true,
|
||||
ExtensionCommon: true,
|
||||
ExtensionUtils: true,
|
||||
extensions: true,
|
||||
global: true,
|
||||
require: false,
|
||||
Services: true,
|
||||
XPCOMUtils: true,
|
||||
},
|
||||
|
||||
rules: {
|
||||
// Rules from the mozilla plugin
|
||||
"mozilla/balanced-listeners": "error",
|
||||
|
@ -6,6 +6,35 @@
|
||||
|
||||
module.exports = {
|
||||
globals: {
|
||||
// These are defined in the WebExtension script scopes by
|
||||
// ExtensionCommon.sys.mjs in the _createExtGlobal method.
|
||||
AppConstants: true,
|
||||
Cc: true,
|
||||
ChromeWorker: true,
|
||||
Ci: true,
|
||||
Cr: true,
|
||||
Cu: true,
|
||||
ExtensionAPI: true,
|
||||
ExtensionAPIPersistent: true,
|
||||
ExtensionCommon: true,
|
||||
FileReader: true,
|
||||
Glean: true,
|
||||
GleanPings: true,
|
||||
IOUtils: true,
|
||||
MatchGlob: true,
|
||||
MatchPattern: true,
|
||||
MatchPatternSet: true,
|
||||
OffscreenCanvas: true,
|
||||
PathUtils: true,
|
||||
Services: true,
|
||||
StructuredCloneHolder: true,
|
||||
WebExtensionPolicy: true,
|
||||
XPCOMUtils: true,
|
||||
extensions: true,
|
||||
global: true,
|
||||
ExtensionUtils: true,
|
||||
|
||||
// This is defined in toolkit/components/extensions/child/ext-toolkit.js
|
||||
EventManager: true,
|
||||
},
|
||||
};
|
||||
|
@ -6,12 +6,35 @@
|
||||
|
||||
module.exports = {
|
||||
globals: {
|
||||
CONTAINER_STORE: true,
|
||||
DEFAULT_STORE: true,
|
||||
EventEmitter: true,
|
||||
EventManager: true,
|
||||
InputEventManager: true,
|
||||
PRIVATE_STORE: true,
|
||||
// These are defined in the WebExtension script scopes by
|
||||
// ExtensionCommon.sys.mjs in the _createExtGlobal method.
|
||||
AppConstants: true,
|
||||
Cc: true,
|
||||
ChromeWorker: true,
|
||||
Ci: true,
|
||||
Cr: true,
|
||||
Cu: true,
|
||||
ExtensionAPI: true,
|
||||
ExtensionAPIPersistent: true,
|
||||
ExtensionCommon: true,
|
||||
FileReader: true,
|
||||
Glean: true,
|
||||
GleanPings: true,
|
||||
IOUtils: true,
|
||||
MatchGlob: true,
|
||||
MatchPattern: true,
|
||||
MatchPatternSet: true,
|
||||
OffscreenCanvas: true,
|
||||
PathUtils: true,
|
||||
Services: true,
|
||||
StructuredCloneHolder: true,
|
||||
WebExtensionPolicy: true,
|
||||
XPCOMUtils: true,
|
||||
extensions: true,
|
||||
global: true,
|
||||
ExtensionUtils: true,
|
||||
|
||||
// These are defined in toolkit/components/extensions/parent/ext-tabs-base.js
|
||||
TabBase: true,
|
||||
TabManagerBase: true,
|
||||
TabTrackerBase: true,
|
||||
@ -19,6 +42,12 @@ module.exports = {
|
||||
WindowManagerBase: true,
|
||||
WindowTrackerBase: true,
|
||||
getUserContextIdForCookieStoreId: true,
|
||||
// There are defined in toolkit/components/extensions/parent/ext-toolkit.js
|
||||
CONTAINER_STORE: true,
|
||||
DEFAULT_STORE: true,
|
||||
EventEmitter: true,
|
||||
EventManager: true,
|
||||
PRIVATE_STORE: true,
|
||||
getContainerForCookieStoreId: true,
|
||||
getCookieStoreIdForContainer: true,
|
||||
getCookieStoreIdForOriginAttributes: true,
|
||||
|
@ -4,9 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// The ext-* files are imported into the same scopes.
|
||||
/* import-globals-from ext-toolkit.js */
|
||||
|
||||
// Manages an alarm created by the extension (alarms API).
|
||||
class Alarm {
|
||||
constructor(api, name, alarmInfo) {
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
/* globals DEFAULT_STORE, PRIVATE_STORE */
|
||||
|
||||
var { ExtensionError } = ExtensionUtils;
|
||||
|
||||
const SAME_SITE_STATUSES = [
|
||||
|
@ -5,8 +5,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
/* globals EventEmitter */
|
||||
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||
});
|
||||
|
@ -10,12 +10,6 @@
|
||||
getContainerForCookieStoreId,
|
||||
isValidCookieStoreId, isContainerCookieStoreId,
|
||||
EventManager, URL */
|
||||
/* global getCookieStoreIdForTab:false,
|
||||
getCookieStoreIdForContainer:false,
|
||||
getContainerForCookieStoreId: false,
|
||||
isValidCookieStoreId:false, isContainerCookieStoreId:false,
|
||||
isDefaultCookieStoreId: false, isPrivateCookieStoreId:false,
|
||||
EventManager: false */
|
||||
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
ContextualIdentityService:
|
||||
@ -33,8 +27,6 @@ var { ExtensionError } = ExtensionUtils;
|
||||
global.EventEmitter = ExtensionCommon.EventEmitter;
|
||||
global.EventManager = ExtensionCommon.EventManager;
|
||||
|
||||
/* globals DEFAULT_STORE, PRIVATE_STORE, CONTAINER_STORE */
|
||||
|
||||
global.DEFAULT_STORE = "firefox-default";
|
||||
global.PRIVATE_STORE = "firefox-private";
|
||||
global.CONTAINER_STORE = "firefox-container-";
|
||||
|
@ -47,6 +47,7 @@ let gleanFiles = {
|
||||
},
|
||||
]),
|
||||
"parent.js": () => {
|
||||
/* globals ExtensionAPI */ // (also defined for use in child.js below)
|
||||
this.gleanHelper = class extends ExtensionAPI {
|
||||
getAPI() {
|
||||
return {
|
||||
|
@ -2,6 +2,9 @@
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
const { ExtensionCommon } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/ExtensionCommon.sys.mjs"
|
||||
);
|
||||
const { ExtensionAPI } = ExtensionCommon;
|
||||
|
||||
AddonTestUtils.init(this);
|
||||
|
@ -2,6 +2,9 @@
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
const { ExtensionCommon } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/ExtensionCommon.sys.mjs"
|
||||
);
|
||||
const { ExtensionAPI } = ExtensionCommon;
|
||||
|
||||
AddonTestUtils.init(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user