diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /toolkit/components/cleardata/tests/unit | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/cleardata/tests/unit')
-rw-r--r-- | toolkit/components/cleardata/tests/unit/test_cookies.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/toolkit/components/cleardata/tests/unit/test_cookies.js b/toolkit/components/cleardata/tests/unit/test_cookies.js index 4bcb6d725a..045f6c0b24 100644 --- a/toolkit/components/cleardata/tests/unit/test_cookies.js +++ b/toolkit/components/cleardata/tests/unit/test_cookies.js @@ -391,3 +391,74 @@ add_task(async function test_baseDomain_cookies_subdomain() { // Cleanup Services.cookies.removeAll(); }); + +function addCookiesForHost(host) { + const expiry = Date.now() + 24 * 60 * 60; + Services.cookies.add( + host, + "path", + "name", + "value", + true /* secure */, + true /* http only */, + false /* session */, + expiry, + {}, + Ci.nsICookie.SAMESITE_NONE, + Ci.nsICookie.SCHEME_HTTPS + ); +} + +function addIpv6Cookies() { + addCookiesForHost("[A:B:C:D:E:0:0:1]"); + addCookiesForHost("[a:b:c:d:e:0:0:1]"); + addCookiesForHost("[A:B:C:D:E::1]"); + addCookiesForHost("[000A:000B:000C:000D:000E:0000:0000:0001]"); + addCookiesForHost("A:B:C:D:E:0:0:1"); + addCookiesForHost("a:b:c:d:e:0:0:1"); + addCookiesForHost("A:B:C:D:E::1"); + + Assert.equal(Services.cookies.cookies.length, 7); +} + +// This tests the intermediate fix for Bug 1860033. +// When Bug 1882259 is resolved multiple cookies with same IPv6 host in +// different representation will not be stored anymore and this test needs to +// be removed. +add_task(async function test_ipv6_cookies() { + // Add multiple cookies of same IPv6 address in different representations. + addIpv6Cookies(); + + // Delete cookies using cookie service + Services.cookies.removeCookiesFromExactHost( + "A:B:C:D:E::1", + JSON.stringify({}) + ); + + // Assert that all cookies were removed. + Assert.equal(Services.cookies.cookies.length, 0); + + // Add multiple cookies of same IPv6 address in different representations. + addIpv6Cookies(); + + // Delete cookies by principal from URI + let uri = Services.io.newURI("http://[A:B:C:D:E::1]"); + let principal = Services.scriptSecurityManager.createContentPrincipal( + uri, + {} + ); + await new Promise(aResolve => { + Services.clearData.deleteDataFromPrincipal( + principal, + true /* user request */, + Ci.nsIClearDataService.CLEAR_COOKIES, + value => { + Assert.equal(value, 0); + aResolve(); + } + ); + }); + + // Assert that all cookies were removed. + Assert.equal(Services.cookies.cookies.length, 0); +}); |