зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1585217 - Make the layout debugger with -autoclose handle content process crashes. r=heycam
This means that you can use it as a very light-weight crashtest harness by using: MOZ_GDB_SLEEP=0 ./mach run -layoutdebug <file> -autoclose Right now we just never exit otherwise. Differential Revision: https://phabricator.services.mozilla.com/D47715 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fe80db04c7
Коммит
caccd3a1d9
|
@ -141,6 +141,32 @@ for (let name of COMMANDS) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
|
||||||
|
function autoCloseIfNeeded(aCrash) {
|
||||||
|
if (!gArgs.autoclose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTimeout(function() {
|
||||||
|
if (aCrash) {
|
||||||
|
let browser = document.createElementNS(XUL_NS, "browser");
|
||||||
|
// FIXME(emilio): we could use gBrowser if we bothered get the process switches right.
|
||||||
|
//
|
||||||
|
// Doesn't seem worth for this particular case.
|
||||||
|
document.documentElement.appendChild(browser);
|
||||||
|
browser.loadURI("about:crashparent", {
|
||||||
|
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (gArgs.profile && Services.profiler) {
|
||||||
|
dumpProfile();
|
||||||
|
} else {
|
||||||
|
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
||||||
|
}
|
||||||
|
}, gArgs.delay * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
function nsLDBBrowserContentListener() {
|
function nsLDBBrowserContentListener() {
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
@ -174,19 +200,14 @@ nsLDBBrowserContentListener.prototype = {
|
||||||
this.setButtonEnabled(this.mStopButton, false);
|
this.setButtonEnabled(this.mStopButton, false);
|
||||||
this.mStatusText.value = gURLBar.value + " loaded";
|
this.mStatusText.value = gURLBar.value + " loaded";
|
||||||
this.mLoading = false;
|
this.mLoading = false;
|
||||||
if (gArgs.autoclose && gBrowser.currentURI.spec != "about:blank") {
|
|
||||||
|
if (gBrowser.currentURI.spec != "about:blank") {
|
||||||
// We check for about:blank just to avoid one or two STATE_STOP
|
// We check for about:blank just to avoid one or two STATE_STOP
|
||||||
// notifications that occur before the loadURI() call completes.
|
// notifications that occur before the loadURI() call completes.
|
||||||
// This does mean that --autoclose doesn't work when the URL on
|
// This does mean that --autoclose doesn't work when the URL on
|
||||||
// the command line is about:blank (or not specified), but that's
|
// the command line is about:blank (or not specified), but that's
|
||||||
// not a big deal.
|
// not a big deal.
|
||||||
setTimeout(function() {
|
autoCloseIfNeeded(false);
|
||||||
if (gArgs.profile && Services.profiler) {
|
|
||||||
dumpProfile();
|
|
||||||
} else {
|
|
||||||
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
|
||||||
}
|
|
||||||
}, gArgs.delay * 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -255,6 +276,23 @@ function parseArguments() {
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TabCrashedObserver = {
|
||||||
|
observe(subject, topic, data) {
|
||||||
|
switch (topic) {
|
||||||
|
case "ipc:content-shutdown":
|
||||||
|
subject.QueryInterface(Ci.nsIPropertyBag2);
|
||||||
|
if (!subject.get("abnormal")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "oop-frameloader-crashed":
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
autoCloseIfNeeded(true);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
function OnLDBLoad() {
|
function OnLDBLoad() {
|
||||||
gBrowser = document.getElementById("browser");
|
gBrowser = document.getElementById("browser");
|
||||||
gURLBar = document.getElementById("urlbar");
|
gURLBar = document.getElementById("urlbar");
|
||||||
|
@ -263,6 +301,9 @@ function OnLDBLoad() {
|
||||||
|
|
||||||
checkPersistentMenus();
|
checkPersistentMenus();
|
||||||
|
|
||||||
|
Services.obs.addObserver(TabCrashedObserver, "ipc:content-shutdown");
|
||||||
|
Services.obs.addObserver(TabCrashedObserver, "oop-frameloader-crashed");
|
||||||
|
|
||||||
// Pretend slightly to be like a normal browser, so that SessionStore.jsm
|
// Pretend slightly to be like a normal browser, so that SessionStore.jsm
|
||||||
// doesn't get too confused. The effect is that we'll never switch process
|
// doesn't get too confused. The effect is that we'll never switch process
|
||||||
// type when navigating, and for layout debugging purposes we don't bother
|
// type when navigating, and for layout debugging purposes we don't bother
|
||||||
|
@ -362,6 +403,8 @@ function OnLDBBeforeUnload(event) {
|
||||||
|
|
||||||
function OnLDBUnload() {
|
function OnLDBUnload() {
|
||||||
gDebugger.detachBrowser();
|
gDebugger.detachBrowser();
|
||||||
|
Services.obs.removeObserver(TabCrashedObserver, "ipc:content-shutdown");
|
||||||
|
Services.obs.removeObserver(TabCrashedObserver, "oop-frameloader-crashed");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle(menuitem) {
|
function toggle(menuitem) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче