Bug 770705 - Changes to about:permissions to expose ALLOW_FIRST_PARTY_ONLY as a site specific cookie pref. r=margaret

This commit is contained in:
Monica Chew 2012-09-24 16:20:00 -07:00
parent 7e1eac7739
commit 395b701269
5 changed files with 22 additions and 2 deletions

View File

@ -761,12 +761,18 @@ let AboutPermissions = {
permissionValue = PermissionDefaults[aType];
if (aType == "plugins")
document.getElementById("plugins-pref-item").hidden = false;
else if (aType == "cookie")
// cookie-9 corresponds to ALLOW_FIRST_PARTY_ONLY, which is reserved
// for site-specific preferences only.
document.getElementById("cookie-9").hidden = true;
} else {
if (aType == "plugins") {
document.getElementById("plugins-pref-item").hidden =
!Services.prefs.getBoolPref("plugins.click_to_play");
return;
}
if (aType == "cookie")
document.getElementById("cookie-9").hidden = false;
let result = {};
permissionValue = this._selectedSite.getPermission(aType, result) ?
result.value : PermissionDefaults[aType];

View File

@ -127,6 +127,7 @@
<menupopup>
<menuitem id="cookie-1" value="1" label="&permission.allow;"/>
<menuitem id="cookie-8" value="8" label="&permission.allowForSession;"/>
<menuitem id="cookie-9" value="9" label="&permission.allowFirstPartyOnly;"/>
<menuitem id="cookie-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>

View File

@ -14,7 +14,6 @@ const TEST_URI_3 = NetUtil.newURI("http://wikipedia.org/");
const PERM_UNKNOWN = 0;
const PERM_ALLOW = 1;
const PERM_DENY = 2;
const PERM_SESION = 8;
// used to set permissions on test sites
const TEST_PERMS = {

View File

@ -16,7 +16,8 @@ const TEST_PRINCIPAL_2 = Services.scriptSecurityManager.getNoAppCodebasePrincipa
const PERM_UNKNOWN = 0;
const PERM_ALLOW = 1;
const PERM_DENY = 2;
const PERM_SESION = 8;
// cookie specific permissions
const PERM_FIRST_PARTY_ONLY = 9;
// used to set permissions on test sites
const TEST_PERMS = {
@ -253,6 +254,18 @@ var tests = [
is(Services.perms.testPermissionFromPrincipal(TEST_PRINCIPAL_2, "geo"), PERM_ALLOW,
"permission manager shows that geolocation is allowed");
// change a site-specific cookie permission, just for fun
let cookieMenuList = getPermissionMenulist("cookie");
let cookieItem = gBrowser.contentDocument.getElementById("cookie-" + PERM_FIRST_PARTY_ONLY);
cookieMenuList.selectedItem = cookieItem;
cookieMenuList.doCommand();
is(cookieMenuList.value, PERM_FIRST_PARTY_ONLY, "menulist correctly shows that " +
"first party only cookies are allowed");
is(Services.perms.testPermissionFromPrincipal(TEST_PRINCIPAL_2, "cookie"),
PERM_FIRST_PARTY_ONLY, "permission manager shows that first party cookies " +
"are allowed");
runNextTest();
},

View File

@ -20,6 +20,7 @@
<!ENTITY permission.alwaysAsk "Always Ask">
<!ENTITY permission.allow "Allow">
<!ENTITY permission.allowForSession "Allow for Session">
<!ENTITY permission.allowFirstPartyOnly "Allow First Party Only">
<!ENTITY permission.block "Block">
<!ENTITY password.label "Store Passwords">