Bug 1263042 - When the crash reporter is disabled, avoid JavaScript strict warnings in Telemetry code during startup. r=gfritzsche

This commit is contained in:
Jonathan Watt 2016-03-23 10:24:41 +00:00
Родитель 4b7a85789e
Коммит 6b407c6579
2 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -224,9 +224,10 @@ function toLocalTimeISOString(date) {
*/
function annotateCrashReport(sessionId) {
try {
const cr = Cc["@mozilla.org/toolkit/crash-reporter;1"]
.getService(Ci.nsICrashReporter);
cr.setTelemetrySessionId(sessionId);
const cr = Cc["@mozilla.org/toolkit/crash-reporter;1"];
if (cr) {
cr.getService(Ci.nsICrashReporter).setTelemetrySessionId(sessionId);
}
} catch (e) {
// Ignore errors when crash reporting is disabled
}

Просмотреть файл

@ -39,10 +39,11 @@ TelemetryStartup.prototype.observe = function(aSubject, aTopic, aData) {
function annotateEnvironment() {
try {
let cr = Cc["@mozilla.org/toolkit/crash-reporter;1"]
.getService(Ci.nsICrashReporter);
let env = JSON.stringify(TelemetryEnvironment.currentEnvironment);
cr.annotateCrashReport("TelemetryEnvironment", env);
let cr = Cc["@mozilla.org/toolkit/crash-reporter;1"];
if (cr) {
let env = JSON.stringify(TelemetryEnvironment.currentEnvironment);
cr.getService(Ci.nsICrashReporter).annotateCrashReport("TelemetryEnvironment", env);
}
} catch (e) {
// crash reporting not built or disabled? Ignore errors
}