зеркало из https://github.com/mozilla/gecko-dev.git
Bug 205541 Selecting "Unblock Cookies..." while on a site that you'd previously blocked allows the site to set cookies rather than just removing the block
patch by mpconnor@rogers.com r=neil sr=alecf
This commit is contained in:
Родитель
45c2bb8d16
Коммит
ac828a26e3
|
@ -52,8 +52,6 @@
|
|||
// determine which items we need to hide or disable from the task menu
|
||||
function CheckForVisibility()
|
||||
{
|
||||
var uri = getBrowser().currentURI;
|
||||
|
||||
// obtain access to permissionmanager and popupmanager
|
||||
// (popup manager is a wrapper around permission that does extra work)
|
||||
permissionmanager =
|
||||
|
@ -68,15 +66,13 @@
|
|||
}
|
||||
|
||||
// determine current state (blocked or unblocked) and hide appropriate menu item
|
||||
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
|
||||
blocked = permissionmanager.testPermission(uri, "cookie");
|
||||
enableElement("AllowCookies", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockCookies", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
blocked = permissionmanager.testPermission(uri, "image");
|
||||
enableElement("AllowImages", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockImages", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
var uri = getBrowser().currentURI;
|
||||
setRadioButton("UseCookiesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "cookie");
|
||||
setRadioButton("AllowCookies", uri, nsIPermissionManager.ALLOW_ACTION, "cookie");
|
||||
setRadioButton("BlockCookies", uri, nsIPermissionManager.DENY_ACTION, "cookie");
|
||||
setRadioButton("UseImagesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "image");
|
||||
setRadioButton("AllowImages", uri, nsIPermissionManager.ALLOW_ACTION, "image");
|
||||
setRadioButton("BlockImages", uri, nsIPermissionManager.DENY_ACTION, "image");
|
||||
|
||||
SetPopupMenuEnabledState();
|
||||
|
||||
|
@ -116,6 +112,11 @@
|
|||
|
||||
enableElement("AllowPopups", false);
|
||||
}
|
||||
|
||||
function setRadioButton(elementID, uri, perm, type) {
|
||||
var enable = (perm == permissionmanager.testPermission(uri, type));
|
||||
document.getElementById(elementID).setAttribute("checked", enable);
|
||||
}
|
||||
|
||||
function enableElement(elementID, enable) {
|
||||
var element = document.getElementById(elementID);
|
||||
|
@ -134,29 +135,50 @@
|
|||
}
|
||||
var element;
|
||||
var uri = getBrowser().currentURI;
|
||||
|
||||
switch (action) {
|
||||
case "cookieAllow":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsIPermissionManager.ALLOW_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "cookieDefault":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsIPermissionManager.UNKNOWN_ACTION)
|
||||
return;
|
||||
permissionmanager.remove(uri.hostPort, "cookie");
|
||||
element = document.getElementById("UseCookiesDefault");
|
||||
break;
|
||||
case "cookieBlock":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsIPermissionManager.DENY_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageAllow":
|
||||
if (permissionmanager.testPermission(uri, "image") == nsIPermissionManager.ALLOW_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageDefault":
|
||||
if (permissionmanager.testPermission(uri, "image") == nsIPermissionManager.UNKNOWN_ACTION)
|
||||
return;
|
||||
permissionmanager.remove(uri.hostPort, "image");
|
||||
element = document.getElementById("UseImagesDefault");
|
||||
break;
|
||||
case "imageBlock":
|
||||
if (permissionmanager.testPermission(uri, "image") == nsIPermissionManager.DENY_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
promptService.alert(window,element.getAttribute("title"), element.getAttribute("msg"));
|
||||
}
|
||||
|
||||
function OpenAboutPopups() {
|
||||
|
@ -182,11 +204,21 @@
|
|||
<menupopup>
|
||||
<menuitem id="BlockCookies" label="&cookieBlockCookiesCmd.label;"
|
||||
accesskey="&cookieBlockCookiesCmd.accesskey;"
|
||||
title="&cookieMessageTitle.label;"
|
||||
msg="&cookieBlockCookiesMsg.label;"
|
||||
type="radio" name="cookies"
|
||||
oncommand="CookieImageAction('cookieBlock');"/>
|
||||
<menuitem id="UseCookiesDefault" label="&cookieCookiesDefaultCmd.label;"
|
||||
accesskey="&cookieCookiesDefaultCmd.accesskey;"
|
||||
title="&cookieMessageTitle.label;"
|
||||
msg="&cookieCookiesDefaultMsg.label;"
|
||||
type="radio" name="cookies" checked="true"
|
||||
oncommand="CookieImageAction('cookieDefault');"/>
|
||||
<menuitem id="AllowCookies" label="&cookieAllowCookiesCmd.label;"
|
||||
title="&cookieMessageTitle.label;"
|
||||
accesskey="&cookieAllowCookiesCmd.accesskey;"
|
||||
msg="&cookieAllowCookiesMsg.label;"
|
||||
type="radio" name="cookies"
|
||||
oncommand="CookieImageAction('cookieAllow');"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayCookiesCmd.label;"
|
||||
|
@ -201,11 +233,21 @@
|
|||
<menupopup>
|
||||
<menuitem id="BlockImages" label="&cookieBlockImagesCmd.label;"
|
||||
accesskey="&cookieBlockImagesCmd.accesskey;"
|
||||
title="&cookieImageMessageTitle.label;"
|
||||
msg="&cookieBlockImagesMsg.label;"
|
||||
type="radio" name="images"
|
||||
oncommand="CookieImageAction('imageBlock');"/>
|
||||
<menuitem id="UseImagesDefault" label="&cookieImagesDefaultCmd.label;"
|
||||
accesskey="&cookieImagesDefaultCmd.accesskey;"
|
||||
title="&cookieImageMessageTitle.label;"
|
||||
msg="&cookieImagesDefaultMsg.label;"
|
||||
type="radio" name="images"
|
||||
oncommand="CookieImageAction('imageDefault');"/>
|
||||
<menuitem id="AllowImages" label="&cookieAllowImagesCmd.label;"
|
||||
accesskey="&cookieAllowImagesCmd.accesskey;"
|
||||
accesskey="&cookieAllowImagesCmd.accesskey;"
|
||||
title="&cookieImageMessageTitle.label;"
|
||||
msg="&cookieAllowImagesMsg.label;"
|
||||
type="radio" name="images"
|
||||
oncommand="CookieImageAction('imageAllow');"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayImagesCmd.label;"
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
<!-- the following is for the task menu overlay -->
|
||||
|
||||
<!ENTITY cookieMessageTitle.label "Cookie Permissions Changed">
|
||||
<!ENTITY cookieDisplayCookiesCmd.label "Manage Stored Cookies">
|
||||
<!ENTITY cookieDisplayCookiesCmd.accesskey "m">
|
||||
<!ENTITY cookieAllowCookiesCmd.label "Unblock Cookies from this Site">
|
||||
<!ENTITY cookieAllowCookiesCmd.accesskey "u">
|
||||
<!ENTITY cookieDisplayCookiesCmd.accesskey "M">
|
||||
<!ENTITY cookieAllowCookiesCmd.label "Allow Cookies from this Site">
|
||||
<!ENTITY cookieAllowCookiesCmd.accesskey "A">
|
||||
<!ENTITY cookieAllowCookiesMsg.label "Cookies from this site will not be blocked">
|
||||
<!ENTITY cookieCookiesDefaultCmd.label "Use Default Cookie Permissions">
|
||||
<!ENTITY cookieCookiesDefaultCmd.accesskey "U">
|
||||
<!ENTITY cookieCookiesDefaultMsg.label "Cookies from this site will be accepted or rejected based on default settings">
|
||||
<!ENTITY cookieBlockCookiesCmd.label "Block Cookies from this Site">
|
||||
<!ENTITY cookieBlockCookiesCmd.accesskey "b">
|
||||
<!ENTITY cookieBlockCookiesCmd.accesskey "B">
|
||||
<!ENTITY cookieBlockCookiesMsg.label "Cookies from this site will always be rejected">
|
||||
|
||||
<!ENTITY cookieImageMessageTitle.label "Image Permissions Changed">
|
||||
<!ENTITY cookieDisplayImagesCmd.label "Manage Image Permissions">
|
||||
<!ENTITY cookieDisplayImagesCmd.accesskey "m">
|
||||
<!ENTITY cookieAllowImagesCmd.label "Unblock Images from this Site">
|
||||
<!ENTITY cookieAllowImagesCmd.accesskey "u">
|
||||
<!ENTITY cookieDisplayImagesCmd.accesskey "M">
|
||||
<!ENTITY cookieAllowImagesCmd.label "Allow Images from this Site">
|
||||
<!ENTITY cookieAllowImagesCmd.accesskey "A">
|
||||
<!ENTITY cookieAllowImagesMsg.label "Images from this site will always be downloaded">
|
||||
<!ENTITY cookieImagesDefaultCmd.label "Use Default Image Permissions">
|
||||
<!ENTITY cookieImagesDefaultCmd.accesskey "U">
|
||||
<!ENTITY cookieImagesDefaultMsg.label "Images from this site will be downloaded based on default settings">
|
||||
<!ENTITY cookieBlockImagesCmd.label "Block Images from this Site">
|
||||
<!ENTITY cookieBlockImagesCmd.accesskey "b">
|
||||
<!ENTITY cookieBlockImagesCmd.accesskey "B">
|
||||
<!ENTITY cookieBlockImagesMsg.label "Images from this site will never be downloaded">
|
||||
|
||||
<!ENTITY cookieAllowPopupsCmd.label "Allow Popups From This Site">
|
||||
|
|
|
@ -52,8 +52,6 @@
|
|||
// determine which items we need to hide or disable from the task menu
|
||||
function CheckForVisibility()
|
||||
{
|
||||
var uri = getBrowser().currentURI;
|
||||
|
||||
// obtain access to permissionmanager and popupmanager
|
||||
// (popup manager is a wrapper around permission that does extra work)
|
||||
permissionmanager =
|
||||
|
@ -68,15 +66,13 @@
|
|||
}
|
||||
|
||||
// determine current state (blocked or unblocked) and hide appropriate menu item
|
||||
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
|
||||
blocked = permissionmanager.testPermission(uri, "cookie");
|
||||
enableElement("AllowCookies", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockCookies", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
blocked = permissionmanager.testPermission(uri, "image");
|
||||
enableElement("AllowImages", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockImages", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
var uri = getBrowser().currentURI;
|
||||
setRadioButton("UseCookiesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "cookie");
|
||||
setRadioButton("AllowCookies", uri, nsIPermissionManager.ALLOW_ACTION, "cookie");
|
||||
setRadioButton("BlockCookies", uri, nsIPermissionManager.DENY_ACTION, "cookie");
|
||||
setRadioButton("UseImagesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "image");
|
||||
setRadioButton("AllowImages", uri, nsIPermissionManager.ALLOW_ACTION, "image");
|
||||
setRadioButton("BlockImages", uri, nsIPermissionManager.DENY_ACTION, "image");
|
||||
|
||||
SetPopupMenuEnabledState();
|
||||
|
||||
|
@ -116,6 +112,11 @@
|
|||
|
||||
enableElement("AllowPopups", false);
|
||||
}
|
||||
|
||||
function setRadioButton(elementID, uri, perm, type) {
|
||||
var enable = (perm == permissionmanager.testPermission(uri, type));
|
||||
document.getElementById(elementID).setAttribute("checked", enable);
|
||||
}
|
||||
|
||||
function enableElement(elementID, enable) {
|
||||
var element = document.getElementById(elementID);
|
||||
|
@ -134,29 +135,50 @@
|
|||
}
|
||||
var element;
|
||||
var uri = getBrowser().currentURI;
|
||||
|
||||
switch (action) {
|
||||
case "cookieAllow":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsIPermissionManager.ALLOW_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "cookieDefault":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsIPermissionManager.UNKNOWN_ACTION)
|
||||
return;
|
||||
permissionmanager.remove(uri.hostPort, "cookie");
|
||||
element = document.getElementById("UseCookiesDefault");
|
||||
break;
|
||||
case "cookieBlock":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsIPermissionManager.DENY_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageAllow":
|
||||
if (permissionmanager.testPermission(uri, "image") == nsIPermissionManager.ALLOW_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageDefault":
|
||||
if (permissionmanager.testPermission(uri, "image") == nsIPermissionManager.UNKNOWN_ACTION)
|
||||
return;
|
||||
permissionmanager.remove(uri.hostPort, "image");
|
||||
element = document.getElementById("UseImagesDefault");
|
||||
break;
|
||||
case "imageBlock":
|
||||
if (permissionmanager.testPermission(uri, "image") == nsIPermissionManager.DENY_ACTION)
|
||||
return;
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
promptService.alert(window,element.getAttribute("title"), element.getAttribute("msg"));
|
||||
}
|
||||
|
||||
function OpenAboutPopups() {
|
||||
|
@ -182,11 +204,21 @@
|
|||
<menupopup>
|
||||
<menuitem id="BlockCookies" label="&cookieBlockCookiesCmd.label;"
|
||||
accesskey="&cookieBlockCookiesCmd.accesskey;"
|
||||
title="&cookieMessageTitle.label;"
|
||||
msg="&cookieBlockCookiesMsg.label;"
|
||||
type="radio" name="cookies"
|
||||
oncommand="CookieImageAction('cookieBlock');"/>
|
||||
<menuitem id="UseCookiesDefault" label="&cookieCookiesDefaultCmd.label;"
|
||||
accesskey="&cookieCookiesDefaultCmd.accesskey;"
|
||||
title="&cookieMessageTitle.label;"
|
||||
msg="&cookieCookiesDefaultMsg.label;"
|
||||
type="radio" name="cookies" checked="true"
|
||||
oncommand="CookieImageAction('cookieDefault');"/>
|
||||
<menuitem id="AllowCookies" label="&cookieAllowCookiesCmd.label;"
|
||||
title="&cookieMessageTitle.label;"
|
||||
accesskey="&cookieAllowCookiesCmd.accesskey;"
|
||||
msg="&cookieAllowCookiesMsg.label;"
|
||||
type="radio" name="cookies"
|
||||
oncommand="CookieImageAction('cookieAllow');"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayCookiesCmd.label;"
|
||||
|
@ -201,11 +233,21 @@
|
|||
<menupopup>
|
||||
<menuitem id="BlockImages" label="&cookieBlockImagesCmd.label;"
|
||||
accesskey="&cookieBlockImagesCmd.accesskey;"
|
||||
title="&cookieImageMessageTitle.label;"
|
||||
msg="&cookieBlockImagesMsg.label;"
|
||||
type="radio" name="images"
|
||||
oncommand="CookieImageAction('imageBlock');"/>
|
||||
<menuitem id="UseImagesDefault" label="&cookieImagesDefaultCmd.label;"
|
||||
accesskey="&cookieImagesDefaultCmd.accesskey;"
|
||||
title="&cookieImageMessageTitle.label;"
|
||||
msg="&cookieImagesDefaultMsg.label;"
|
||||
type="radio" name="images"
|
||||
oncommand="CookieImageAction('imageDefault');"/>
|
||||
<menuitem id="AllowImages" label="&cookieAllowImagesCmd.label;"
|
||||
accesskey="&cookieAllowImagesCmd.accesskey;"
|
||||
accesskey="&cookieAllowImagesCmd.accesskey;"
|
||||
title="&cookieImageMessageTitle.label;"
|
||||
msg="&cookieAllowImagesMsg.label;"
|
||||
type="radio" name="images"
|
||||
oncommand="CookieImageAction('imageAllow');"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayImagesCmd.label;"
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
<!-- the following is for the task menu overlay -->
|
||||
|
||||
<!ENTITY cookieMessageTitle.label "Cookie Permissions Changed">
|
||||
<!ENTITY cookieDisplayCookiesCmd.label "Manage Stored Cookies">
|
||||
<!ENTITY cookieDisplayCookiesCmd.accesskey "m">
|
||||
<!ENTITY cookieAllowCookiesCmd.label "Unblock Cookies from this Site">
|
||||
<!ENTITY cookieAllowCookiesCmd.accesskey "u">
|
||||
<!ENTITY cookieDisplayCookiesCmd.accesskey "M">
|
||||
<!ENTITY cookieAllowCookiesCmd.label "Allow Cookies from this Site">
|
||||
<!ENTITY cookieAllowCookiesCmd.accesskey "A">
|
||||
<!ENTITY cookieAllowCookiesMsg.label "Cookies from this site will not be blocked">
|
||||
<!ENTITY cookieCookiesDefaultCmd.label "Use Default Cookie Permissions">
|
||||
<!ENTITY cookieCookiesDefaultCmd.accesskey "U">
|
||||
<!ENTITY cookieCookiesDefaultMsg.label "Cookies from this site will be accepted or rejected based on default settings">
|
||||
<!ENTITY cookieBlockCookiesCmd.label "Block Cookies from this Site">
|
||||
<!ENTITY cookieBlockCookiesCmd.accesskey "b">
|
||||
<!ENTITY cookieBlockCookiesCmd.accesskey "B">
|
||||
<!ENTITY cookieBlockCookiesMsg.label "Cookies from this site will always be rejected">
|
||||
|
||||
<!ENTITY cookieImageMessageTitle.label "Image Permissions Changed">
|
||||
<!ENTITY cookieDisplayImagesCmd.label "Manage Image Permissions">
|
||||
<!ENTITY cookieDisplayImagesCmd.accesskey "m">
|
||||
<!ENTITY cookieAllowImagesCmd.label "Unblock Images from this Site">
|
||||
<!ENTITY cookieAllowImagesCmd.accesskey "u">
|
||||
<!ENTITY cookieDisplayImagesCmd.accesskey "M">
|
||||
<!ENTITY cookieAllowImagesCmd.label "Allow Images from this Site">
|
||||
<!ENTITY cookieAllowImagesCmd.accesskey "A">
|
||||
<!ENTITY cookieAllowImagesMsg.label "Images from this site will always be downloaded">
|
||||
<!ENTITY cookieImagesDefaultCmd.label "Use Default Image Permissions">
|
||||
<!ENTITY cookieImagesDefaultCmd.accesskey "U">
|
||||
<!ENTITY cookieImagesDefaultMsg.label "Images from this site will be downloaded based on default settings">
|
||||
<!ENTITY cookieBlockImagesCmd.label "Block Images from this Site">
|
||||
<!ENTITY cookieBlockImagesCmd.accesskey "b">
|
||||
<!ENTITY cookieBlockImagesCmd.accesskey "B">
|
||||
<!ENTITY cookieBlockImagesMsg.label "Images from this site will never be downloaded">
|
||||
|
||||
<!ENTITY cookieAllowPopupsCmd.label "Allow Popups From This Site">
|
||||
|
|
Загрузка…
Ссылка в новой задаче