1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 ChromeUtils.defineESModuleGetters(lazy, {
8 SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
9 TabCrashHandler: "resource:///modules/ContentCrashHandlers.sys.mjs",
12 // A list of all of the open about:tabcrashed pages.
13 let gAboutTabCrashedPages = new Map();
15 export class AboutTabCrashedParent extends JSWindowActorParent {
17 this.removeCrashedPage();
20 async receiveMessage(message) {
21 let browser = this.browsingContext.top.embedderElement;
23 // If there is no browser, remove the crashed page from the set
25 this.removeCrashedPage();
29 let gBrowser = browser.getTabBrowser();
30 let tab = gBrowser.getTabForBrowser(browser);
32 switch (message.name) {
34 gAboutTabCrashedPages.set(this, browser);
35 this.updateTabCrashedCount();
37 let report = lazy.TabCrashHandler.onAboutTabCrashedLoad(browser);
38 this.sendAsyncMessage("SetCrashReportAvailable", report);
43 lazy.TabCrashHandler.maybeSendCrashReport(browser, message);
44 gBrowser.removeTab(tab, { animate: true });
49 lazy.TabCrashHandler.maybeSendCrashReport(browser, message);
50 lazy.SessionStore.reviveCrashedTab(tab);
55 lazy.TabCrashHandler.maybeSendCrashReport(browser, message);
56 lazy.SessionStore.reviveAllCrashedTabs();
64 this.browsingContext.top.embedderElement ||
65 gAboutTabCrashedPages.get(this);
67 gAboutTabCrashedPages.delete(this);
68 this.updateTabCrashedCount();
70 lazy.TabCrashHandler.onAboutTabCrashedUnload(browser);
73 updateTabCrashedCount() {
74 // Broadcast to all about:tabcrashed pages a count of
75 // how many about:tabcrashed pages exist, so that they
76 // can decide whether or not to display the "Restore All
77 // Crashed Tabs" button.
78 let count = gAboutTabCrashedPages.size;
80 for (let actor of gAboutTabCrashedPages.keys()) {
81 let browser = actor.browsingContext.top.embedderElement;
83 browser.sendMessageToActor("UpdateCount", { count }, "AboutTabCrashed");