Bug 1320557 - Prevent broken UI from invalid permission states. r=Gijs
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 06 Jan 2017 10:02:58 +0100
changeset 375581 d0f0fbb66c71697c972e6b90132049d29a578468
parent 375580 7736a9b5fc05dc50989f77563f0189cdb74f2af6
child 375582 1eb8dcc1427f412282648badd1d20c2e22dd75b9
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
bugs1320557
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 1320557 - Prevent broken UI from invalid permission states. r=Gijs MozReview-Commit-ID: FxmCHoLx0lE
browser/base/content/pageinfo/permissions.js
browser/modules/SitePermissions.jsm
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -168,17 +168,19 @@ function onRadioClick(aPartId) {
   var radioGroup = document.getElementById(aPartId + "RadioGroup");
   var id = radioGroup.selectedItem.id;
   var permission = id.split('#')[1];
   SitePermissions.set(gPermURI, aPartId, permission);
 }
 
 function setRadioState(aPartId, aValue) {
   var radio = document.getElementById(aPartId + "#" + aValue);
-  radio.radioGroup.selectedItem = radio;
+  if (radio) {
+    radio.radioGroup.selectedItem = radio;
+  }
 }
 
 function initIndexedDBRow() {
   let row = document.getElementById("perm-indexedDB-row");
   let extras = document.getElementById("perm-indexedDB-extras");
 
   row.appendChild(extras);
 
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -181,17 +181,17 @@ this.SitePermissions = {
         return gStringBundle.GetStringFromName("alwaysAsk");
       case this.ALLOW:
         return gStringBundle.GetStringFromName("allow");
       case this.SESSION:
         return gStringBundle.GetStringFromName("allowForSession");
       case this.BLOCK:
         return gStringBundle.GetStringFromName("block");
       default:
-        throw new Error("unknown permission state");
+        return null;
     }
   }
 };
 
 var gPermissionObject = {
   /* Holds permission ID => options pairs.
    *
    * Supported options: