Commit bff8e0ac authored by Mike Conley's avatar Mike Conley
Browse files

Bug 1533955 - Show some UI to indicate that a subframe has crashed. r=NeilDeakin

Differential Revision: https://phabricator.services.mozilla.com/D29238

--HG--
extra : moz-landing-system : lando
parent b64aa8e8
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* 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";
var EXPORTED_SYMBOLS = ["SubframeCrashChild"];
let {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
class SubframeCrashChild extends JSWindowActorChild {
receiveMessage(message) {
if (message.name == "SubframeCrashed") {
this.onSubframeCrashed(message.data.id);
}
}
onSubframeCrashed(browsingContextId) {
let bc = BrowsingContext.get(browsingContextId);
let iframe = bc.embedderElement;
let uri = Services.io.newURI(iframe.src);
iframe.removeAttribute("fission");
iframe.removeAttribute("src");
// Passing a null remoteType is currently how we tell the iframe to run
// in the same process as the embedder.
iframe.changeRemoteness({ remoteType: null });
let docShell = iframe.frameLoader.docShell;
docShell.displayLoadError(Cr.NS_ERROR_FRAME_CRASHED, uri, null);
}
}
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* 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";
var EXPORTED_SYMBOLS = ["SubframeCrashParent"];
class SubframeCrashParent extends JSWindowActorParent {
}
......@@ -40,6 +40,8 @@ FINAL_TARGET_FILES.actors += [
'PluginChild.jsm',
'RFPHelperChild.jsm',
'SearchTelemetryChild.jsm',
'SubframeCrashChild.jsm',
'SubframeCrashParent.jsm',
'URIFixupChild.jsm',
'WebRTCChild.jsm',
]
<!DOCTYPE html>
<!-- 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/. -->
<html>
<head>
<link rel="stylesheet" type="text/css" media="all"
href="chrome://global/skin/in-content/info-pages.css"/>
<link rel="stylesheet" type="text/css" media="all"
href="chrome://browser/skin/aboutFrameCrashed.css"/>
</head>
<body>
</body>
</html>
......@@ -61,6 +61,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
SimpleServiceDiscovery: "resource://gre/modules/SimpleServiceDiscovery.jsm",
SiteDataManager: "resource:///modules/SiteDataManager.jsm",
SitePermissions: "resource:///modules/SitePermissions.jsm",
SubframeCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
TabModalPrompt: "chrome://global/content/tabprompts.jsm",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
......
......@@ -4627,8 +4627,15 @@ window._gBrowser = {
});
this.addEventListener("oop-browser-crashed", (event) => {
if (!event.isTrusted)
if (!event.isTrusted) {
return;
}
if (!event.isTopFrame) {
let bc = BrowsingContext.get(event.browsingContextId);
SubframeCrashHandler.onSubframeCrash(bc);
return;
}
let browser = event.originalTarget;
......
......@@ -22,6 +22,7 @@ browser.jar:
content/browser/aboutNetError.xhtml (content/aboutNetError.xhtml)
content/browser/aboutNetError.js (content/aboutNetError.js)
content/browser/aboutRobots-icon.png (content/aboutRobots-icon.png)
content/browser/aboutFrameCrashed.html (content/aboutFrameCrashed.html)
content/browser/aboutTabCrashed.css (content/aboutTabCrashed.css)
content/browser/aboutTabCrashed.js (content/aboutTabCrashed.js)
content/browser/aboutTabCrashed.xhtml (content/aboutTabCrashed.xhtml)
......
......@@ -16,6 +16,17 @@ ChromeUtils.defineModuleGetter(this, "ActorManagerParent",
const PREF_PDFJS_ENABLED_CACHE_STATE = "pdfjs.enabledCache.state";
let ACTORS = {
SubframeCrash: {
parent: {
moduleURI: "resource:///actors/SubframeCrashParent.jsm",
},
child: {
moduleURI: "resource:///actors/SubframeCrashChild.jsm",
},
allFrames: true,
},
};
let LEGACY_ACTORS = {
......
......@@ -53,6 +53,9 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
{"config", "chrome://browser/content/aboutconfig/aboutconfig.html", 0},
{"framecrashed", "chrome://browser/content/aboutFrameCrashed.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
{"tabcrashed", "chrome://browser/content/aboutTabCrashed.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT},
......
......@@ -8,6 +8,7 @@ pages = [
'blocked',
'certerror',
'downloads',
'framecrashed',
'home',
'library',
'newinstall',
......
......@@ -1044,7 +1044,9 @@ var SessionStoreInternal = {
this.saveStateDelayed(win);
break;
case "oop-browser-crashed":
this.onBrowserCrashed(target);
if (aEvent.isTopFrame) {
this.onBrowserCrashed(target);
}
break;
case "XULFrameLoaderCreated":
if (target.namespaceURI == NS_XUL &&
......
......@@ -4,8 +4,9 @@
"use strict";
var EXPORTED_SYMBOLS = [ "TabCrashHandler",
"PluginCrashReporter",
var EXPORTED_SYMBOLS = [ "PluginCrashReporter",
"SubframeCrashHandler",
"TabCrashHandler",
"UnsubmittedCrashHandler" ];
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
......@@ -585,6 +586,16 @@ var TabCrashHandler = {
},
};
var SubframeCrashHandler = {
onSubframeCrash(browsingContext) {
// A subframe has crashed. We have to inform the parent frame so that it
// can show suitable UI.
let parentWg = browsingContext.parent.currentWindowGlobal;
let actor = parentWg.getActor("SubframeCrash");
actor.sendAsyncMessage("SubframeCrashed", { id: browsingContext.id });
},
};
/**
* This component is responsible for scanning the pending
* crash report directory for reports, and (if enabled), to
......
body {
background-image: url("chrome://browser/skin/tab-crashed.svg");
background-position: center, center;
background-repeat: no-repeat;
height: 100%;
width: 100%;
background-size: 1.6em;
}
......@@ -13,6 +13,7 @@
skin/classic/browser/aboutRestartRequired.css (../shared/aboutRestartRequired.css)
* skin/classic/browser/aboutSessionRestore.css (../shared/aboutSessionRestore.css)
skin/classic/browser/aboutLibrary.css (../shared/aboutLibrary.css)
skin/classic/browser/aboutFrameCrashed.css (../shared/aboutFrameCrashed.css)
skin/classic/browser/aboutTabCrashed.css (../shared/aboutTabCrashed.css)
skin/classic/browser/aboutWelcomeBack.css (../shared/aboutWelcomeBack.css)
skin/classic/browser/setDesktopBackground.css (../shared/setDesktopBackground.css)
......
......@@ -4255,6 +4255,10 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
if (messageStr.IsEmpty()) {
messageStr.AssignLiteral(u" ");
}
} else if (NS_ERROR_FRAME_CRASHED == aError) {
errorPage.AssignLiteral("framecrashed");
error = "framecrashed";
messageStr.AssignLiteral(u" ");
} else if (NS_ERROR_BUILDID_MISMATCH == aError) {
errorPage.AssignLiteral("restartrequired");
error = "restartrequired";
......
......@@ -221,6 +221,7 @@ XPC_MSG_DEF(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY , "Cannot print this docum
/* Codes related to content */
XPC_MSG_DEF(NS_ERROR_CONTENT_CRASHED , "The process that hosted this content has crashed.")
XPC_MSG_DEF(NS_ERROR_FRAME_CRASHED , "The process that hosted this frame has crashed.")
XPC_MSG_DEF(NS_ERROR_BUILDID_MISMATCH , "The process that hosted this content did not have the same buildID as the parent.")
/* Codes for the JS-implemented Push DOM API. These can be removed as part of bug 1252660. */
......
......@@ -288,7 +288,12 @@ const BackgroundPageThumbs = {
// an event that is sent if the remote process crashes - no need to remove
// it as we want it to be there as long as the browser itself lives.
browser.addEventListener("oop-browser-crashed", () => {
browser.addEventListener("oop-browser-crashed", event => {
if (!event.isTopFrame) {
// It was a subframe that crashed. We'll ignore this.
return;
}
Cu.reportError("BackgroundThumbnails remote process crashed - recovering");
this._destroyBrowser();
let curCapture = this._captureQueue.length ? this._captureQueue[0] : null;
......
......@@ -846,6 +846,8 @@ with modules["CONTENT"]:
errors["NS_ERROR_XBL_BLOCKED"] = FAILURE(15)
# Error code for when the content process crashed
errors["NS_ERROR_CONTENT_CRASHED"] = FAILURE(16)
# Error code for when a subframe process crashed
errors["NS_ERROR_FRAME_CRASHED"] = FAILURE(14)
# Error code for when the content process had a different buildID than the
# parent
errors["NS_ERROR_BUILDID_MISMATCH"] = FAILURE(17)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment