[Pkg-mozext-commits] [requestpolicy] 244/257: [fix] setup page: crash when installing at application startup

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:20:18 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 12a93f90d7be9172405ccc5e0cacf0535b3ec387
Author: Martin Kimmerle <dev at 256k.de>
Date:   Fri Dec 25 19:59:19 2015 +0100

    [fix] setup page: crash when installing at application startup
    
    Fix #695
---
 src/content/main/requestpolicy-service.jsm | 46 ++++++++++++++++--------------
 src/content/settings/setup.js              | 10 +++----
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index 00b37ac..2b1dcc6 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -96,13 +96,15 @@ var rpService = (function() {
   }
 
   // TODO: move to window manager
-  function showWelcomeWindow() {
+  function maybeShowSetupTab() {
     if (!Prefs.get("welcomeWindowShown")) {
       var url = "about:requestpolicy?setup";
 
       let win = WindowUtils.getMostRecentBrowserWindow();
+      if (win === null) {
+        return;
+      }
       let tabbrowser = win.getBrowser();
-
       if (typeof tabbrowser.addTab !== "function") {
         return;
       }
@@ -174,18 +176,16 @@ var rpService = (function() {
      * @return {Boolean} whether opening the tab was successful
      */
     function openTab() {
-      var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
-          .getService(Ci.nsIWindowMediator);
-      var mostRecentWindow = wm.getMostRecentWindow("navigator:browser");
-
-      // the gBrowser object of the firefox window
-      var _gBrowser = mostRecentWindow.getBrowser();
-
-      if (typeof _gBrowser.addTab !== "function") {
-        return false;
+      let win = WindowUtils.getMostRecentBrowserWindow();
+      if (win === null) {
+        return;
+      }
+      let tabbrowser = win.getBrowser();
+      if (typeof tabbrowser.addTab !== "function") {
+        return;
       }
 
-      _gBrowser.selectedTab = _gBrowser.addTab(NOTICE_URL);
+      tabbrowser.selectedTab = tabbrowser.addTab(NOTICE_URL);
 
       return true;
     }
@@ -223,7 +223,7 @@ var rpService = (function() {
      * Check if other RequestPolicy versions (with other extension IDs)
      * are installed. If so, a tab with a notice will be opened.
      */
-    function checkForOtherInstallations() {
+    function maybeShowMultipleInstallationsWarning() {
       if (initialCheckDone === true) {
         return;
       }
@@ -231,7 +231,10 @@ var rpService = (function() {
       AddonManager.getAddonsByIDs(addonIDs, addonListCallback);
     }
 
-    return {checkForOtherInstallations: checkForOtherInstallations};
+    return {
+      maybeShowMultipleInstallationsWarning:
+          maybeShowMultipleInstallationsWarning
+    };
   }());
 
   //----------------------------------------------------------------------------
@@ -261,12 +264,11 @@ var rpService = (function() {
   ProcessEnvironment.addStartupFunction(
       Environment.LEVELS.UI,
       function(data, reason) {
-        if (reason !== C.APP_STARTUP) {
-          // In case of the app's startup, the following functions will be
-          // called when "sessionstore-windows-restored" is observed.
-          showWelcomeWindow();
-          DetectorForOtherInstallations.checkForOtherInstallations();
-        }
+        // In case of the app's startup and if they fail now, they
+        // will be successful when they are called by the
+        // "sessionstore-windows-restored" observer.
+        maybeShowSetupTab();
+        DetectorForOtherInstallations.maybeShowMultipleInstallationsWarning();
       });
 
   self.getSubscriptions = function() {
@@ -321,8 +323,8 @@ var rpService = (function() {
       }
 
       case "sessionstore-windows-restored":
-        showWelcomeWindow();
-        DetectorForOtherInstallations.checkForOtherInstallations();
+        maybeShowSetupTab();
+        DetectorForOtherInstallations.maybeShowMultipleInstallationsWarning();
         break;
 
       // support for old browsers (Firefox <20)
diff --git a/src/content/settings/setup.js b/src/content/settings/setup.js
index b4894e7..1c12ac5 100644
--- a/src/content/settings/setup.js
+++ b/src/content/settings/setup.js
@@ -97,13 +97,13 @@
 
   /*
   function getArguments(args) {
-    let urlQuery = document.location.search || "";
+    var urlQuery = document.location.search || "";
     if (urlQuery.length > 1) {
       urlQuery = decodeURIComponent(urlQuery.substr(1));
     }
-    let queryArgs = split("&");
-    for (let i in queryArgs) {
-      let tmp = queryArgs.split("=");
+    var queryArgs = split("&");
+    for (var i in queryArgs) {
+      var tmp = queryArgs.split("=");
       if (args.hasOwnProperty(tmp)) {
         args[tmp[0]] = tmp[1];
       }
@@ -119,7 +119,7 @@
 
     // Populate the form values based on the user's current settings.
 
-    let defaultAllow = Prefs.get("defaultPolicy.allow");
+    var defaultAllow = Prefs.get("defaultPolicy.allow");
     $id("defaultallow").checked = defaultAllow;
     $id("defaultdeny").checked = !defaultAllow;
     if (!defaultAllow) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list