Bug 775829 - Use the new Permission Manager API in Browser ID. r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Fri, 20 Jul 2012 18:09:12 -0700
changeset 100008 d60807c526a5e02373c01b6dce32fb63b727b173
parent 100007 9bde00d26d7cde4f42db0b14f7ce7d4d2b131ff9
child 100009 c91e97f88ab3a10321ec66679a55aeb3b43ec688
push id12294
push usermlamouri@mozilla.com
push dateSat, 21 Jul 2012 01:10:28 +0000
treeherdermozilla-inbound@d60807c526a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs775829
milestone17.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 775829 - Use the new Permission Manager API in Browser ID. r=sicking
services/aitc/modules/browserid.js
--- a/services/aitc/modules/browserid.js
+++ b/services/aitc/modules/browserid.js
@@ -207,37 +207,36 @@ BrowserIDService.prototype = {
   /**
    * Open a login window and ask the user to login, returning the assertion
    * generated as a result to the caller.
    */
   _getAssertionWithLogin: function _getAssertionWithLogin(cb, win) {
     // We're executing navigator.id.get as a content script in win.
     // This results in a popup that we will temporarily unblock.
     let pm = Services.perms;
-    let origin = Services.io.newURI(
-      win.wrappedJSObject.location.toString(), null, null
-    );
-    let oldPerm = pm.testExactPermission(origin, "popup");
+    let principal = win.document.nodePrincipal;
+
+    let oldPerm = pm.testExactPermissionFromPrincipal(principal, "popup");
     try {
-      pm.add(origin, "popup", pm.ALLOW_ACTION);
+      pm.addFromPrincipal(principal, "popup", pm.ALLOW_ACTION);
     } catch(e) {
       this._log.warn("Setting popup blocking to false failed " + e);
     }
 
     // Open sandbox and execute script. This sandbox will be GC'ed.
     let sandbox = new Cu.Sandbox(win, {
       wantXrays:        false,
       sandboxPrototype: win
     });
 
     let self = this;
     function callback(val) {
       // Set popup blocker permission to original value.
       try {
-        pm.add(origin, "popup", oldPerm);
+        pm.addFromPrincipal(principal, "popup", oldPerm);
       } catch(e) {
         this._log.warn("Setting popup blocking to original value failed " + e);
       }
 
       if (val) {
         self._log.info("_getAssertionWithLogin succeeded");
         try {
           cb(null, val);