Bug 1804661 - Convert browser/components/BrowserGlue.jsm to an ES module. r=Gijs,settings-reviewers,perftest-reviewers,sparky

Differential Revision: https://phabricator.services.mozilla.com/D164204
This commit is contained in:
Mark Banner 2022-12-12 14:59:18 +00:00
Родитель 1e3d30c693
Коммит 53ce0faad1
22 изменённых файлов: 38 добавлений и 59 удалений

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

@ -2372,7 +2372,7 @@ var gBrowserInit = {
* The functions scheduled here will fire from idle callbacks
* once every window has finished being restored by session
* restore, and after the equivalent only-once tasks
* have run (from _scheduleStartupIdleTasks in BrowserGlue.jsm).
* have run (from _scheduleStartupIdleTasks in BrowserGlue.sys.mjs).
*/
_schedulePerWindowIdleTasks() {
// Bail out if the window has been closed in the meantime.

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

@ -24,11 +24,11 @@ const startupPhases = {
// Anything loaded during app-startup must have a compelling reason
// to run before we have even selected the user profile.
// Consider loading your code after first paint instead,
// eg. from BrowserGlue.jsm' _onFirstWindowLoaded method).
// eg. from BrowserGlue.sys.mjs' _onFirstWindowLoaded method).
"before profile selection": {
allowlist: {
modules: new Set([
"resource:///modules/BrowserGlue.jsm",
"resource:///modules/BrowserGlue.sys.mjs",
"resource:///modules/StartupRecorder.jsm",
"resource://gre/modules/AppConstants.sys.mjs",
"resource://gre/modules/ActorManagerParent.sys.mjs",

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

@ -5,11 +5,9 @@ const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"BrowserGlue",
"resource:///modules/BrowserGlue.jsm"
);
ChromeUtils.defineESModuleGetters(this, {
BrowserGlue: "resource:///modules/BrowserGlue.sys.mjs",
});
const PREF_DFPI_ENABLED_BY_DEFAULT =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";

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

@ -13,11 +13,9 @@ const { EnterprisePolicyTesting } = ChromeUtils.importESModule(
"resource://testing-common/EnterprisePolicyTesting.sys.mjs"
);
ChromeUtils.defineModuleGetter(
this,
"BrowserGlue",
"resource:///modules/BrowserGlue.jsm"
);
ChromeUtils.defineESModuleGetters(this, {
BrowserGlue: "resource:///modules/BrowserGlue.sys.mjs",
});
const ROLLOUT_PREF_PHASE1 =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";

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

@ -198,7 +198,7 @@ function getPostUpdateOverridePage(update, defaultOverridePage) {
/**
* Open a browser window. If this is the initial launch, this function will
* attempt to use the navigator:blank window opened by BrowserGlue.jsm during
* attempt to use the navigator:blank window opened by BrowserGlue.sys.mjs during
* early startup.
*
* @param cmdLine

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

@ -2,19 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = [
"AboutHomeStartupCache",
"BrowserGlue",
"ContentPermissionPrompt",
"DefaultBrowserCheck",
];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -900,7 +889,7 @@ const STARTUP_CRASHES_END_DELAY_MS = 30 * 1000;
*/
const OBSERVE_LASTWINDOW_CLOSE_TOPICS = AppConstants.platform != "macosx";
function BrowserGlue() {
export function BrowserGlue() {
XPCOMUtils.defineLazyServiceGetter(
this,
"_userIdleService",
@ -5232,7 +5221,7 @@ const ContentPermissionIntegration = {
},
};
function ContentPermissionPrompt() {}
export function ContentPermissionPrompt() {}
ContentPermissionPrompt.prototype = {
classID: Components.ID("{d8903bf6-68d5-4e97-bcd1-e4d3012f721a}"),
@ -5328,7 +5317,7 @@ ContentPermissionPrompt.prototype = {
},
};
var DefaultBrowserCheck = {
export var DefaultBrowserCheck = {
async prompt(win) {
const shellService = win.getShellService();
const needPin = await shellService.doesAppNeedPin();
@ -5618,7 +5607,7 @@ var JawsScreenReaderVersionCheck = {
* See https://firefox-source-docs.mozilla.org/browser/components/newtab/docs/v2-system-addon/about_home_startup_cache.html
* for further details.
*/
var AboutHomeStartupCache = {
export var AboutHomeStartupCache = {
ABOUT_HOME_URI_STRING: "about:home",
SCRIPT_EXTENSION: "script",
ENABLED_PREF: "browser.startup.homepage.abouthome_cache.enabled",

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

@ -112,7 +112,7 @@ StartupRecorder.prototype = {
// We can't ensure our observer will be called first or last, so the list of
// topics we observe here should avoid the topics used to trigger things
// during startup (eg. the topics observed by BrowserGlue.jsm).
// during startup (eg. the topics observed by BrowserGlue.sys.mjs).
let topics = [
"profile-do-change", // This catches stuff loaded during app-startup
"toplevel-window-ready", // Catches stuff from final-ui-startup

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

@ -44,13 +44,13 @@ Classes = [
{
'cid': '{eab9012e-5f74-4cbc-b2b5-a590235513cc}',
'contract_ids': ['@mozilla.org/browser/browserglue;1'],
'jsm': 'resource:///modules/BrowserGlue.jsm',
'esModule': 'resource:///modules/BrowserGlue.sys.mjs',
'constructor': 'BrowserGlue',
},
{
'cid': '{d8903bf6-68d5-4e97-bcd1-e4d3012f721a}',
'contract_ids': ['@mozilla.org/content-permission/prompt;1'],
'jsm': 'resource:///modules/BrowserGlue.jsm',
'esModule': 'resource:///modules/BrowserGlue.sys.mjs',
'constructor': 'ContentPermissionPrompt',
},
]

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

@ -88,7 +88,7 @@ EXTRA_COMPONENTS += [
EXTRA_JS_MODULES += [
"BrowserContentHandler.jsm",
"BrowserGlue.jsm",
"BrowserGlue.sys.mjs",
"distribution.js",
]

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

@ -14,11 +14,9 @@ ChromeUtils.defineModuleGetter(
"resource:///modules/AboutNewTab.jsm"
);
ChromeUtils.defineModuleGetter(
lazy,
"AboutHomeStartupCache",
"resource:///modules/BrowserGlue.jsm"
);
ChromeUtils.defineESModuleGetters(lazy, {
AboutHomeStartupCache: "resource:///modules/BrowserGlue.sys.mjs",
});
const { RemotePages } = ChromeUtils.import(
"resource://gre/modules/remotepagemanager/RemotePageManagerParent.jsm"

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

@ -3,8 +3,8 @@
"use strict";
let { AboutHomeStartupCache } = ChromeUtils.import(
"resource:///modules/BrowserGlue.jsm"
let { AboutHomeStartupCache } = ChromeUtils.importESModule(
"resource:///modules/BrowserGlue.sys.mjs"
);
// Some Activity Stream preferences are JSON encoded, and quite complex.

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

@ -2,13 +2,9 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
ChromeUtils.defineESModuleGetters(this, {
BrowserGlue: "resource:///modules/BrowserGlue.sys.mjs",
Preferences: "resource://gre/modules/Preferences.sys.mjs",
});
ChromeUtils.defineModuleGetter(
this,
"BrowserGlue",
"resource:///modules/BrowserGlue.jsm"
);
const { ExperimentFakes } = ChromeUtils.import(
"resource://testing-common/NimbusTestUtils.jsm"

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

@ -3,8 +3,8 @@
"use strict";
const { DefaultBrowserCheck } = ChromeUtils.import(
"resource:///modules/BrowserGlue.jsm"
const { DefaultBrowserCheck } = ChromeUtils.importESModule(
"resource:///modules/BrowserGlue.sys.mjs"
);
const CHECK_PREF = "browser.shell.checkDefaultBrowser";

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

@ -1483,7 +1483,7 @@ class Preferences {
/**
* Initializes the showSearchSuggestionsFirst pref based on the matchGroups
* pref. This function can be removed when the corresponding UI migration in
* BrowserGlue.jsm is no longer needed.
* BrowserGlue.sys.mjs is no longer needed.
*/
initializeShowSearchSuggestionsFirstPref() {
let matchGroups = [];

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

@ -18,6 +18,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AppMenuNotifications: "resource://gre/modules/AppMenuNotifications.sys.mjs",
DefaultBrowserCheck: "resource:///modules/BrowserGlue.sys.mjs",
ProfileAge: "resource://gre/modules/ProfileAge.sys.mjs",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
UrlbarProviderTopSites: "resource:///modules/UrlbarProviderTopSites.sys.mjs",
@ -27,7 +28,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
DefaultBrowserCheck: "resource:///modules/BrowserGlue.jsm",
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
});

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

@ -271,7 +271,7 @@ Message Manager Actors
While the JSWindowActor mechanism was being designed and developed, large sections of our framescripts were converted to an "actor style" pattern to make eventual porting to JSWindowActors easier. These Actors use the Message Manager under the hood, but made it much easier to shrink our framescripts, and also allowed us to gain significant memory savings by having the actors be lazily instantiated.
You can find the list of Message Manager Actors (or "Legacy Actors") in :searchfox:`BrowserGlue.jsm <browser/components/BrowserGlue.jsm>` and :searchfox:`ActorManagerParent.sys.mjs <toolkit/modules/ActorManagerParent.sys.mjs>`, in the ``LEGACY_ACTORS`` lists.
You can find the list of Message Manager Actors (or "Legacy Actors") in :searchfox:`BrowserGlue.sys.mjs <browser/components/BrowserGlue.sys.mjs>` and :searchfox:`ActorManagerParent.sys.mjs <toolkit/modules/ActorManagerParent.sys.mjs>`, in the ``LEGACY_ACTORS`` lists.
.. note::
The split in Message Manager Actors defined between ``BrowserGlue`` and ``ActorManagerParent`` is mainly to keep Firefox Desktop specific Actors separate from Actors that can (in theory) be instantiated for non-Desktop browsers (like Fennec and GeckoView-based browsers). Firefox Desktop-specific Actors should be registered in ``BrowserGlue``. Shared "toolkit" Actors should go into ``ActorManagerParent``.
@ -386,7 +386,7 @@ The full list of registration parameters can be found:
- for JSProcessActor in file `JSProcessActor.webidl`_ as ``WindowActorOptions``, ``ProcessActorSidedOptions`` and ``ProcessActorChildOptions``.
- for JSWindowActor in file `JSWindowActor.webidl`_ as ``WindowActorOptions``, ``WindowActorSidedOptions`` and ``WindowActorChildOptions``.
Here's an example ``JSWindowActor`` registration pulled from ``BrowserGlue.jsm``:
Here's an example ``JSWindowActor`` registration pulled from ``BrowserGlue.sys.mjs``:
.. code-block:: javascript

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

@ -72,7 +72,7 @@ static bool MaybeCreateAndDispatchMozClipboardReadPasteEvent(
// Conceptionally, `ClipboardReadPasteChild` is the target of the event.
// It ensures to receive the event by declaring the event in
// <BrowserGlue.jsm>.
// <BrowserGlue.sys.mjs>.
return !NS_WARN_IF(NS_FAILED(nsContentUtils::DispatchChromeEvent(
document, ToSupports(document), u"MozClipboardReadPaste"_ns,
CanBubble::eNo, Cancelable::eNo)));

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

@ -233,7 +233,7 @@ var RemoteSecuritySettings = {
/**
* Initialize the clients (cheap instantiation) and setup their sync event.
* This static method is called from BrowserGlue.jsm soon after startup.
* This static method is called from BrowserGlue.sys.mjs soon after startup.
*
* @returns {object} instantiated clients for security remote settings.
*/

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

@ -9,12 +9,12 @@ const { ComponentUtils } = ChromeUtils.import(
);
ChromeUtils.defineESModuleGetters(this, {
AboutHomeStartupCache: "resource:///modules/BrowserGlue.sys.mjs",
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
AboutHomeStartupCache: "resource:///modules/BrowserGlue.jsm",
AboutNewTab: "resource:///modules/AboutNewTab.jsm",
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
PerTestCoverageUtils: "resource://testing-common/PerTestCoverageUtils.jsm",

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

@ -83,7 +83,7 @@ It is possible to run background tasks in non-emphemeral, i.e., persistent, prof
The technical mechanism that keeps background tasks "lightweight" is very simple. XPCOM declares a number of observer notifications for loosely coupling components via the observer service. Some of those observer notifications are declared as category notifications which allow consumers to register themselves in static components.conf registration files (or in now deprecated chrome.manifest files). In background task mode, category notifications are not registered by default.
For Firefox in particular, this means that [`BrowserContentHandler.jsm`](https://searchfox.org/mozilla-central/source/browser/components/BrowserContentHandler.jsm) is not registered as a command-line-handler. This means that [`BrowserGlue.jsm`](https://searchfox.org/mozilla-central/source/browser/components/BrowserGlue.jsm) is not loaded, and this short circuits regular headed browsing startup.
For Firefox in particular, this means that [`BrowserContentHandler.jsm`](https://searchfox.org/mozilla-central/source/browser/components/BrowserContentHandler.jsm) is not registered as a command-line-handler. This means that [`BrowserGlue.sys.mjs`](https://searchfox.org/mozilla-central/source/browser/components/BrowserGlue.sys.mjs) is not loaded, and this short circuits regular headed browsing startup.
See the [documentation for defining static components](https://firefox-source-docs.mozilla.org/build/buildsystem/defining-xpcom-components.html) for how to change this default behaviour, and [Bug 1675848](https://bugzilla.mozilla.org/show_bug.cgi?id=1675848) for details of the implementation.

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

@ -832,7 +832,7 @@ dapTelemetry:
description: DAP Telemetry
owner: simon@mozilla.com
hasExposure: false
isEarlyStartup: true # Data is sent on startup with a trigger in BrowserGlue.jsm
isEarlyStartup: true # Data is sent on startup with a trigger in BrowserGlue.sys.mjs
variables:
enabled:
type: boolean

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

@ -41,7 +41,7 @@
// Import if we can - this is a browser/ module so it may not be
// available, in which case we return null. We replace this getter
// when the module becomes available (should be on delayed startup
// when the first browser window loads, via BrowserGlue.jsm ).
// when the first browser window loads, via BrowserGlue.sys.mjs).
const kURL = "resource:///modules/ProcessHangMonitor.jsm";
if (Cu.isModuleLoaded(kURL)) {
let { ProcessHangMonitor } = ChromeUtils.import(kURL);