Bug 723984 PageInfo->Permissions: Don't assume that the whitelist pref is there. It defaults to true in the new add-ons manager code. Don't assume all consumers use testPermission r=Neil.
authorPhilip Chee <philip.chee@gmail.com>
Sun, 05 Feb 2012 00:15:11 +0800
changeset 10776 765a0a88867acc3380a2b6a7bac5d92e27130cbb
parent 10775 8fcccaa67d82bd78aa412373a30a51396dfc13f3
child 10777 223a7cd94a09740fe28c9aeb749bd0b026d1552c
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs723984
Bug 723984 PageInfo->Permissions: Don't assume that the whitelist pref is there. It defaults to true in the new add-ons manager code. Don't assume all consumers use testPermission r=Neil.
suite/browser/pageinfo/permissions.js
suite/browser/test/browser/browser_feed_tab.js
--- a/suite/browser/pageinfo/permissions.js
+++ b/suite/browser/pageinfo/permissions.js
@@ -59,19 +59,23 @@ var gPermObj = {
   popup: function getPopupDefaultPermission()
   {
     if (Services.prefs.getBoolPref("dom.disable_open_during_load"))
       return BLOCK;
     return ALLOW;
   },
   install: function getInstallDefaultPermission()
   {
-    if (Services.prefs.getBoolPref("xpinstall.whitelist.required"))
-      return BLOCK;
-    return ALLOW;
+    try {
+      if (!Services.prefs.getBoolPref("xpinstall.whitelist.required"))
+        return ALLOW;
+    }
+    catch (e) {
+    }
+    return BLOCK;
   },
   geo: function getGeoDefaultPermission()
   {
     return BLOCK;
   }
 };
 
 var permissionObserver = {
@@ -118,17 +122,20 @@ function initRow(aPartId)
   if (!/^https?/.test(gPermURI.scheme)) {
     checkbox.checked = false;
     checkbox.setAttribute("disabled", "true");
     command.setAttribute("disabled", "true");
     document.getElementById(aPartId + "RadioGroup").selectedItem = null;
     return;
   }
   checkbox.removeAttribute("disabled");
-  var perm = Services.perms.testPermission(gPermURI, aPartId);
+  var pm = Services.perms;
+  var perm = aPartId == "geo" ? pm.testExactPermission(gPermURI, aPartId) :
+                                pm.testPermission(gPermURI, aPartId);
+ 
   if (perm) {
     checkbox.checked = false;
     command.removeAttribute("disabled");
   }
   else {
     checkbox.checked = true;
     command.setAttribute("disabled", "true");
     perm = gPermObj[aPartId]();
--- a/suite/browser/test/browser/browser_feed_tab.js
+++ b/suite/browser/test/browser/browser_feed_tab.js
@@ -1,34 +1,33 @@
+// originally from m-c/browser/base/content/test/browser_pageInfo.js.
 function test() {
   waitForExplicitFinish();
 
   var pageInfo;
   var gTestPage = gBrowser.addTab();
   gBrowser.selectedTab = gTestPage;
   gTestPage.linkedBrowser.addEventListener("load", handleLoad, true);
   content.location =
-    "http://mochi.test:8888/browser/suite/browser/test/feed_tab.html";
+    "http://example.com/browser/suite/browser/test/feed_tab.html";
   gTestPage.focus();
-  var obs = Components.classes["@mozilla.org/observer-service;1"]
-                      .getService(Components.interfaces.nsIObserverService);
 
   var observer = {
     observe: function(win, topic, data) {
       if (topic != "page-info-dialog-loaded")
         return;
 
-      obs.removeObserver(observer, "page-info-dialog-loaded");
+      Services.obs.removeObserver(observer, "page-info-dialog-loaded");
       handlePageInfo();
     }
   };
 
   function handleLoad() {
     gTestPage.linkedBrowser.removeEventListener("load", handleLoad, true);
-    obs.addObserver(observer, "page-info-dialog-loaded", false);
+    Services.obs.addObserver(observer, "page-info-dialog-loaded", false);
     pageInfo = BrowserPageInfo();
   }
 
   function handlePageInfo() {
     function $(aId) { return pageInfo.document.getElementById(aId) };
     var feedTab = $("feedPanel");
     var feedListbox = $("feedListbox");