Bug 1331873 - Null-check tab in TelemetryReportingPolicyImpl._openFirstRunPage's progress listener since it can be called synchronously before we have a reference to the tab. r=Gijs
authorDão Gottwald <dao@mozilla.com>
Wed, 18 Jan 2017 11:11:05 +0100
changeset 377172 ef886fa0b8f18cc7c8c3c7a3f4ff74f86075cc0a
parent 377171 b84c8830194f9ebca8753e4761dc62c55773fb3c
child 377173 76452d510db7a4c041e0e6c3a6eb1ca4b67e3f76
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1331873
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1331873 - Null-check tab in TelemetryReportingPolicyImpl._openFirstRunPage's progress listener since it can be called synchronously before we have a reference to the tab. r=Gijs MozReview-Commit-ID: Gcktb3x7o4W
toolkit/components/telemetry/TelemetryReportingPolicy.jsm
--- a/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
+++ b/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
@@ -428,21 +428,23 @@ var TelemetryReportingPolicyImpl = {
 
     if (!win) {
       this._log.info("Couldn't find browser window to open first-run page. Falling back to infobar.");
       return false;
     }
 
     // We'll consider the user notified once the privacy policy has been loaded
     // in a background tab even if that tab hasn't been selected.
+    let tab;
     let progressListener = {};
     progressListener.onStateChange =
       (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) => {
         if (aWebProgress.isTopLevel &&
-            aBrowser == tab.linkedBrowser &&
+            tab &&
+            tab.linkedBrowser == aBrowser &&
             aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
             aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
           let uri = aBrowser.documentURI;
           if (uri && !/^about:(blank|neterror|certerror|blocked)/.test(uri.spec)) {
             this._userNotified();
           } else {
             this._log.info("Failed to load first-run page. Falling back to infobar.");
             this._showInfobar();
@@ -454,17 +456,17 @@ var TelemetryReportingPolicyImpl = {
     let removeListeners = () => {
       win.removeEventListener("unload", removeListeners);
       win.gBrowser.removeTabsProgressListener(progressListener);
     };
 
     win.addEventListener("unload", removeListeners);
     win.gBrowser.addTabsProgressListener(progressListener);
 
-    let tab = win.gBrowser.loadOneTab(firstRunPolicyURL, { inBackground: true });
+    tab = win.gBrowser.loadOneTab(firstRunPolicyURL, { inBackground: true });
 
     return true;
   },
 
   observe(aSubject, aTopic, aData) {
     if (aTopic != "sessionstore-windows-restored") {
       return;
     }