diff --git a/browser/components/enterprisepolicies/Policies.jsm b/browser/components/enterprisepolicies/Policies.jsm index 95e53457e594..1093eadd864b 100644 --- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -107,15 +107,6 @@ var Policies = { "Cookies": { onBeforeUIStartup(manager, param) { addAllowDenyPermissions("cookie", param.Allow, param.Block); - - if (param.Block) { - const hosts = param.Block.map(uri => uri.host).sort().join('\n'); - runOncePerModification("clearCookiesForBlockedHosts", hosts, () => { - for (let blocked of param.Block) { - Services.cookies.removeCookiesWithOriginAttributes("{}", blocked.host); - } - }); - } } }, diff --git a/browser/components/enterprisepolicies/tests/browser/browser.ini b/browser/components/enterprisepolicies/tests/browser/browser.ini index 5ab1effcd42d..d0a73e1c9813 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser.ini +++ b/browser/components/enterprisepolicies/tests/browser/browser.ini @@ -21,7 +21,6 @@ support-files = [browser_policy_block_about_profiles.js] [browser_policy_block_about_support.js] [browser_policy_block_set_desktop_background.js] -[browser_policy_blocked_cookies.js] [browser_policy_bookmarks.js] [browser_policy_default_browser_check.js] [browser_policy_disable_formhistory.js] diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_blocked_cookies.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_blocked_cookies.js deleted file mode 100644 index 663d352a35fc..000000000000 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_blocked_cookies.js +++ /dev/null @@ -1,62 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - - -add_task(async function setup() { - const expiry = Date.now() + 24 * 60 * 60; - Services.cookies.add("example.com", "/", "secure", "true", true, false, false, expiry, {}); - Services.cookies.add("example.com", "/", "insecure", "true", false, false, false, expiry, {}); - Services.cookies.add("example.org", "/", "secure", "true", true, false, false, expiry, {}); - Services.cookies.add("example.org", "/", "insecure", "true", false, false, false, expiry, {}); - Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {}); - await setupPolicyEngineWithJson({ - "policies": { - "Cookies": { - "Block": [ - "http://example.com", - "https://example.org:8080" - ] - } - } - }); -}); - -function retrieve_all_cookies(host) { - const values = []; - const cookies = Services.cookies.getCookiesFromHost(host, {}); - while (cookies.hasMoreElements()) { - const cookie = cookies.getNext().QueryInterface(Ci.nsICookie); - values.push({ - host: cookie.host, - name: cookie.name, - path: cookie.path - }); - } - return values; -} - -add_task(async function test_cookies_for_blocked_sites_cleared() { - const cookies = { - hostname: retrieve_all_cookies("example.com"), - origin: retrieve_all_cookies("example.org"), - keep: retrieve_all_cookies("example.net") - }; - const expected = { - hostname: [], - origin: [], - keep: [ - {host: "example.net", - name: "secure", - path: "/"} - ] - }; - is(JSON.stringify(cookies), JSON.stringify(expected), - "All stored cookies for blocked hosts should be cleared"); -}); - -add_task(function teardown() { - for (let host of ["example.com", "example.org", "example.net"]) { - Services.cookies.removeCookiesWithOriginAttributes("{}", host); - } -}); \ No newline at end of file