Bug 1263042 - When the crash reporter is disabled, avoid JavaScript strict warnings in Telemetry code during startup. r=gfritzsche
authorJonathan Watt <jwatt@jwatt.org>
Wed, 23 Mar 2016 10:24:41 +0000
changeset 292436 6f741bd80adc7348ee92b7cbdb36a0f4d32688e3
parent 292435 3c2c25159286ed063140f407ef84e68accf3ef5a
child 292437 7d2985286d633565ec798ea590f52a89fc2bd456
push id18623
push userryanvm@gmail.com
push dateSun, 10 Apr 2016 20:21:27 +0000
treeherderfx-team@29d5a4175c8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1263042
milestone48.0a1
Bug 1263042 - When the crash reporter is disabled, avoid JavaScript strict warnings in Telemetry code during startup. r=gfritzsche
toolkit/components/telemetry/TelemetrySession.jsm
toolkit/components/telemetry/TelemetryStartup.js
--- a/toolkit/components/telemetry/TelemetrySession.jsm
+++ b/toolkit/components/telemetry/TelemetrySession.jsm
@@ -219,19 +219,20 @@ function toLocalTimeISOString(date) {
 }
 
 /**
  * Annotate the current session ID with the crash reporter to map potential
  * crash pings with the related main ping.
  */
 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
   }
 }
 
 /**
  * Read current process I/O counters.
  */
--- a/toolkit/components/telemetry/TelemetryStartup.js
+++ b/toolkit/components/telemetry/TelemetryStartup.js
@@ -34,18 +34,19 @@ TelemetryStartup.prototype.observe = fun
     annotateEnvironment();
     TelemetryEnvironment.registerChangeListener("CrashAnnotator", annotateEnvironment);
     TelemetryEnvironment.onInitialized().then(() => annotateEnvironment());
   }
 }
 
 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
   }
 }
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelemetryStartup]);