Bug 1816994 - ESMified UITour JSMs. r=kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D173571
This commit is contained in:
Bilal 2023-03-29 17:32:27 +00:00
parent dd166ee80e
commit 3a0a9908fa
12 changed files with 22 additions and 35 deletions

View file

@ -8,7 +8,7 @@
# See PermissionManager.cpp for more...
# UITour
# Bug 1557153: www.mozilla.org gets a special workaround in UITourChild.jsm
# Bug 1557153: www.mozilla.org gets a special workaround in UITourChild.sys.mjs
origin uitour 1 https://www.mozilla.org
origin uitour 1 https://monitor.firefox.com
origin uitour 1 https://screenshots.firefox.com

View file

@ -54,6 +54,7 @@ ChromeUtils.defineESModuleGetters(this, {
"resource:///modules/firefox-view-tabs-setup-manager.sys.mjs",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
TranslationsParent: "resource://gre/actors/TranslationsParent.sys.mjs",
UITour: "resource:///modules/UITour.sys.mjs",
UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
UrlbarInput: "resource:///modules/UrlbarInput.sys.mjs",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
@ -96,7 +97,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
SitePermissions: "resource:///modules/SitePermissions.jsm",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
Translation: "resource:///modules/translation/TranslationParent.jsm",
UITour: "resource:///modules/UITour.jsm",
WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
webrtcUI: "resource:///modules/webrtcUI.jsm",
ZoomUI: "resource:///modules/ZoomUI.jsm",

View file

@ -794,10 +794,10 @@ let JSWINDOWACTORS = {
UITour: {
parent: {
moduleURI: "resource:///modules/UITourParent.jsm",
esModuleURI: "resource:///modules/UITourParent.sys.mjs",
},
child: {
moduleURI: "resource:///modules/UITourChild.jsm",
esModuleURI: "resource:///modules/UITourChild.sys.mjs",
events: {
mozUITour: { wantUntrusted: true },
},

View file

@ -8,7 +8,7 @@
* Test opening and closing the menu panel UI.
*/
// Show and hide the menu panel programmatically without an event (like UITour.jsm would)
// Show and hide the menu panel programmatically without an event (like UITour.sys.mjs would)
add_task(async function() {
await gCUITestUtils.openMainMenu();

View file

@ -16,11 +16,9 @@ let { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
);
ChromeUtils.defineModuleGetter(
this,
"UITour",
"resource:///modules/UITour.jsm"
);
ChromeUtils.defineESModuleGetters(this, {
UITour: "resource:///modules/UITour.sys.mjs",
});
const DECKINDEX_TABS = 0;
const DECKINDEX_FETCHING = 1;

View file

@ -2,14 +2,9 @@
// 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 = ["UITour"];
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
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";
const lazy = {};
@ -78,7 +73,7 @@ XPCOMUtils.defineLazyGetter(lazy, "log", () => {
return new ConsoleAPI(consoleOptions);
});
var UITour = {
export var UITour = {
url: null,
/* Map from browser chrome windows to a Set of <browser>s in which a tour is open (both visible and hidden) */
tourBrowsersByWindow: new WeakMap(),

View file

@ -2,12 +2,10 @@
* 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 = ["UITourChild"];
const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins";
const UITOUR_PERMISSION = "uitour";
class UITourChild extends JSWindowActorChild {
export class UITourChild extends JSWindowActorChild {
handleEvent(event) {
if (!Services.prefs.getBoolPref("browser.uitour.enabled")) {
return;
@ -47,7 +45,7 @@ class UITourChild extends JSWindowActorChild {
return false;
}
// This function is copied from UITour.jsm.
// This function is copied from UITour.sys.mjs.
isSafeScheme(aURI) {
let allowedSchemes = new Set(["https", "about"]);
if (!Services.prefs.getBoolPref("browser.uitour.requireSecure")) {

View file

@ -2,11 +2,9 @@
* 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 = ["UITourParent"];
import { UITour } from "resource:///modules/UITour.sys.mjs";
let { UITour } = ChromeUtils.import("resource:///modules/UITour.jsm");
class UITourParent extends JSWindowActorParent {
export class UITourParent extends JSWindowActorParent {
receiveMessage(message) {
switch (message.name) {
case "UITour:onPageEvent":

View file

@ -2,7 +2,7 @@
# 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/.
EXTRA_JS_MODULES += ["UITour.jsm", "UITourChild.jsm", "UITourParent.jsm"]
EXTRA_JS_MODULES += ["UITour.sys.mjs", "UITourChild.sys.mjs", "UITourParent.sys.mjs"]
BROWSER_CHROME_MANIFESTS += [
"test/browser.ini",

View file

@ -3,11 +3,9 @@
// This file expects these globals to be defined by the test case.
/* global gTestTab:true, gContentAPI:true, tests:false */
ChromeUtils.defineModuleGetter(
this,
"UITour",
"resource:///modules/UITour.jsm"
);
ChromeUtils.defineESModuleGetters(this, {
UITour: "resource:///modules/UITour.sys.mjs",
});
const { PermissionTestUtils } = ChromeUtils.import(
"resource://testing-common/PermissionTestUtils.jsm"
@ -276,7 +274,7 @@ function promisePanelElementEvent(win, aPanel, aEvent) {
function onPanelEvent(e) {
aPanel.removeEventListener(aEvent, onPanelEvent);
win.clearTimeout(timeoutId);
// Wait one tick to let UITour.jsm process the event as well.
// Wait one tick to let UITour.sys.mjs process the event as well.
executeSoon(resolve);
}

View file

@ -12,11 +12,11 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs",
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
UITour: "resource:///modules/UITour.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
UITour: "resource:///modules/UITour.jsm",
Spotlight: "resource://activity-stream/lib/Spotlight.jsm",
ColorwayClosetOpener: "resource:///modules/ColorwayClosetOpener.jsm",
});

View file

@ -59,7 +59,7 @@ avoid-blacklist-and-whitelist:
- browser/components/resistfingerprinting/test/mochitest/test_bug1354633_media_error.html
- browser/components/safebrowsing/content/test/browser_whitelisted.js
- browser/components/sessionstore/test/browser_crashedTabs.js
- browser/components/uitour/UITourChild.jsm
- browser/components/uitour/UITourChild.sys.mjs
- browser/components/urlbar/tests/browser/browser_searchSingleWordNotification.js
- browser/components/urlbar/tests/browser/browser_UrlbarInput_trimURLs.js
- browser/components/urlbar/tests/unit/test_providerHeuristicFallback.js