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... # See PermissionManager.cpp for more...
# UITour # 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://www.mozilla.org
origin uitour 1 https://monitor.firefox.com origin uitour 1 https://monitor.firefox.com
origin uitour 1 https://screenshots.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", "resource:///modules/firefox-view-tabs-setup-manager.sys.mjs",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs", TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
TranslationsParent: "resource://gre/actors/TranslationsParent.sys.mjs", TranslationsParent: "resource://gre/actors/TranslationsParent.sys.mjs",
UITour: "resource:///modules/UITour.sys.mjs",
UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs", UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
UrlbarInput: "resource:///modules/UrlbarInput.sys.mjs", UrlbarInput: "resource:///modules/UrlbarInput.sys.mjs",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs", UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
@ -96,7 +97,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
SitePermissions: "resource:///modules/SitePermissions.jsm", SitePermissions: "resource:///modules/SitePermissions.jsm",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm", TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
Translation: "resource:///modules/translation/TranslationParent.jsm", Translation: "resource:///modules/translation/TranslationParent.jsm",
UITour: "resource:///modules/UITour.jsm",
WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm", WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
webrtcUI: "resource:///modules/webrtcUI.jsm", webrtcUI: "resource:///modules/webrtcUI.jsm",
ZoomUI: "resource:///modules/ZoomUI.jsm", ZoomUI: "resource:///modules/ZoomUI.jsm",

View file

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

View file

@ -8,7 +8,7 @@
* Test opening and closing the menu panel UI. * 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() { add_task(async function() {
await gCUITestUtils.openMainMenu(); await gCUITestUtils.openMainMenu();

View file

@ -16,11 +16,9 @@ let { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs" "resource://services-sync/UIState.sys.mjs"
); );
ChromeUtils.defineModuleGetter( ChromeUtils.defineESModuleGetters(this, {
this, UITour: "resource:///modules/UITour.sys.mjs",
"UITour", });
"resource:///modules/UITour.jsm"
);
const DECKINDEX_TABS = 0; const DECKINDEX_TABS = 0;
const DECKINDEX_FETCHING = 1; 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 // 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/. // 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( import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -78,7 +73,7 @@ XPCOMUtils.defineLazyGetter(lazy, "log", () => {
return new ConsoleAPI(consoleOptions); return new ConsoleAPI(consoleOptions);
}); });
var UITour = { export var UITour = {
url: null, url: null,
/* Map from browser chrome windows to a Set of <browser>s in which a tour is open (both visible and hidden) */ /* Map from browser chrome windows to a Set of <browser>s in which a tour is open (both visible and hidden) */
tourBrowsersByWindow: new WeakMap(), tourBrowsersByWindow: new WeakMap(),

View file

@ -2,12 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["UITourChild"];
const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins"; const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins";
const UITOUR_PERMISSION = "uitour"; const UITOUR_PERMISSION = "uitour";
class UITourChild extends JSWindowActorChild { export class UITourChild extends JSWindowActorChild {
handleEvent(event) { handleEvent(event) {
if (!Services.prefs.getBoolPref("browser.uitour.enabled")) { if (!Services.prefs.getBoolPref("browser.uitour.enabled")) {
return; return;
@ -47,7 +45,7 @@ class UITourChild extends JSWindowActorChild {
return false; return false;
} }
// This function is copied from UITour.jsm. // This function is copied from UITour.sys.mjs.
isSafeScheme(aURI) { isSafeScheme(aURI) {
let allowedSchemes = new Set(["https", "about"]); let allowedSchemes = new Set(["https", "about"]);
if (!Services.prefs.getBoolPref("browser.uitour.requireSecure")) { 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 * 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/. */ * 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"); export class UITourParent extends JSWindowActorParent {
class UITourParent extends JSWindowActorParent {
receiveMessage(message) { receiveMessage(message) {
switch (message.name) { switch (message.name) {
case "UITour:onPageEvent": case "UITour:onPageEvent":

View file

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # 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 += [ BROWSER_CHROME_MANIFESTS += [
"test/browser.ini", "test/browser.ini",

View file

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

View file

@ -12,11 +12,11 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs", FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs",
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs", MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
UITour: "resource:///modules/UITour.sys.mjs",
}); });
XPCOMUtils.defineLazyModuleGetters(lazy, { XPCOMUtils.defineLazyModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.jsm", AddonManager: "resource://gre/modules/AddonManager.jsm",
UITour: "resource:///modules/UITour.jsm",
Spotlight: "resource://activity-stream/lib/Spotlight.jsm", Spotlight: "resource://activity-stream/lib/Spotlight.jsm",
ColorwayClosetOpener: "resource:///modules/ColorwayClosetOpener.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/resistfingerprinting/test/mochitest/test_bug1354633_media_error.html
- browser/components/safebrowsing/content/test/browser_whitelisted.js - browser/components/safebrowsing/content/test/browser_whitelisted.js
- browser/components/sessionstore/test/browser_crashedTabs.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_searchSingleWordNotification.js
- browser/components/urlbar/tests/browser/browser_UrlbarInput_trimURLs.js - browser/components/urlbar/tests/browser/browser_UrlbarInput_trimURLs.js
- browser/components/urlbar/tests/unit/test_providerHeuristicFallback.js - browser/components/urlbar/tests/unit/test_providerHeuristicFallback.js