diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index d114ae9a4b5a..31fe9359431a 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2576,8 +2576,8 @@ let BrowserOnClick = { TabCrashReporter.submitCrashReport(browser); } #endif - - TabCrashReporter.reloadCrashedTab(browser); + let tab = gBrowser.getTabForBrowser(browser); + SessionStore.reviveCrashedTab(tab); } }, diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 83f343520dc0..18bf3ab89b62 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -276,6 +276,10 @@ this.SessionStore = { return SessionStoreInternal.getCurrentState(aUpdateAll); }, + reviveCrashedTab(aTab) { + return SessionStoreInternal.reviveCrashedTab(aTab); + }, + /** * Backstage pass to implementation details, used for testing purpose. * Controlled by preference "browser.sessionstore.testmode". @@ -1948,6 +1952,35 @@ let SessionStoreInternal = { LastSession.clear(); }, + /** + * Revive a crashed tab and restore its state from before it crashed. + * + * @param aTab + * A linked to a crashed browser. This is a no-op if the + * browser hasn't actually crashed, or is not associated with a tab. + * This function will also throw if the browser happens to be remote. + */ + reviveCrashedTab(aTab) { + if (!aTab) { + throw new Error("SessionStore.reviveCrashedTab expected a tab, but got null."); + } + + let browser = aTab.linkedBrowser; + if (!this._crashedBrowsers.has(browser.permanentKey)) { + return; + } + + // Sanity check - the browser to be revived should not be remote + // at this point. + if (browser.isRemoteBrowser) { + throw new Error("SessionStore.reviveCrashedTab: " + + "Somehow a crashed browser is still remote.") + } + + let data = TabState.collect(aTab); + this.restoreTab(aTab, data); + }, + /** * See if aWindow is usable for use when restoring a previous session via * restoreLastSession. If usable, prepare it for use. diff --git a/browser/modules/TabCrashReporter.jsm b/browser/modules/TabCrashReporter.jsm index 68088208e29e..677688c1465e 100644 --- a/browser/modules/TabCrashReporter.jsm +++ b/browser/modules/TabCrashReporter.jsm @@ -87,18 +87,6 @@ this.TabCrashReporter = { } }, - reloadCrashedTab: function (browser) { - if (browser.isRemoteBrowser) - return; - - let doc = browser.contentDocument; - if (!doc.documentURI.startsWith("about:tabcrashed")) - return; - - let url = browser.currentURI.spec; - browser.loadURIWithFlags(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); - }, - onAboutTabCrashedLoad: function (aBrowser) { if (!this.childMap) return;