diff --git a/browser/base/content/test/performance/browser_startup_content.js b/browser/base/content/test/performance/browser_startup_content.js index e5b357f54686..741d3111ab7d 100644 --- a/browser/base/content/test/performance/browser_startup_content.js +++ b/browser/base/content/test/performance/browser_startup_content.js @@ -60,7 +60,7 @@ const known_scripts = { if (!gFissionBrowser) { known_scripts.modules.add( - "resource:///modules/sessionstore/ContentSessionStore.jsm" + "resource:///modules/sessionstore/ContentSessionStore.sys.mjs" ); } diff --git a/browser/components/sessionstore/ContentRestore.jsm b/browser/components/sessionstore/ContentRestore.sys.mjs similarity index 99% rename from browser/components/sessionstore/ContentRestore.jsm rename to browser/components/sessionstore/ContentRestore.sys.mjs index 10762860098e..7caa6dbca1f9 100644 --- a/browser/components/sessionstore/ContentRestore.jsm +++ b/browser/components/sessionstore/ContentRestore.sys.mjs @@ -2,16 +2,13 @@ * 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 = ["ContentRestore"]; - const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { SessionHistory: "resource://gre/modules/sessionstore/SessionHistory.sys.mjs", Utils: "resource://gre/modules/sessionstore/Utils.sys.mjs", }); + /** * This module implements the content side of session restoration. The chrome * side is handled by SessionStore.jsm. The functions in this module are called @@ -41,7 +38,7 @@ ChromeUtils.defineESModuleGetters(lazy, { * reset message, which causes resetRestore to be called. At that point it's * legal to begin another restore. */ -function ContentRestore(chromeGlobal) { +export function ContentRestore(chromeGlobal) { let internal = new ContentRestoreInternal(chromeGlobal); let external = {}; diff --git a/browser/components/sessionstore/ContentSessionStore.jsm b/browser/components/sessionstore/ContentSessionStore.sys.mjs similarity index 98% rename from browser/components/sessionstore/ContentSessionStore.jsm rename to browser/components/sessionstore/ContentSessionStore.sys.mjs index e9c5e6569395..7e12a94f036e 100644 --- a/browser/components/sessionstore/ContentSessionStore.jsm +++ b/browser/components/sessionstore/ContentSessionStore.sys.mjs @@ -2,16 +2,11 @@ * 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 = ["ContentSessionStore"]; - -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); -const { clearTimeout, setTimeoutWithTarget } = ChromeUtils.importESModule( - "resource://gre/modules/Timer.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; +import { + clearTimeout, + setTimeoutWithTarget, +} from "resource://gre/modules/Timer.sys.mjs"; function debug(msg) { Services.console.logStringMessage("SessionStoreContent: " + msg); @@ -19,12 +14,8 @@ function debug(msg) { const lazy = {}; -ChromeUtils.defineModuleGetter( - lazy, - "ContentRestore", - "resource:///modules/sessionstore/ContentRestore.jsm" -); ChromeUtils.defineESModuleGetters(lazy, { + ContentRestore: "resource:///modules/sessionstore/ContentRestore.sys.mjs", SessionHistory: "resource://gre/modules/sessionstore/SessionHistory.sys.mjs", }); @@ -512,7 +503,7 @@ const MESSAGES = [ "SessionStore:prepareForProcessChange", ]; -class ContentSessionStore { +export class ContentSessionStore { constructor(mm) { if (Services.appinfo.sessionHistoryInParent) { throw new Error("This frame script should not be loaded for SHIP"); diff --git a/browser/components/sessionstore/GlobalState.jsm b/browser/components/sessionstore/GlobalState.sys.mjs similarity index 95% rename from browser/components/sessionstore/GlobalState.jsm rename to browser/components/sessionstore/GlobalState.sys.mjs index d6c1e80a030e..a49fe4650d89 100644 --- a/browser/components/sessionstore/GlobalState.jsm +++ b/browser/components/sessionstore/GlobalState.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["GlobalState"]; - const EXPORTED_METHODS = [ "getState", "clear", @@ -14,10 +10,11 @@ const EXPORTED_METHODS = [ "delete", "setFromState", ]; + /** * Module that contains global session data. */ -function GlobalState() { +export function GlobalState() { let internal = new GlobalStateInternal(); let external = {}; for (let method of EXPORTED_METHODS) { diff --git a/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm b/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.sys.mjs similarity index 96% rename from browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm rename to browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.sys.mjs index 241a0b5b827b..9bfb81999f41 100644 --- a/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm +++ b/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.sys.mjs @@ -2,30 +2,19 @@ * 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 = ["RecentlyClosedTabsAndWindowsMenuUtils"]; - const lazy = {}; -ChromeUtils.defineModuleGetter( - lazy, - "PluralForm", - "resource://gre/modules/PluralForm.jsm" -); -ChromeUtils.defineModuleGetter( - lazy, - "SessionStore", - "resource:///modules/sessionstore/SessionStore.jsm" -); - ChromeUtils.defineESModuleGetters(lazy, { PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs", + PluralForm: "resource://gre/modules/PluralForm.sys.mjs", + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", }); var navigatorBundle = Services.strings.createBundle( "chrome://browser/locale/browser.properties" ); -var RecentlyClosedTabsAndWindowsMenuUtils = { +export var RecentlyClosedTabsAndWindowsMenuUtils = { /** * Builds up a document fragment of UI items for the recently closed tabs. * @param aWindow diff --git a/browser/components/sessionstore/RunState.jsm b/browser/components/sessionstore/RunState.sys.mjs similarity index 97% rename from browser/components/sessionstore/RunState.jsm rename to browser/components/sessionstore/RunState.sys.mjs index 64be1a9b05d7..94f9a86fcddc 100644 --- a/browser/components/sessionstore/RunState.jsm +++ b/browser/components/sessionstore/RunState.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["RunState"]; - const STATE_STOPPED = 0; const STATE_RUNNING = 1; const STATE_QUITTING = 2; @@ -21,7 +17,7 @@ var state = STATE_STOPPED; * the initial browser window has loaded we switch to STATE_RUNNING. On the * first notice that a browser shutdown was granted we switch to STATE_QUITTING. */ -var RunState = Object.freeze({ +export var RunState = Object.freeze({ // If we're stopped then SessionStore hasn't been initialized yet. As soon // as the session is read from disk and the initial browser window has loaded // the run state will change to STATE_RUNNING. diff --git a/browser/components/sessionstore/SessionCookies.jsm b/browser/components/sessionstore/SessionCookies.sys.mjs similarity index 98% rename from browser/components/sessionstore/SessionCookies.jsm rename to browser/components/sessionstore/SessionCookies.sys.mjs index 90a3af5d7e7b..baaa5039c773 100644 --- a/browser/components/sessionstore/SessionCookies.jsm +++ b/browser/components/sessionstore/SessionCookies.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["SessionCookies"]; - const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { @@ -17,7 +13,7 @@ const MAX_EXPIRY = Number.MAX_SAFE_INTEGER; /** * The external API implemented by the SessionCookies module. */ -var SessionCookies = Object.freeze({ +export var SessionCookies = Object.freeze({ collect() { return SessionCookiesInternal.collect(); }, diff --git a/browser/components/sessionstore/SessionFile.jsm b/browser/components/sessionstore/SessionFile.sys.mjs similarity index 97% rename from browser/components/sessionstore/SessionFile.jsm rename to browser/components/sessionstore/SessionFile.sys.mjs index 4e299662116b..b74dbc621c84 100644 --- a/browser/components/sessionstore/SessionFile.jsm +++ b/browser/components/sessionstore/SessionFile.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["SessionFile"]; - /** * Implementation of all the disk I/O required by the session store. * This is a private API, meant to be used only by the session store. @@ -19,16 +15,12 @@ var EXPORTED_SYMBOLS = ["SessionFile"]; * another attempts to copy that file. */ -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); - const lazy = {}; -XPCOMUtils.defineLazyModuleGetters(lazy, { - RunState: "resource:///modules/sessionstore/RunState.jsm", - SessionStore: "resource:///modules/sessionstore/SessionStore.jsm", - SessionWriter: "resource:///modules/sessionstore/SessionWriter.jsm", +ChromeUtils.defineESModuleGetters(lazy, { + RunState: "resource:///modules/sessionstore/RunState.sys.mjs", + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", + SessionWriter: "resource:///modules/sessionstore/SessionWriter.sys.mjs", }); const PREF_UPGRADE_BACKUP = "browser.sessionstore.upgradeBackup.latestBuildID"; @@ -38,7 +30,7 @@ const PREF_MAX_UPGRADE_BACKUPS = const PREF_MAX_SERIALIZE_BACK = "browser.sessionstore.max_serialize_back"; const PREF_MAX_SERIALIZE_FWD = "browser.sessionstore.max_serialize_forward"; -var SessionFile = { +export var SessionFile = { /** * Read the contents of the session file, asynchronously. */ diff --git a/browser/components/sessionstore/SessionMigration.jsm b/browser/components/sessionstore/SessionMigration.sys.mjs similarity index 97% rename from browser/components/sessionstore/SessionMigration.jsm rename to browser/components/sessionstore/SessionMigration.sys.mjs index 4899d7031c18..26e1e27d5010 100644 --- a/browser/components/sessionstore/SessionMigration.jsm +++ b/browser/components/sessionstore/SessionMigration.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["SessionMigration"]; - const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { @@ -78,7 +74,7 @@ var SessionMigrationInternal = { }, }; -var SessionMigration = { +export var SessionMigration = { /** * Migrate a limited set of session data from one path to another. */ diff --git a/browser/components/sessionstore/SessionSaver.jsm b/browser/components/sessionstore/SessionSaver.sys.mjs similarity index 95% rename from browser/components/sessionstore/SessionSaver.jsm rename to browser/components/sessionstore/SessionSaver.sys.mjs index 44ef4422d297..20521bf326bf 100644 --- a/browser/components/sessionstore/SessionSaver.jsm +++ b/browser/components/sessionstore/SessionSaver.sys.mjs @@ -2,34 +2,23 @@ * 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 = ["SessionSaver"]; - -const { +import { cancelIdleCallback, clearTimeout, requestIdleCallback, setTimeout, -} = ChromeUtils.importESModule("resource://gre/modules/Timer.sys.mjs"); -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); +} from "resource://gre/modules/Timer.sys.mjs"; +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { PrivacyFilter: "resource://gre/modules/sessionstore/PrivacyFilter.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", -}); - -XPCOMUtils.defineLazyModuleGetters(lazy, { - RunState: "resource:///modules/sessionstore/RunState.jsm", - SessionStore: "resource:///modules/sessionstore/SessionStore.jsm", - SessionFile: "resource:///modules/sessionstore/SessionFile.jsm", + RunState: "resource:///modules/sessionstore/RunState.sys.mjs", + SessionFile: "resource:///modules/sessionstore/SessionFile.sys.mjs", + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", }); /* @@ -74,7 +63,7 @@ var stopWatchFinish = stopWatch("finish"); /** * The external API implemented by the SessionSaver module. */ -var SessionSaver = Object.freeze({ +export var SessionSaver = Object.freeze({ /** * Immediately saves the current session to disk. */ diff --git a/browser/components/sessionstore/SessionStartup.jsm b/browser/components/sessionstore/SessionStartup.sys.mjs similarity index 97% rename from browser/components/sessionstore/SessionStartup.jsm rename to browser/components/sessionstore/SessionStartup.sys.mjs index b8a3441c9731..37d7bf387e96 100644 --- a/browser/components/sessionstore/SessionStartup.jsm +++ b/browser/components/sessionstore/SessionStartup.sys.mjs @@ -2,8 +2,6 @@ * 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"; - /** * Session Storage and Restoration * @@ -29,30 +27,21 @@ * browser.startup.page is set to 3. */ -var EXPORTED_SYMBOLS = ["SessionStartup"]; - /* :::::::: Constants and Helpers ::::::::::::::: */ const lazy = {}; -ChromeUtils.defineModuleGetter( - lazy, - "SessionFile", - "resource:///modules/sessionstore/SessionFile.jsm" -); -ChromeUtils.defineModuleGetter( - lazy, - "StartupPerformance", - "resource:///modules/sessionstore/StartupPerformance.jsm" -); +ChromeUtils.defineESModuleGetters(lazy, { + PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", + SessionFile: "resource:///modules/sessionstore/SessionFile.sys.mjs", + StartupPerformance: + "resource:///modules/sessionstore/StartupPerformance.sys.mjs", +}); ChromeUtils.defineModuleGetter( lazy, "CrashMonitor", "resource://gre/modules/CrashMonitor.jsm" ); -ChromeUtils.defineESModuleGetters(lazy, { - PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", -}); const STATE_RUNNING_STR = "running"; @@ -93,7 +82,7 @@ var gOnceInitializedDeferred = (function() { /* :::::::: The Service ::::::::::::::: */ -var SessionStartup = { +export var SessionStartup = { NO_SESSION: TYPE_NO_SESSION, RECOVER_SESSION: TYPE_RECOVER_SESSION, RESUME_SESSION: TYPE_RESUME_SESSION, diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.sys.mjs similarity index 99% rename from browser/components/sessionstore/SessionStore.jsm rename to browser/components/sessionstore/SessionStore.sys.mjs index ed20cffd9ac5..f193eea3e1d2 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["SessionStore", "_LastSession"]; - // Current version of the format used by Session Restore. const FORMAT_VERSION = 1; @@ -217,21 +213,14 @@ const BROWSER_STARTUP_RESUME_SESSION = 3; const kNoIndex = Number.MAX_SAFE_INTEGER; const kLastIndex = Number.MAX_SAFE_INTEGER - 1; -const { PrivateBrowsingUtils } = ChromeUtils.importESModule( - "resource://gre/modules/PrivateBrowsingUtils.sys.mjs" -); +import { PrivateBrowsingUtils } from "resource://gre/modules/PrivateBrowsingUtils.sys.mjs"; + const { TelemetryTimestamps } = ChromeUtils.import( "resource://gre/modules/TelemetryTimestamps.jsm" ); -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); -const { GlobalState } = ChromeUtils.import( - "resource:///modules/sessionstore/GlobalState.jsm" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; +import { GlobalState } from "resource:///modules/sessionstore/GlobalState.sys.mjs"; const lazy = {}; @@ -244,7 +233,16 @@ ChromeUtils.defineESModuleGetters(lazy, { E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs", PrivacyFilter: "resource://gre/modules/sessionstore/PrivacyFilter.sys.mjs", PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs", + RunState: "resource:///modules/sessionstore/RunState.sys.mjs", + SessionCookies: "resource:///modules/sessionstore/SessionCookies.sys.mjs", + SessionFile: "resource:///modules/sessionstore/SessionFile.sys.mjs", SessionHistory: "resource://gre/modules/sessionstore/SessionHistory.sys.mjs", + SessionSaver: "resource:///modules/sessionstore/SessionSaver.sys.mjs", + SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs", + TabAttributes: "resource:///modules/sessionstore/TabAttributes.sys.mjs", + TabState: "resource:///modules/sessionstore/TabState.sys.mjs", + TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs", + TabStateFlusher: "resource:///modules/sessionstore/TabStateFlusher.sys.mjs", setTimeout: "resource://gre/modules/Timer.sys.mjs", }); @@ -252,16 +250,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm", BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm", HomePage: "resource:///modules/HomePage.jsm", - RunState: "resource:///modules/sessionstore/RunState.jsm", - SessionCookies: "resource:///modules/sessionstore/SessionCookies.jsm", - SessionFile: "resource:///modules/sessionstore/SessionFile.jsm", - SessionSaver: "resource:///modules/sessionstore/SessionSaver.jsm", - SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm", - TabAttributes: "resource:///modules/sessionstore/TabAttributes.jsm", TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm", - TabState: "resource:///modules/sessionstore/TabState.jsm", - TabStateCache: "resource:///modules/sessionstore/TabStateCache.jsm", - TabStateFlusher: "resource:///modules/sessionstore/TabStateFlusher.jsm", }); /** @@ -278,7 +267,7 @@ var gDebuggingEnabled = false; */ var gResistFingerprintingEnabled = false; -var SessionStore = { +export var SessionStore = { get promiseInitialized() { return SessionStoreInternal.promiseInitialized; }, @@ -6865,4 +6854,4 @@ var LastSession = { }; // Exposed for tests -const _LastSession = LastSession; +export const _LastSession = LastSession; diff --git a/browser/components/sessionstore/SessionWriter.jsm b/browser/components/sessionstore/SessionWriter.sys.mjs similarity index 99% rename from browser/components/sessionstore/SessionWriter.jsm rename to browser/components/sessionstore/SessionWriter.sys.mjs index 942709c2e8da..37f565e4af75 100644 --- a/browser/components/sessionstore/SessionWriter.jsm +++ b/browser/components/sessionstore/SessionWriter.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["SessionWriter"]; - /** * We just started (we haven't written anything to disk yet) from * `Paths.clean`. The backup directory may not exist. @@ -53,7 +49,7 @@ function lockIOWithMutex() { /** * Interface dedicated to handling I/O for Session Store. */ -const SessionWriter = { +export const SessionWriter = { init(origin, useOldExtension, paths, prefs = {}) { return SessionWriterInternal.init(origin, useOldExtension, paths, prefs); }, diff --git a/browser/components/sessionstore/StartupPerformance.jsm b/browser/components/sessionstore/StartupPerformance.sys.mjs similarity index 98% rename from browser/components/sessionstore/StartupPerformance.jsm rename to browser/components/sessionstore/StartupPerformance.sys.mjs index 7e6ef84494c6..a13333d9d1ee 100644 --- a/browser/components/sessionstore/StartupPerformance.jsm +++ b/browser/components/sessionstore/StartupPerformance.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["StartupPerformance"]; - const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { clearTimeout: "resource://gre/modules/Timer.sys.mjs", @@ -19,7 +15,7 @@ const OBSERVED_TOPICS = [ "sessionstore-initiating-manual-restore", ]; -var StartupPerformance = { +export var StartupPerformance = { /** * Once we have finished restoring initial tabs, we broadcast on this topic. */ diff --git a/browser/components/sessionstore/TabAttributes.jsm b/browser/components/sessionstore/TabAttributes.sys.mjs similarity index 95% rename from browser/components/sessionstore/TabAttributes.jsm rename to browser/components/sessionstore/TabAttributes.sys.mjs index 37a40ca977f4..1c7f54b6abcb 100644 --- a/browser/components/sessionstore/TabAttributes.jsm +++ b/browser/components/sessionstore/TabAttributes.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["TabAttributes"]; - // We never want to directly read or write these attributes. // 'image' should not be accessed directly but handled by using the // gBrowser.getIcon()/setIcon() methods. @@ -22,7 +18,7 @@ const ATTRIBUTES_TO_SKIP = new Set([ // A set of tab attributes to persist. We will read a given list of tab // attributes when collecting tab data and will re-set those attributes when // the given tab data is restored to a new tab. -var TabAttributes = Object.freeze({ +export var TabAttributes = Object.freeze({ persist(name) { return TabAttributesInternal.persist(name); }, diff --git a/browser/components/sessionstore/TabState.jsm b/browser/components/sessionstore/TabState.sys.mjs similarity index 95% rename from browser/components/sessionstore/TabState.jsm rename to browser/components/sessionstore/TabState.sys.mjs index 1fe7ab1c09e9..26f5671c849d 100644 --- a/browser/components/sessionstore/TabState.jsm +++ b/browser/components/sessionstore/TabState.sys.mjs @@ -2,30 +2,18 @@ * 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 = ["TabState"]; - const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { PrivacyFilter: "resource://gre/modules/sessionstore/PrivacyFilter.sys.mjs", + TabAttributes: "resource:///modules/sessionstore/TabAttributes.sys.mjs", + TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs", }); -ChromeUtils.defineModuleGetter( - lazy, - "TabStateCache", - "resource:///modules/sessionstore/TabStateCache.jsm" -); -ChromeUtils.defineModuleGetter( - lazy, - "TabAttributes", - "resource:///modules/sessionstore/TabAttributes.jsm" -); /** * Module that contains tab state collection methods. */ -var TabState = Object.freeze({ +export var TabState = Object.freeze({ update(permanentKey, data) { TabStateInternal.update(permanentKey, data); }, diff --git a/browser/components/sessionstore/TabStateCache.jsm b/browser/components/sessionstore/TabStateCache.sys.mjs similarity index 98% rename from browser/components/sessionstore/TabStateCache.jsm rename to browser/components/sessionstore/TabStateCache.sys.mjs index 9380ed70b839..81524c4d69cd 100644 --- a/browser/components/sessionstore/TabStateCache.jsm +++ b/browser/components/sessionstore/TabStateCache.sys.mjs @@ -2,10 +2,6 @@ * 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 = ["TabStateCache"]; - /** * A cache for tabs data. * @@ -16,7 +12,7 @@ var EXPORTED_SYMBOLS = ["TabStateCache"]; * - that data is used very seldom by SessionStore; * - caching private data in addition to public data is memory consuming. */ -var TabStateCache = Object.freeze({ +export var TabStateCache = Object.freeze({ /** * Retrieves cached data for a given |tab| or associated |browser|. * diff --git a/browser/components/sessionstore/TabStateFlusher.jsm b/browser/components/sessionstore/TabStateFlusher.sys.mjs similarity index 97% rename from browser/components/sessionstore/TabStateFlusher.jsm rename to browser/components/sessionstore/TabStateFlusher.sys.mjs index 887f3ab60604..897d02b6f600 100644 --- a/browser/components/sessionstore/TabStateFlusher.jsm +++ b/browser/components/sessionstore/TabStateFlusher.sys.mjs @@ -2,16 +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/. */ -"use strict"; - -var EXPORTED_SYMBOLS = ["TabStateFlusher"]; - const lazy = {}; -ChromeUtils.defineModuleGetter( - lazy, - "SessionStore", - "resource:///modules/sessionstore/SessionStore.jsm" -); +ChromeUtils.defineESModuleGetters(lazy, { + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", +}); /** * A module that enables async flushes. Updates from frame scripts are @@ -20,7 +14,7 @@ ChromeUtils.defineModuleGetter( * wait until the frame scripts reported back. At this point the parent has the * latest data and the action can continue. */ -var TabStateFlusher = Object.freeze({ +export var TabStateFlusher = Object.freeze({ /** * Requests an async flush for the given browser. Returns a promise that will * resolve when we heard back from the content process and the parent has diff --git a/browser/components/sessionstore/content/aboutSessionRestore.js b/browser/components/sessionstore/content/aboutSessionRestore.js index 9a046cace374..321bb9d0db9e 100644 --- a/browser/components/sessionstore/content/aboutSessionRestore.js +++ b/browser/components/sessionstore/content/aboutSessionRestore.js @@ -7,11 +7,9 @@ const { AppConstants } = ChromeUtils.importESModule( "resource://gre/modules/AppConstants.sys.mjs" ); -ChromeUtils.defineModuleGetter( - this, - "SessionStore", - "resource:///modules/sessionstore/SessionStore.jsm" -); +ChromeUtils.defineESModuleGetters(this, { + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", +}); var gStateObject; var gTreeData; diff --git a/browser/components/sessionstore/content/content-sessionStore.js b/browser/components/sessionstore/content/content-sessionStore.js index 372f875a00a3..a4bdea0bdc46 100644 --- a/browser/components/sessionstore/content/content-sessionStore.js +++ b/browser/components/sessionstore/content/content-sessionStore.js @@ -6,8 +6,8 @@ "use strict"; -const { ContentSessionStore } = ChromeUtils.import( - "resource:///modules/sessionstore/ContentSessionStore.jsm" +const { ContentSessionStore } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/ContentSessionStore.sys.mjs" ); void new ContentSessionStore(this); diff --git a/browser/components/sessionstore/moz.build b/browser/components/sessionstore/moz.build index 1b0f43ea0018..d2191375a9b2 100644 --- a/browser/components/sessionstore/moz.build +++ b/browser/components/sessionstore/moz.build @@ -10,23 +10,23 @@ BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] JAR_MANIFESTS += ["jar.mn"] EXTRA_JS_MODULES.sessionstore = [ - "ContentRestore.jsm", - "ContentSessionStore.jsm", - "GlobalState.jsm", - "RecentlyClosedTabsAndWindowsMenuUtils.jsm", - "RunState.jsm", - "SessionCookies.jsm", - "SessionFile.jsm", - "SessionMigration.jsm", - "SessionSaver.jsm", - "SessionStartup.jsm", - "SessionStore.jsm", - "SessionWriter.jsm", - "StartupPerformance.jsm", - "TabAttributes.jsm", - "TabState.jsm", - "TabStateCache.jsm", - "TabStateFlusher.jsm", + "ContentRestore.sys.mjs", + "ContentSessionStore.sys.mjs", + "GlobalState.sys.mjs", + "RecentlyClosedTabsAndWindowsMenuUtils.sys.mjs", + "RunState.sys.mjs", + "SessionCookies.sys.mjs", + "SessionFile.sys.mjs", + "SessionMigration.sys.mjs", + "SessionSaver.sys.mjs", + "SessionStartup.sys.mjs", + "SessionStore.sys.mjs", + "SessionWriter.sys.mjs", + "StartupPerformance.sys.mjs", + "TabAttributes.sys.mjs", + "TabState.sys.mjs", + "TabStateCache.sys.mjs", + "TabStateFlusher.sys.mjs", ] with Files("**"): diff --git a/browser/components/sessionstore/test/browser_354894_perwindowpb.js b/browser/components/sessionstore/test/browser_354894_perwindowpb.js index d54355c7cd82..27f822f8ef26 100644 --- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js +++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js @@ -26,8 +26,8 @@ * notifications. The latter won't. */ -const { SessionStartup } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionStartup.jsm" +const { SessionStartup } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionStartup.sys.mjs" ); // The rejection "BrowserWindowTracker.getTopWindow(...) is null" is left // unhandled in some cases. This bug should be fixed, but for the moment this diff --git a/browser/components/sessionstore/test/browser_394759_basic.js b/browser/components/sessionstore/test/browser_394759_basic.js index d8b16aae7e23..442f04cd0ce2 100644 --- a/browser/components/sessionstore/test/browser_394759_basic.js +++ b/browser/components/sessionstore/test/browser_394759_basic.js @@ -8,8 +8,8 @@ const TEST_URL = "data:text/html;charset=utf-8," + ""; -const { SessionStore } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionStore.jsm" +const { SessionStore } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionStore.sys.mjs" ); /** diff --git a/browser/components/sessionstore/test/browser_461634.js b/browser/components/sessionstore/test/browser_461634.js index c713e267f07f..5de6b92c330d 100644 --- a/browser/components/sessionstore/test/browser_461634.js +++ b/browser/components/sessionstore/test/browser_461634.js @@ -2,8 +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/. */ -const { SessionStore } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionStore.jsm" +const { SessionStore } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionStore.sys.mjs" ); add_task(async function testClosedTabData() { diff --git a/browser/components/sessionstore/test/browser_closedId.js b/browser/components/sessionstore/test/browser_closedId.js index 1a362931875e..ade315a8742a 100644 --- a/browser/components/sessionstore/test/browser_closedId.js +++ b/browser/components/sessionstore/test/browser_closedId.js @@ -3,8 +3,8 @@ "use strict"; -const { SessionStore } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionStore.jsm" +const { SessionStore } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionStore.sys.mjs" ); const BACKUP_STATE = SessionStore.getBrowserState(); diff --git a/browser/components/sessionstore/test/browser_duplicate_history.js b/browser/components/sessionstore/test/browser_duplicate_history.js index f916ce4b5a5d..9e9a386e3bcf 100644 --- a/browser/components/sessionstore/test/browser_duplicate_history.js +++ b/browser/components/sessionstore/test/browser_duplicate_history.js @@ -1,18 +1,7 @@ -ChromeUtils.defineModuleGetter( - this, - "SessionStore", - "resource:///modules/sessionstore/SessionStore.jsm" -); -ChromeUtils.defineModuleGetter( - this, - "TabStateCache", - "resource:///modules/sessionstore/TabStateCache.jsm" -); -ChromeUtils.defineModuleGetter( - this, - "TabStateFlusher", - "resource:///modules/sessionstore/TabStateFlusher.jsm" -); +ChromeUtils.defineESModuleGetters(this, { + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", + TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs", +}); add_task(async function() { await BrowserTestUtils.withNewTab("http://example.com", async function( diff --git a/browser/components/sessionstore/test/browser_duplicate_tab_in_new_window.js b/browser/components/sessionstore/test/browser_duplicate_tab_in_new_window.js index 036b0081c11e..0c7782535657 100644 --- a/browser/components/sessionstore/test/browser_duplicate_tab_in_new_window.js +++ b/browser/components/sessionstore/test/browser_duplicate_tab_in_new_window.js @@ -1,8 +1,6 @@ -ChromeUtils.defineModuleGetter( - this, - "SessionStore", - "resource:///modules/sessionstore/SessionStore.jsm" -); +ChromeUtils.defineESModuleGetters(this, { + SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", +}); add_task(async function() { await BrowserTestUtils.withNewTab("https://example.com", async function( diff --git a/browser/components/sessionstore/test/browser_firefoxView_selected_restore.js b/browser/components/sessionstore/test/browser_firefoxView_selected_restore.js index 3ec073b6ace4..690c748c1052 100644 --- a/browser/components/sessionstore/test/browser_firefoxView_selected_restore.js +++ b/browser/components/sessionstore/test/browser_firefoxView_selected_restore.js @@ -1,8 +1,8 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -const { _LastSession } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionStore.jsm" +const { _LastSession } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionStore.sys.mjs" ); const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm"); diff --git a/browser/components/sessionstore/test/browser_sessionStoreContainer.js b/browser/components/sessionstore/test/browser_sessionStoreContainer.js index b10f78cfd6d3..ab92a6ba7564 100644 --- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js +++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js @@ -121,10 +121,6 @@ function waitForNewCookie() { add_task(async function test() { const USER_CONTEXTS = ["default", "personal", "work"]; - const { TabStateFlusher } = ChromeUtils.import( - "resource:///modules/sessionstore/TabStateFlusher.jsm" - ); - // Make sure userContext is enabled. await SpecialPowers.pushPrefEnv({ set: [["privacy.userContext.enabled", true]], diff --git a/browser/components/sessionstore/test/browser_undoCloseById.js b/browser/components/sessionstore/test/browser_undoCloseById.js index fa56db3bfaa2..7a513d730ce9 100644 --- a/browser/components/sessionstore/test/browser_undoCloseById.js +++ b/browser/components/sessionstore/test/browser_undoCloseById.js @@ -5,8 +5,8 @@ * This test is for the undoCloseById function. */ -const { SessionStore } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionStore.jsm" +const { SessionStore } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionStore.sys.mjs" ); async function openWindow(url) { diff --git a/browser/components/sessionstore/test/head.js b/browser/components/sessionstore/test/head.js index a3a75cedecea..4150f826c64a 100644 --- a/browser/components/sessionstore/test/head.js +++ b/browser/components/sessionstore/test/head.js @@ -20,17 +20,17 @@ const HTTPSROOT = ROOT.replace( "https://example.com/" ); -const { SessionSaver } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionSaver.jsm" +const { SessionSaver } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionSaver.sys.mjs" ); -const { SessionFile } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionFile.jsm" +const { SessionFile } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" ); -const { TabState } = ChromeUtils.import( - "resource:///modules/sessionstore/TabState.jsm" +const { TabState } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/TabState.sys.mjs" ); -const { TabStateFlusher } = ChromeUtils.import( - "resource:///modules/sessionstore/TabStateFlusher.jsm" +const { TabStateFlusher } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/TabStateFlusher.sys.mjs" ); const ss = SessionStore; diff --git a/browser/components/sessionstore/test/unit/head.js b/browser/components/sessionstore/test/unit/head.js index d7f33990e77e..7217841201b6 100644 --- a/browser/components/sessionstore/test/unit/head.js +++ b/browser/components/sessionstore/test/unit/head.js @@ -1,8 +1,6 @@ -ChromeUtils.defineModuleGetter( - this, - "SessionStartup", - "resource:///modules/sessionstore/SessionStartup.jsm" -); +ChromeUtils.defineESModuleGetters(this, { + SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs", +}); // Call a function once initialization of SessionStartup is complete function afterSessionStartupInitialization(cb) { diff --git a/browser/components/sessionstore/test/unit/test_backup_once.js b/browser/components/sessionstore/test/unit/test_backup_once.js index 4613188c1055..19bb267ef327 100644 --- a/browser/components/sessionstore/test/unit/test_backup_once.js +++ b/browser/components/sessionstore/test/unit/test_backup_once.js @@ -3,14 +3,14 @@ "use strict"; -const { SessionWriter } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionWriter.jsm" +const { SessionWriter } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionWriter.sys.mjs" ); // Make sure that we have a profile before initializing SessionFile. const profd = do_get_profile(); -const { SessionFile } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionFile.jsm" +const { SessionFile } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" ); const Paths = SessionFile.Paths; diff --git a/browser/components/sessionstore/test/unit/test_final_write_cleanup.js b/browser/components/sessionstore/test/unit/test_final_write_cleanup.js index 3660c156c260..5a55f274f5f4 100644 --- a/browser/components/sessionstore/test/unit/test_final_write_cleanup.js +++ b/browser/components/sessionstore/test/unit/test_final_write_cleanup.js @@ -7,15 +7,17 @@ * entries. */ -const { SessionWriter } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionWriter.jsm" +const { SessionWriter } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionWriter.sys.mjs" ); // Make sure that we have a profile before initializing SessionFile. do_get_profile(); const { SessionFile: { Paths }, -} = ChromeUtils.import("resource:///modules/sessionstore/SessionFile.jsm"); +} = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" +); const MAX_ENTRIES = 9; const URL = "http://example.com/#"; diff --git a/browser/components/sessionstore/test/unit/test_histogram_corrupt_files.js b/browser/components/sessionstore/test/unit/test_histogram_corrupt_files.js index d5508add7f66..5cdb8aff9f3f 100644 --- a/browser/components/sessionstore/test/unit/test_histogram_corrupt_files.js +++ b/browser/components/sessionstore/test/unit/test_histogram_corrupt_files.js @@ -14,8 +14,8 @@ const HistogramId = "FX_SESSION_RESTORE_ALL_FILES_CORRUPT"; // Prepare the session file. do_get_profile(); -const { SessionFile } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionFile.jsm" +const { SessionFile } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" ); /** diff --git a/browser/components/sessionstore/test/unit/test_migration_lz4compression.js b/browser/components/sessionstore/test/unit/test_migration_lz4compression.js index 86ff5ba4b681..7fea3ece204a 100644 --- a/browser/components/sessionstore/test/unit/test_migration_lz4compression.js +++ b/browser/components/sessionstore/test/unit/test_migration_lz4compression.js @@ -1,13 +1,13 @@ "use strict"; -const { SessionWriter } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionWriter.jsm" +const { SessionWriter } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionWriter.sys.mjs" ); // Make sure that we have a profile before initializing SessionFile. const profd = do_get_profile(); -const { SessionFile } = ChromeUtils.import( - "resource:///modules/sessionstore/SessionFile.jsm" +const { SessionFile } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" ); const Paths = SessionFile.Paths; diff --git a/browser/components/sessionstore/test/unit/test_startup_invalid_session.js b/browser/components/sessionstore/test/unit/test_startup_invalid_session.js index 823717677176..50960b1d4310 100644 --- a/browser/components/sessionstore/test/unit/test_startup_invalid_session.js +++ b/browser/components/sessionstore/test/unit/test_startup_invalid_session.js @@ -3,8 +3,8 @@ function run_test() { let profd = do_get_profile(); - var SessionFile = ChromeUtils.import( - "resource:///modules/sessionstore/SessionFile.jsm" + var SessionFile = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" ).SessionFile; let sourceSession = do_get_file("data/sessionstore_invalid.js"); diff --git a/browser/components/sessionstore/test/unit/test_startup_session_async.js b/browser/components/sessionstore/test/unit/test_startup_session_async.js index a8f72b1b3b52..a61c9fe422ec 100644 --- a/browser/components/sessionstore/test/unit/test_startup_session_async.js +++ b/browser/components/sessionstore/test/unit/test_startup_session_async.js @@ -8,8 +8,8 @@ function run_test() { let profd = do_get_profile(); - var SessionFile = ChromeUtils.import( - "resource:///modules/sessionstore/SessionFile.jsm" + var SessionFile = ChromeUtils.importESModule( + "resource:///modules/sessionstore/SessionFile.sys.mjs" ).SessionFile; let sourceSession = do_get_file("data/sessionstore_valid.js"); diff --git a/tools/lint/rejected-words.yml b/tools/lint/rejected-words.yml index abca800c239d..b6b6419a79a4 100644 --- a/tools/lint/rejected-words.yml +++ b/tools/lint/rejected-words.yml @@ -62,7 +62,7 @@ avoid-blacklist-and-whitelist: - browser/components/preferences/privacy.js - browser/components/resistfingerprinting/test/mochitest/test_bug1354633_media_error.html - browser/components/safebrowsing/content/test/browser_whitelisted.js - - browser/components/sessionstore/ContentSessionStore.jsm + - browser/components/sessionstore/ContentSessionStore.sys.mjs - browser/components/sessionstore/test/browser_crashedTabs.js - browser/components/uitour/UITourChild.jsm - browser/components/urlbar/tests/browser/browser_searchSingleWordNotification.js