mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 792604 - Permission Settings followup fixes. r=sicking
This commit is contained in:
parent
bdfc941e84
commit
e0d311872f
@ -6,10 +6,10 @@
|
||||
|
||||
interface nsIDOMDOMRequest;
|
||||
|
||||
[scriptable, uuid(36e73ef0-c6f4-11e1-9b21-0800200c9a66)]
|
||||
[scriptable, uuid(18390770-02ab-11e2-a21f-0800200c9a66)]
|
||||
interface nsIDOMPermissionSettings : nsISupports
|
||||
{
|
||||
DOMString get(in DOMString permission, in DOMString access, in DOMString manifestURI, in DOMString origin, in bool browserFlag);
|
||||
DOMString get(in DOMString permission, in DOMString manifestURI, in DOMString origin, in bool browserFlag);
|
||||
|
||||
void set(in DOMString permission, in DOMString access, in DOMString manifestURI, in DOMString origin, in DOMString value, in bool browserFlag);
|
||||
void set(in DOMString permission, in DOMString value, in DOMString manifestURI, in DOMString origin, in bool browserFlag);
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"].getSer
|
||||
// PermissionSettings
|
||||
|
||||
const PERMISSIONSETTINGS_CONTRACTID = "@mozilla.org/permissionSettings;1";
|
||||
const PERMISSIONSETTINGS_CID = Components.ID("{36e73ef0-c6f4-11e1-9b21-0800200c9a66}");
|
||||
const PERMISSIONSETTINGS_CID = Components.ID("{18390770-02ab-11e2-a21f-0800200c9a66}");
|
||||
const nsIDOMPermissionSettings = Components.interfaces.nsIDOMPermissionSettings;
|
||||
|
||||
function PermissionSettings()
|
||||
@ -36,8 +36,8 @@ var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"].getServi
|
||||
var appsService = Components.classes["@mozilla.org/AppsService;1"].getService(Components.interfaces.nsIAppsService);
|
||||
|
||||
PermissionSettings.prototype = {
|
||||
get: function get(aPermission, aAccess, aManifestURL, aOrigin, aBrowserFlag) {
|
||||
debug("Get called with: " + aPermission + ", " + aAccess + ", " + aManifestURL + ", " + aOrigin + ", " + aBrowserFlag);
|
||||
get: function get(aPermission, aManifestURL, aOrigin, aBrowserFlag) {
|
||||
debug("Get called with: " + aPermission + ", " + aManifestURL + ", " + aOrigin + ", " + aBrowserFlag);
|
||||
let uri = Services.io.newURI(aOrigin, null, null);
|
||||
let appID = appsService.getAppLocalIdByManifestURL(aManifestURL);
|
||||
let principal = secMan.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
|
||||
@ -59,12 +59,11 @@ PermissionSettings.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
set: function set(aPermission, aAccess, aManifestURL, aOrigin, aValue, aBrowserFlag) {
|
||||
debug("Set called with: " + aPermission + ", " + aAccess + ", " + aManifestURL + ", " + aOrigin + ", " + aValue + ", " + aBrowserFlag);
|
||||
set: function set(aPermission, aValue, aManifestURL, aOrigin, aBrowserFlag) {
|
||||
debug("Set called with: " + aPermission + ", " + aManifestURL + ", " + aOrigin + ", " + aValue + ", " + aBrowserFlag);
|
||||
let action;
|
||||
cpm.sendSyncMessage("PermissionSettings:AddPermission", {
|
||||
type: aPermission,
|
||||
access: aAccess,
|
||||
origin: aOrigin,
|
||||
manifestURL: aManifestURL,
|
||||
value: aValue,
|
||||
@ -74,10 +73,11 @@ PermissionSettings.prototype = {
|
||||
|
||||
init: function(aWindow) {
|
||||
debug("init");
|
||||
|
||||
// Set navigator.mozPermissionSettings to null.
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(aWindow.document.nodePrincipal, "permissions");
|
||||
if (!Services.prefs.getBoolPref("dom.mozPermissionSettings.enabled")
|
||||
|| Services.perms.testExactPermissionFromPrincipal(aWindow.document.nodePrincipal, "permissions")) {
|
||||
debug("Permission to get/set permissions not granted!");
|
||||
|| perm != Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
component {36e73ef0-c6f4-11e1-9b21-0800200c9a66} PermissionSettings.js
|
||||
contract @mozilla.org/permissionSettings;1 {36e73ef0-c6f4-11e1-9b21-0800200c9a66}
|
||||
component {18390770-02ab-11e2-a21f-0800200c9a66} PermissionSettings.js
|
||||
contract @mozilla.org/permissionSettings;1 {18390770-02ab-11e2-a21f-0800200c9a66}
|
||||
category JavaScript-navigator-property mozPermissionSettings @mozilla.org/permissionSettings;1
|
||||
|
@ -21,10 +21,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id={770731}
|
||||
|
||||
"use strict";
|
||||
|
||||
SpecialPowers.addPermission("permissions", true, document);
|
||||
var comp = SpecialPowers.wrap(Components);
|
||||
SpecialPowers.pushPrefEnv({ "set": [["dom.mozPermissionSettings.enabled", true]] },
|
||||
function() {
|
||||
SpecialPowers.addPermission("permissions", true, document);
|
||||
SpecialPowers.removePermission("permissions", document);
|
||||
});
|
||||
|
||||
comp.utils.import("resource://gre/modules/PermissionSettings.jsm");
|
||||
@ -32,17 +33,17 @@ var mozPermissions = window.navigator.mozPermissionSettings;
|
||||
|
||||
function permissionTest() {
|
||||
if (gPermissionssEnabled) {
|
||||
mozPermissions.set("a", "read", "http://examplemanifestURI.com", "http://origin.com", "unknown", true);
|
||||
var result = mozPermissions.get("a","read", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
mozPermissions.set("a", "unknown", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
var result = mozPermissions.get("a", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
is(result, "unknown", "same result");
|
||||
mozPermissions.set("a", "read", "http://examplemanifestURI.com", "http://origin.com", "allow", true);
|
||||
result = mozPermissions.get("a","read", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
mozPermissions.set("a", "allow", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
result = mozPermissions.get("a", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
is(result, "allow", "same result");
|
||||
mozPermissions.set("a", "read", "http://examplemanifestURI.com", "http://origin.com", "deny", true);
|
||||
result = mozPermissions.get("a","read", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
mozPermissions.set("a", "deny", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
result = mozPermissions.get("a", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
is(result, "deny", "same result");
|
||||
mozPermissions.set("a", "read", "http://examplemanifestURI.com", "http://origin.com", "prompt", true);
|
||||
result = mozPermissions.get("a","read", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
mozPermissions.set("a", "prompt", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
result = mozPermissions.get("a", "http://examplemanifestURI.com", "http://origin.com", true);
|
||||
is(result, "prompt", "same result");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user