Bug 1258792 - ensure window before trying to use it in update check; r=marco, a=ritu
authorMyk Melez <myk@mykzilla.org>
Thu, 24 Mar 2016 14:24:47 -0700
changeset 351354 a4481ccef67e4732e005b3538df8d8e61890bcdc
parent 351353 7fad9b1e32fd631e7df6486d580d82120eef4eb2
child 351355 49207e06538f84689dc6ff388621b9f754c2ca91
push id15502
push userahunt@mozilla.com
push dateThu, 14 Apr 2016 20:27:48 +0000
reviewersmarco, ritu
bugs1258792
milestone47.0a2
Bug 1258792 - ensure window before trying to use it in update check; r=marco, a=ritu
webapprt/WebappRT.jsm
--- a/webapprt/WebappRT.jsm
+++ b/webapprt/WebappRT.jsm
@@ -97,25 +97,24 @@ this.WebappRT = {
   startUpdateService: function() {
     let manifestURL = this.config.app.manifestURL;
     // We used to install apps without storing their manifest URL.
     // Now we can't update them.
     if (!manifestURL) {
       return;
     }
 
-    if (!window.navigator.mozApps) {
-      return;
-    }
-
     // Check for updates once a day.
     let timerManager = Cc["@mozilla.org/updates/timer-manager;1"].
                        getService(Ci.nsIUpdateTimerManager);
     timerManager.registerTimer("updateTimer", () => {
       let window = Services.wm.getMostRecentWindow("webapprt:webapp");
+      if (!window.navigator.mozApps) {
+        return;
+      }
       window.navigator.mozApps.mgmt.getAll().onsuccess = function() {
         let thisApp = null;
         for (let app of this.result) {
           if (app.manifestURL == manifestURL) {
             thisApp = app;
             break;
           }
         }