Bug 1320557 - Prevent broken UI from invalid permission states. r=Gijs, a=jcristau
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 06 Jan 2017 10:02:58 +0100
changeset 353487 2f4669bb405480b51d87b47269d66055f90ae94c
parent 353486 f58ab27623520a2ff2844b746afc0ed7ac591934
child 353488 f0f0bb716505259fcf5038405994fb5a27cee905
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, jcristau
bugs1320557
milestone52.0a2
Bug 1320557 - Prevent broken UI from invalid permission states. r=Gijs, a=jcristau 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
@@ -178,17 +178,19 @@ function onRadioClick(aPartId)
   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: