diff --git a/dom/permission/PermissionPromptHelper.jsm b/dom/permission/PermissionPromptHelper.jsm index 044c68279489..98c8306d1ec1 100644 --- a/dom/permission/PermissionPromptHelper.jsm +++ b/dom/permission/PermissionPromptHelper.jsm @@ -74,10 +74,18 @@ this.PermissionPromptHelper = { } if (permValue == Ci.nsIPermissionManager.PROMPT_ACTION) { - // create a nsIContentPermissionRequest - let request = { + // create an array with a nsIContentPermissionType element + let type = { type: msg.type, access: msg.access ? msg.access : "unused", + QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionType]) + }; + let typeArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray); + typeArray.appendElement(type, false); + + // create a nsIContentPermissionRequest + let request = { + types: typeArray, principal: principal, QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionRequest]), allow: aCallbacks.allow, diff --git a/dom/permission/PermissionPromptService.js b/dom/permission/PermissionPromptService.js index 954fd2c94fc4..40ec10a49f50 100644 --- a/dom/permission/PermissionPromptService.js +++ b/dom/permission/PermissionPromptService.js @@ -68,8 +68,17 @@ PermissionPromptService.prototype = { + "2nd argument must be type 'nsIContentPermissionRequest'"); } - let type = aRequest.access !== "unused" ? aRequest.type + "-" + aRequest.access - : aRequest.type; + // Only allow exactly one permission request here. + let types = aRequest.types.QueryInterface(Ci.nsIArray); + if (types.length != 1) { + aRequest.cancel(); + return; + } + + let reqType = types.queryElementAt(0, Ci.nsIContentPermissionType); + + let type = reqType.access !== "unused" ? reqType.type + "-" + reqType.access + : reqType.type; let perm = permissionManager.testExactPermissionFromPrincipal(aRequest.principal, type);