Bug 1575901 - Refactored pageInfo.js to use PermissionManager principal methods. r=johannh
authorPaul Zuehlcke <pzuhlcke@mozilla.com>
Wed, 28 Aug 2019 08:17:43 +0000
changeset 551105 12222c1aa6de971f4166e9a5dc8d92d3077f82d2
parent 551104 720ff3a404a7e289cd0437b012aeea6bfbee6c5c
child 551106 80d4cec02dc950ef6228d8d0a22dbf43d18ecea8
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1575901
milestone70.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 1575901 - Refactored pageInfo.js to use PermissionManager principal methods. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D43636
browser/base/content/pageinfo/pageInfo.js
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -841,20 +841,28 @@ function saveMedia() {
 
 function onBlockImage() {
   var permissionManager = Cc[PERMISSION_CONTRACTID].getService(
     nsIPermissionManager
   );
 
   var checkbox = document.getElementById("blockImage");
   var uri = Services.io.newURI(document.getElementById("imageurltext").value);
+  let principal = Services.scriptSecurityManager.createContentPrincipal(
+    uri,
+    gDocInfo.principal.originAttributes
+  );
   if (checkbox.checked) {
-    permissionManager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
+    permissionManager.addFromPrincipal(
+      principal,
+      "image",
+      nsIPermissionManager.DENY_ACTION
+    );
   } else {
-    permissionManager.remove(uri, "image");
+    permissionManager.removeFromPrincipal(principal, "image");
   }
 }
 
 function onImageSelect() {
   var previewBox = document.getElementById("mediaPreviewBox");
   var mediaSaveBox = document.getElementById("mediaSaveBox");
   var splitter = document.getElementById("mediaSplitter");
   var tree = document.getElementById("imagetree");
@@ -1090,17 +1098,24 @@ function makeBlockImage(url) {
     checkbox.hidden = true;
   } else {
     var uri = Services.io.newURI(url);
     if (uri.host) {
       checkbox.hidden = false;
       document.l10n.setAttributes(checkbox, "media-block-image", {
         website: uri.host,
       });
-      var perm = permissionManager.testPermission(uri, "image");
+      let principal = Services.scriptSecurityManager.createContentPrincipal(
+        uri,
+        gDocInfo.principal.originAttributes
+      );
+      let perm = permissionManager.testPermissionFromPrincipal(
+        principal,
+        "image"
+      );
       checkbox.checked = perm == nsIPermissionManager.DENY_ACTION;
     } else {
       checkbox.hidden = true;
     }
   }
 }
 
 var imagePermissionObserver = {