diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 37da59e4ad30..977c17a94ea6 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3240,9 +3240,7 @@ function getMeOutOfHere() { * that has certificate errors, we can get them somewhere safe. */ function goBackFromErrorPage() { - const ss = Cc["@mozilla.org/browser/sessionstore;1"]. - getService(Ci.nsISessionStore); - let state = JSON.parse(ss.getTabState(gBrowser.selectedTab)); + let state = JSON.parse(SessionStore.getTabState(gBrowser.selectedTab)); if (state.index == 1) { // If the unsafe page is the first or the only one in history, go to the // start page. diff --git a/browser/base/content/test/about/browser_aboutCertError.js b/browser/base/content/test/about/browser_aboutCertError.js index 9ca51ba1fbf8..05048a8c43b8 100644 --- a/browser/base/content/test/about/browser_aboutCertError.js +++ b/browser/base/content/test/about/browser_aboutCertError.js @@ -12,7 +12,6 @@ const BAD_CERT = "https://expired.example.com/"; const UNKNOWN_ISSUER = "https://self-signed.example.com "; const BAD_STS_CERT = "https://badchain.include-subdomains.pinning.example.com:443"; const {TabStateFlusher} = ChromeUtils.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); function injectErrorPageFrame(tab, src) { return ContentTask.spawn(tab.linkedBrowser, {frameSrc: src}, async function({frameSrc}) { @@ -61,7 +60,7 @@ add_task(async function checkReturnToAboutHome() { // Populate the shistory entries manually, since it happens asynchronously // and the following tests will be too soon otherwise. await TabStateFlusher.flush(browser); - let {entries} = JSON.parse(ss.getTabState(tab)); + let {entries} = JSON.parse(SessionStore.getTabState(tab)); is(entries.length, 1, "there is one shistory entry"); info("Clicking the go back button on about:certerror"); @@ -113,7 +112,7 @@ add_task(async function checkReturnToPreviousPage() { // Populate the shistory entries manually, since it happens asynchronously // and the following tests will be too soon otherwise. await TabStateFlusher.flush(browser); - let {entries} = JSON.parse(ss.getTabState(tab)); + let {entries} = JSON.parse(SessionStore.getTabState(tab)); is(entries.length, 2, "there are two shistory entries"); info("Clicking the go back button on about:certerror"); diff --git a/browser/base/content/test/about/browser_aboutNetError.js b/browser/base/content/test/about/browser_aboutNetError.js index 0b2197baf904..2c703eb71cb5 100644 --- a/browser/base/content/test/about/browser_aboutNetError.js +++ b/browser/base/content/test/about/browser_aboutNetError.js @@ -8,8 +8,6 @@ Services.prefs.setIntPref("security.tls.version.max", 3); Services.prefs.setIntPref("security.tls.version.min", 3); const LOW_TLS_VERSION = "https://tls1.example.com/"; -const {TabStateFlusher} = ChromeUtils.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); add_task(async function checkReturnToPreviousPage() { info("Loading a TLS page that isn't supported, ensure we have a fix button and clicking it then loads the page"); diff --git a/browser/base/content/test/general/browser_audioTabIcon.js b/browser/base/content/test/general/browser_audioTabIcon.js index 054089acb4d3..6b03a38493ea 100644 --- a/browser/base/content/test/general/browser_audioTabIcon.js +++ b/browser/base/content/test/general/browser_audioTabIcon.js @@ -170,8 +170,7 @@ async function test_mute_tab(tab, icon, expectMuted) { } function get_tab_state(tab) { - const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - return JSON.parse(ss.getTabState(tab)); + return JSON.parse(SessionStore.getTabState(tab)); } async function test_muting_using_menu(tab, expectMuted) { diff --git a/browser/base/content/test/tabs/browser_bug_1387976_restore_lazy_tab_browser_muted_state.js b/browser/base/content/test/tabs/browser_bug_1387976_restore_lazy_tab_browser_muted_state.js index 612cc9b9d5a3..6d314b3d27cd 100644 --- a/browser/base/content/test/tabs/browser_bug_1387976_restore_lazy_tab_browser_muted_state.js +++ b/browser/base/content/test/tabs/browser_bug_1387976_restore_lazy_tab_browser_muted_state.js @@ -23,8 +23,7 @@ const restartTab = async function(tab) { }; function get_tab_state(tab) { - const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - return JSON.parse(ss.getTabState(tab)); + return JSON.parse(SessionStore.getTabState(tab)); } add_task(async function() { diff --git a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js index 11a0a6641f21..e9b043e53964 100644 --- a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js +++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js @@ -1,5 +1,3 @@ -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm", {}); const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL; @@ -68,7 +66,7 @@ add_task(async function() { let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank"); // Fake a post-crash tab - ss.setTabState(tab, JSON.stringify(TAB_STATE)); + SessionStore.setTabState(tab, JSON.stringify(TAB_STATE)); await BrowserTestUtils.browserLoaded(tab.linkedBrowser); let doc = tab.linkedBrowser.contentDocument; diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index dad5148bdc0d..5f972153863e 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -2334,6 +2334,9 @@ var SessionStoreInternal = { }, getTabState: function ssi_getTabState(aTab) { + if (!aTab || !aTab.ownerGlobal) { + throw Components.Exception("Need a valid tab", Cr.NS_ERROR_INVALID_ARG); + } if (!aTab.ownerGlobal.__SSi) { throw Components.Exception("Default view is not tracked", Cr.NS_ERROR_INVALID_ARG); } @@ -2360,7 +2363,7 @@ var SessionStoreInternal = { } let window = aTab.ownerGlobal; - if (!("__SSi" in window)) { + if (!window || !("__SSi" in window)) { throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG); } @@ -2375,6 +2378,9 @@ var SessionStoreInternal = { }, duplicateTab: function ssi_duplicateTab(aWindow, aTab, aDelta = 0, aRestoreImmediately = true) { + if (!aTab || !aTab.ownerGlobal) { + throw Components.Exception("Need a valid tab", Cr.NS_ERROR_INVALID_ARG); + } if (!aTab.ownerGlobal.__SSi) { throw Components.Exception("Default view is not tracked", Cr.NS_ERROR_INVALID_ARG); } diff --git a/browser/components/sessionstore/content/aboutSessionRestore.js b/browser/components/sessionstore/content/aboutSessionRestore.js index d4881b68c862..212e0955a4ca 100644 --- a/browser/components/sessionstore/content/aboutSessionRestore.js +++ b/browser/components/sessionstore/content/aboutSessionRestore.js @@ -8,6 +8,8 @@ ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.defineModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm"); +ChromeUtils.defineModuleGetter(this, "SessionStore", + "resource:///modules/sessionstore/SessionStore.jsm"); var gStateObject; var gTreeData; @@ -151,12 +153,11 @@ function restoreSession() { } var stateString = JSON.stringify(gStateObject); - var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); var top = getBrowserWindow(); // if there's only this page open, reuse the window for restoring the session if (top.gBrowser.tabs.length == 1) { - ss.setWindowState(top, stateString, true); + SessionStore.setWindowState(top, stateString, true); return; } @@ -169,7 +170,7 @@ function restoreSession() { } Services.obs.removeObserver(observe, topic); - ss.setWindowState(newWindow, stateString, true); + SessionStore.setWindowState(newWindow, stateString, true); var tabbrowser = top.gBrowser; var tabIndex = tabbrowser.getBrowserIndexForDocument(document); @@ -268,12 +269,11 @@ function restoreSingleTab(aIx, aShifted) { var newTab = tabbrowser.addTab(); var item = gTreeData[aIx]; - var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); var tabState = gStateObject.windows[item.parent.ix] .tabs[aIx - gTreeData.indexOf(item.parent) - 1]; // ensure tab would be visible on the tabstrip. tabState.hidden = false; - ss.setTabState(newTab, JSON.stringify(tabState)); + SessionStore.setTabState(newTab, JSON.stringify(tabState)); // respect the preference as to whether to select the tab (the Shift key inverses) if (Services.prefs.getBoolPref("browser.tabs.loadInBackground") != !aShifted) diff --git a/browser/components/sessionstore/moz.build b/browser/components/sessionstore/moz.build index 10553b59ef20..d85dea9cf371 100644 --- a/browser/components/sessionstore/moz.build +++ b/browser/components/sessionstore/moz.build @@ -11,7 +11,6 @@ JAR_MANIFESTS += ['jar.mn'] XPIDL_SOURCES += [ 'nsISessionStartup.idl', - 'nsISessionStore.idl', 'nsISessionStoreUtils.idl', ] @@ -19,8 +18,7 @@ XPIDL_MODULE = 'sessionstore' EXTRA_COMPONENTS += [ 'nsSessionStartup.js', - 'nsSessionStore.js', - 'nsSessionStore.manifest', + 'nsSessionStartup.manifest', ] EXTRA_JS_MODULES.sessionstore = [ diff --git a/browser/components/sessionstore/nsISessionStore.idl b/browser/components/sessionstore/nsISessionStore.idl deleted file mode 100644 index ff411dd79ac6..000000000000 --- a/browser/components/sessionstore/nsISessionStore.idl +++ /dev/null @@ -1,220 +0,0 @@ -/* 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/. */ - -#include "nsISupports.idl" - -interface nsIDOMWindow; -interface nsIDOMNode; - -/** - * nsISessionStore keeps track of the current browsing state - i.e. - * tab history, cookies, scroll state, form data, and window features - * - and allows to restore everything into one browser window. - * - * The nsISessionStore API operates mostly on browser windows and the tabbrowser - * tabs contained in them: - * - * * "Browser windows" are those DOM windows having loaded - * chrome://browser/content/browser.xul . From overlays you can just pass the - * global |window| object to the API, though (or |top| from a sidebar). - * From elsewhere you can get browser windows through the nsIWindowMediator - * by looking for "navigator:browser" windows. - * - * * "Tabbrowser tabs" are all the child nodes of a browser window's - * |gBrowser.tabContainer| such as e.g. |gBrowser.selectedTab|. - */ - -[scriptable, uuid(4580f5eb-693d-423d-b0ce-2cb20a962e4d)] -interface nsISessionStore : nsISupports -{ - /** - * Is it possible to restore the previous session. Will always be false when - * in Private Browsing mode. - */ - attribute boolean canRestoreLastSession; - - /** - * Restore the previous session if possible. This will not overwrite the - * current session. Instead the previous session will be merged into the - * current session. Current windows will be reused if they were windows that - * pinned tabs were previously restored into. New windows will be opened as - * needed. - * - * Note: This will throw if there is no previous state to restore. Check with - * canRestoreLastSession first to avoid thrown errors. - */ - void restoreLastSession(); - - /** - * Get the current browsing state. - * @returns a JSON string representing the session state. - */ - AString getBrowserState(); - - /** - * Set the browsing state. - * This will immediately restore the state of the whole application to the state - * passed in, *replacing* the current session. - * - * @param aState is a JSON string representing the session state. - */ - void setBrowserState(in AString aState); - - /** - * @param aWindow is the browser window whose state is to be returned. - * - * @returns a JSON string representing a session state with only one window. - */ - AString getWindowState(in nsIDOMWindow aWindow); - - /** - * @param aWindow is the browser window whose state is to be set. - * @param aState is a JSON string representing a session state. - * @param aOverwrite boolean overwrite existing tabs - */ - void setWindowState(in nsIDOMWindow aWindow, in AString aState, in boolean aOverwrite); - - /** - * @param aTab is the tabbrowser tab whose state is to be returned. - * - * @returns a JSON string representing the state of the tab - * (note: doesn't contain cookies - if you need them, use getWindowState instead). - */ - AString getTabState(in nsIDOMNode aTab); - - /** - * @param aTab is the tabbrowser tab whose state is to be set. - * @param aState is a JSON string representing a session state. - */ - void setTabState(in nsIDOMNode aTab, in AString aState); - - /** - * Duplicates a given tab as thoroughly as possible. - * - * @param aWindow is the browser window into which the tab will be duplicated. - * @param aTab is the tabbrowser tab to duplicate (can be from a different window). - * @param aDelta is the offset to the history entry to load in the duplicated tab. - * @returns a reference to the newly created tab. - */ - nsIDOMNode duplicateTab(in nsIDOMWindow aWindow, in nsIDOMNode aTab, - [optional] in long aDelta); - - /** - * Get the number of restore-able tabs for a browser window - */ - unsigned long getClosedTabCount(in nsIDOMWindow aWindow); - - /** - * Get closed tab data - * - * @param aWindow is the browser window for which to get closed tab data - * @returns a JSON string representing the list of closed tabs. - */ - AString getClosedTabData(in nsIDOMWindow aWindow); - - /** - * @param aWindow is the browser window to reopen a closed tab in. - * @param aIndex is the index of the tab to be restored (FIFO ordered). - * @returns a reference to the reopened tab. - */ - nsIDOMNode undoCloseTab(in nsIDOMWindow aWindow, in unsigned long aIndex); - - /** - * @param aWindow is the browser window associated with the closed tab. - * @param aIndex is the index of the closed tab to be removed (FIFO ordered). - */ - nsIDOMNode forgetClosedTab(in nsIDOMWindow aWindow, in unsigned long aIndex); - - /** - * Get the number of restore-able windows - */ - unsigned long getClosedWindowCount(); - - /** - * Get closed windows data - * - * @returns a JSON string representing the list of closed windows. - */ - AString getClosedWindowData(); - - /** - * @param aIndex is the index of the windows to be restored (FIFO ordered). - * @returns the nsIDOMWindow object of the reopened window - */ - nsIDOMWindow undoCloseWindow(in unsigned long aIndex); - - /** - * @param aIndex is the index of the closed window to be removed (FIFO ordered). - * - * @throws NS_ERROR_INVALID_ARG - * when aIndex does not map to a closed window - */ - nsIDOMNode forgetClosedWindow(in unsigned long aIndex); - - /** - * @param aWindow is the window to get the value for. - * @param aKey is the value's name. - * - * @returns A string value or an empty string if none is set. - */ - AString getWindowValue(in nsIDOMWindow aWindow, in AString aKey); - - /** - * @param aWindow is the browser window to set the value for. - * @param aKey is the value's name. - * @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects). - */ - void setWindowValue(in nsIDOMWindow aWindow, in AString aKey, in jsval aStringValue); - - /** - * @param aWindow is the browser window to get the value for. - * @param aKey is the value's name. - */ - void deleteWindowValue(in nsIDOMWindow aWindow, in AString aKey); - - /** - * @param aTab is the tabbrowser tab to get the value for. - * @param aKey is the value's name. - * - * @returns A string value or an empty string if none is set. - */ - AString getCustomTabValue(in nsIDOMNode aTab, in AString aKey); - - /** - * @param aTab is the tabbrowser tab to set the value for. - * @param aKey is the value's name. - * @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects). - */ - void setCustomTabValue(in nsIDOMNode aTab, in AString aKey, in jsval aStringValue); - - /** - * @param aTab is the tabbrowser tab to get the value for. - * @param aKey is the value's name. - */ - void deleteCustomTabValue(in nsIDOMNode aTab, in AString aKey); - - /** - * @param aKey is the value's name. - * - * @returns A string value or an empty string if none is set. - */ - AString getGlobalValue(in AString aKey); - - /** - * @param aKey is the value's name. - * @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects). - */ - void setGlobalValue(in AString aKey, in jsval aStringValue); - - /** - * @param aTab is the browser tab to get the value for. - * @param aKey is the value's name. - */ - void deleteGlobalValue(in AString aKey); - - /** - * @param aName is the name of the attribute to save/restore for all tabbrowser tabs. - */ - void persistTabAttribute(in AString aName); -}; diff --git a/browser/components/sessionstore/nsSessionStore.manifest b/browser/components/sessionstore/nsSessionStartup.manifest similarity index 81% rename from browser/components/sessionstore/nsSessionStore.manifest rename to browser/components/sessionstore/nsSessionStartup.manifest index 1d98adc3b9f2..0d0c6e30b371 100644 --- a/browser/components/sessionstore/nsSessionStore.manifest +++ b/browser/components/sessionstore/nsSessionStartup.manifest @@ -5,8 +5,6 @@ # browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384} # mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110} -component {5280606b-2510-4fe0-97ef-9b5a22eafe6b} nsSessionStore.js -contract @mozilla.org/browser/sessionstore;1 {5280606b-2510-4fe0-97ef-9b5a22eafe6b} component {ec7a6c20-e081-11da-8ad9-0800200c9a66} nsSessionStartup.js contract @mozilla.org/browser/sessionstartup;1 {ec7a6c20-e081-11da-8ad9-0800200c9a66} category app-startup nsSessionStartup service,@mozilla.org/browser/sessionstartup;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} diff --git a/browser/components/sessionstore/nsSessionStore.js b/browser/components/sessionstore/nsSessionStore.js deleted file mode 100644 index 2b2c7a1be978..000000000000 --- a/browser/components/sessionstore/nsSessionStore.js +++ /dev/null @@ -1,36 +0,0 @@ -/* 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"; - -/** - * Session Storage and Restoration - * - * Overview - * This service keeps track of a user's session, storing the various bits - * required to return the browser to its current state. The relevant data is - * stored in memory, and is periodically saved to disk in a file in the - * profile directory. The service is started at first window load, in - * delayedStartup, and will restore the session from the data received from - * the nsSessionStartup service. - */ - -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource:///modules/sessionstore/SessionStore.jsm"); - -function SessionStoreService() {} - -// The SessionStore module's object is frozen. We need to modify our prototype -// and add some properties so let's just copy the SessionStore object. -Object.keys(SessionStore).forEach(function(aName) { - let desc = Object.getOwnPropertyDescriptor(SessionStore, aName); - Object.defineProperty(SessionStoreService.prototype, aName, desc); -}); - -SessionStoreService.prototype.classID = - Components.ID("{5280606b-2510-4fe0-97ef-9b5a22eafe6b}"); -SessionStoreService.prototype.QueryInterface = - XPCOMUtils.generateQI([Ci.nsISessionStore]); - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SessionStoreService]); diff --git a/browser/components/sessionstore/test/browser_345898.js b/browser/components/sessionstore/test/browser_345898.js index 0cd0ddbab6df..d995f055c1ce 100644 --- a/browser/components/sessionstore/test/browser_345898.js +++ b/browser/components/sessionstore/test/browser_345898.js @@ -13,16 +13,16 @@ function test() { /NS_ERROR_ILLEGAL_VALUE/, "Invalid window for setWindowState throws"); Assert.throws(() => ss.getTabState({}), - /NS_ERROR_FAILURE/, + /NS_ERROR_ILLEGAL_VALUE/, "Invalid tab for getTabState throws"); Assert.throws(() => ss.setTabState({}, "{}"), - /NS_ERROR_FAILURE/, + /NS_ERROR_ILLEGAL_VALUE/, "Invalid tab state for setTabState throws"); Assert.throws(() => ss.setTabState({}, JSON.stringify({ entries: [] })), - /NS_ERROR_FAILURE/, + /NS_ERROR_ILLEGAL_VALUE/, "Invalid tab for setTabState throws"); Assert.throws(() => ss.duplicateTab({}, {}), - /NS_ERROR_FAILURE/, + /NS_ERROR_ILLEGAL_VALUE/, "Invalid tab for duplicateTab throws"); Assert.throws(() => ss.duplicateTab({}, gBrowser.selectedTab), /NS_ERROR_ILLEGAL_VALUE/, diff --git a/browser/components/sessionstore/test/browser_589246.js b/browser/components/sessionstore/test/browser_589246.js index 6d5e13c55ff1..67743d5c19db 100644 --- a/browser/components/sessionstore/test/browser_589246.js +++ b/browser/components/sessionstore/test/browser_589246.js @@ -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/. */ -// Mirrors WINDOW_ATTRIBUTES IN nsSessionStore.js +// Mirrors WINDOW_ATTRIBUTES IN SessionStore.jsm const WINDOW_ATTRIBUTES = ["width", "height", "screenX", "screenY", "sizemode"]; var stateBackup = ss.getBrowserState(); @@ -38,7 +38,7 @@ function checkOSX34Generator(num) { // should be in aCurState. So let's shape our expectations. let expectedState = JSON.parse(aPreviousState); expectedState[0].tabs.shift(); - // size attributes are stripped out in _prepDataForDeferredRestore in nsSessionStore. + // size attributes are stripped out in _prepDataForDeferredRestore in SessionStore.jsm. // This isn't the best approach, but neither is comparing JSON strings WINDOW_ATTRIBUTES.forEach(attr => delete expectedState[0][attr]); diff --git a/browser/components/sessionstore/test/browser_sessionStoreContainer.js b/browser/components/sessionstore/test/browser_sessionStoreContainer.js index 7fcf2b68f02b..c168d42efb48 100644 --- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js +++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js @@ -102,7 +102,6 @@ add_task(async function test() { "work", ]; - const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); const { TabStateFlusher } = ChromeUtils.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); // Make sure userContext is enabled. @@ -133,7 +132,7 @@ add_task(async function test() { gBrowser.removeTab(tab); } - let state = JSON.parse(ss.getBrowserState()); + let state = JSON.parse(SessionStore.getBrowserState()); is(state.cookies.length, USER_CONTEXTS.length, "session restore should have each container's cookie"); }); diff --git a/browser/components/sessionstore/test/head.js b/browser/components/sessionstore/test/head.js index 6e1d7016a507..e45841230a12 100644 --- a/browser/components/sessionstore/test/head.js +++ b/browser/components/sessionstore/test/head.js @@ -25,13 +25,11 @@ registerCleanupFunction(() => { } }); -const {SessionStore} = ChromeUtils.import("resource:///modules/sessionstore/SessionStore.jsm", {}); const {SessionSaver} = ChromeUtils.import("resource:///modules/sessionstore/SessionSaver.jsm", {}); const {SessionFile} = ChromeUtils.import("resource:///modules/sessionstore/SessionFile.jsm", {}); const {TabState} = ChromeUtils.import("resource:///modules/sessionstore/TabState.jsm", {}); const {TabStateFlusher} = ChromeUtils.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); - -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); +const ss = SessionStore; // Some tests here assume that all restored tabs are loaded without waiting for // the user to bring them to the foreground. We ensure this by resetting the diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 94cf492b58fe..edbed18aa4bb 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -246,9 +246,8 @@ @RESPATH@/components/ProcessSingleton.manifest @RESPATH@/components/MainProcessSingleton.js @RESPATH@/components/ContentProcessSingleton.js -@RESPATH@/browser/components/nsSessionStore.manifest +@RESPATH@/browser/components/nsSessionStartup.manifest @RESPATH@/browser/components/nsSessionStartup.js -@RESPATH@/browser/components/nsSessionStore.js @RESPATH@/components/nsURLFormatter.manifest @RESPATH@/components/nsURLFormatter.js @RESPATH@/components/txEXSLTRegExFunctions.manifest diff --git a/browser/modules/AboutHome.jsm b/browser/modules/AboutHome.jsm index 589155907e07..6bd5e5dc319c 100644 --- a/browser/modules/AboutHome.jsm +++ b/browser/modules/AboutHome.jsm @@ -17,6 +17,8 @@ ChromeUtils.defineModuleGetter(this, "fxAccounts", "resource://gre/modules/FxAccounts.jsm"); ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); +ChromeUtils.defineModuleGetter(this, "SessionStore", + "resource:///modules/sessionstore/SessionStore.jsm"); // Url to fetch snippets, in the urlFormatter service format. const SNIPPETS_URL_PREF = "browser.aboutHomeSnippets.updateUrl"; @@ -108,10 +110,8 @@ var AboutHome = { switch (aMessage.name) { case "AboutHome:RestorePreviousSession": - let ss = Cc["@mozilla.org/browser/sessionstore;1"]. - getService(Ci.nsISessionStore); - if (ss.canRestoreLastSession) { - ss.restoreLastSession(); + if (SessionStore.canRestoreLastSession) { + SessionStore.restoreLastSession(); } break; @@ -156,14 +156,9 @@ var AboutHome = { // Send all the chrome-privileged data needed by about:home. This // gets re-sent when the search engine changes. sendAboutHomeData(target) { - let wrapper = {}; - ChromeUtils.import("resource:///modules/sessionstore/SessionStore.jsm", - wrapper); - let ss = wrapper.SessionStore; - - ss.promiseInitialized.then(function() { + SessionStore.promiseInitialized.then(function() { let data = { - showRestoreLastSession: ss.canRestoreLastSession, + showRestoreLastSession: SessionStore.canRestoreLastSession, snippetsURL: AboutHomeUtils.snippetsURL, showKnowYourRights: AboutHomeUtils.showKnowYourRights, snippetsVersion: AboutHomeUtils.snippetsVersion, diff --git a/devtools/client/responsive.html/test/browser/browser_hide_container.js b/devtools/client/responsive.html/test/browser/browser_hide_container.js index d991b91a05be..3aa65382f658 100644 --- a/devtools/client/responsive.html/test/browser/browser_hide_container.js +++ b/devtools/client/responsive.html/test/browser/browser_hide_container.js @@ -10,8 +10,6 @@ const CONTAINER_URL = "chrome://devtools/content/responsive.html/index.xhtml"; const { TabStateFlusher } = ChromeUtils.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); -const SessionStore = - Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); const { OUTER_FRAME_LOADER_SYMBOL } = require("devtools/client/responsive.html/browser/tunnel"); diff --git a/devtools/client/scratchpad/test/browser_scratchpad_sessions.js b/devtools/client/scratchpad/test/browser_scratchpad_sessions.js index 4a732b0279c2..cc31e6a23102 100644 --- a/devtools/client/scratchpad/test/browser_scratchpad_sessions.js +++ b/devtools/client/scratchpad/test/browser_scratchpad_sessions.js @@ -4,7 +4,6 @@ const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm", {}); const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL; -const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); const testState = { windows: [{ @@ -37,7 +36,7 @@ function test() { Services.ww.registerNotification(windowObserver); - ss.setBrowserState(JSON.stringify(testState)); + SessionStore.setBrowserState(JSON.stringify(testState)); } function windowObserver(subject, topic, data) {