Backed out changeset 066920d21e0e (bug 964349) for breaking browser-chrome tests

This commit is contained in:
Wes Kocher 2014-01-30 17:35:36 -08:00
parent f8217aebfa
commit 54215027c1
2 changed files with 51 additions and 16 deletions

View File

@ -213,6 +213,12 @@ XPCOMUtils.defineLazyGetter(this, "Win7Features", function () {
return null;
});
#ifdef MOZ_CRASHREPORTER
XPCOMUtils.defineLazyServiceGetter(this, "gCrashReporter",
"@mozilla.org/xre/app-info;1",
"nsICrashReporter");
#endif
XPCOMUtils.defineLazyGetter(this, "PageMenu", function() {
let tmp = {};
Cu.import("resource://gre/modules/PageMenu.jsm", tmp);
@ -3727,22 +3733,6 @@ var XULBrowserWindow = {
setTimeout(function () { XULBrowserWindow.asyncUpdateUI(); }, 0);
else
this.asyncUpdateUI();
#ifdef MOZ_CRASHREPORTER
if (aLocationURI) {
let uri = aLocationURI.clone();
try {
// If the current URI contains a username/password, remove it.
uri.userPass = "";
} catch (ex) { /* Ignore failures on about: URIs. */ }
try {
Services.appinfo.annotateCrashReport("URL", uri.spec);
} catch (ex if ex.result == Components.results.NS_ERROR_NOT_INITIALIZED) {
// Don't make noise when the crash reporter is built but not enabled.
}
}
#endif
},
asyncUpdateUI: function () {
@ -4002,6 +3992,15 @@ var CombinedStopReload = {
var TabsProgressListener = {
onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
#ifdef MOZ_CRASHREPORTER
if (aRequest instanceof Ci.nsIChannel &&
aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_DOCUMENT &&
gCrashReporter.enabled) {
gCrashReporter.annotateCrashReport("URL", aRequest.URI.spec);
}
#endif
// Collect telemetry data about tab load times.
if (aWebProgress.isTopLevel) {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {

View File

@ -131,6 +131,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "TabStateCache",
XPCOMUtils.defineLazyModuleGetter(this, "Utils",
"resource:///modules/sessionstore/Utils.jsm");
#ifdef MOZ_CRASHREPORTER
XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
"@mozilla.org/xre/app-info;1", "nsICrashReporter");
#endif
/**
* |true| if we are in debug mode, |false| otherwise.
* Debug mode is controlled by preference browser.sessionstore.debug
@ -1295,6 +1300,8 @@ let SessionStoreInternal = {
if (!aNoNotification) {
this.saveStateDelayed(aWindow);
}
this._updateCrashReportURL(aWindow);
},
/**
@ -1396,6 +1403,9 @@ let SessionStoreInternal = {
delete aBrowser.__SS_data;
this.saveStateDelayed(aWindow);
// attempt to update the current URL we send in a crash report
this._updateCrashReportURL(aWindow);
},
/**
@ -1414,6 +1424,9 @@ let SessionStoreInternal = {
if (tab.linkedBrowser.__SS_restoreState &&
tab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
this.restoreTabContent(tab);
// attempt to update the current URL we send in a crash report
this._updateCrashReportURL(aWindow);
}
},
@ -3053,6 +3066,29 @@ let SessionStoreInternal = {
return Services.io.newURI(aString, null, null);
},
/**
* Annotate a breakpad crash report with the currently selected tab's URL.
*/
_updateCrashReportURL: function ssi_updateCrashReportURL(aWindow) {
#ifdef MOZ_CRASHREPORTER
try {
var currentURI = aWindow.gBrowser.currentURI.clone();
// if the current URI contains a username/password, remove it
try {
currentURI.userPass = "";
}
catch (ex) { } // ignore failures on about: URIs
CrashReporter.annotateCrashReport("URL", currentURI.spec);
}
catch (ex) {
// don't make noise when crashreporter is built but not enabled
if (ex.result != Components.results.NS_ERROR_NOT_INITIALIZED)
debug(ex);
}
#endif
},
/**
* @param aState is a session state
* @param aRecentCrashes is the number of consecutive crashes