Bug 1828461 - Load LoadURIDelegate as lazy module. r=geckoview-reviewers,calu

After landing bug 1673068, `LoadURIDelegate.jsm` isn't used until error page
is shown. This should move to lazy and convert to ES system module.

Differential Revision: https://phabricator.services.mozilla.com/D175661
This commit is contained in:
Makoto Kato 2023-04-21 01:45:22 +00:00
Родитель 0262ee3584
Коммит 6200ec5835
4 изменённых файлов: 12 добавлений и 17 удалений

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

@ -5,9 +5,12 @@
const { GeckoViewActorChild } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewActorChild.sys.mjs"
);
const { LoadURIDelegate } = ChromeUtils.import(
"resource://gre/modules/LoadURIDelegate.jsm"
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.sys.mjs",
});
var EXPORTED_SYMBOLS = ["LoadURIDelegateChild"];
@ -18,7 +21,7 @@ class LoadURIDelegateChild extends GeckoViewActorChild {
debug`handleLoadError: uri=${aUri && aUri.spec}
displaySpec=${aUri && aUri.displaySpec}
error=${aError}`;
if (aUri && LoadURIDelegate.isSafeBrowsingError(aError)) {
if (aUri && lazy.LoadURIDelegate.isSafeBrowsingError(aError)) {
const message = {
type: "GeckoView:ContentBlocked",
uri: aUri.spec,
@ -28,7 +31,7 @@ class LoadURIDelegateChild extends GeckoViewActorChild {
this.eventDispatcher.sendRequest(message);
}
return LoadURIDelegate.handleLoadError(
return lazy.LoadURIDelegate.handleLoadError(
this.contentWindow,
this.eventDispatcher,
aUri,

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

@ -10,10 +10,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.sys.mjs",
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.jsm",
LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.sys.mjs",
});
XPCOMUtils.defineLazyGetter(lazy, "ReferrerInfo", () =>

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

@ -2,17 +2,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["LoadURIDelegate"];
const { GeckoViewUtils } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewUtils.sys.mjs"
);
import { GeckoViewUtils } from "resource://gre/modules/GeckoViewUtils.sys.mjs";
const { debug, warn } = GeckoViewUtils.initLogging("LoadURIDelegate");
const LoadURIDelegate = {
export const LoadURIDelegate = {
// Delegate URI loading to the app.
// Return whether the loading has been handled.
load(aWindow, aEventDispatcher, aUri, aWhere, aFlags, aTriggeringPrincipal) {

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

@ -34,7 +34,7 @@ EXTRA_JS_MODULES += [
"GeckoViewTestUtils.jsm",
"GeckoViewUtils.sys.mjs",
"GeckoViewWebExtension.sys.mjs",
"LoadURIDelegate.jsm",
"LoadURIDelegate.sys.mjs",
"MediaUtils.jsm",
"Messaging.sys.mjs",
]