summaryrefslogtreecommitdiffstats
path: root/toolkit/components/cleardata/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /toolkit/components/cleardata/tests
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/cleardata/tests')
-rw-r--r--toolkit/components/cleardata/tests/marionette/test_moved_origin_directory_cleanup.py11
-rw-r--r--toolkit/components/cleardata/tests/unit/test_cookies.js71
2 files changed, 82 insertions, 0 deletions
diff --git a/toolkit/components/cleardata/tests/marionette/test_moved_origin_directory_cleanup.py b/toolkit/components/cleardata/tests/marionette/test_moved_origin_directory_cleanup.py
index 876f86cd32..50f4c93f65 100644
--- a/toolkit/components/cleardata/tests/marionette/test_moved_origin_directory_cleanup.py
+++ b/toolkit/components/cleardata/tests/marionette/test_moved_origin_directory_cleanup.py
@@ -46,6 +46,11 @@ class MovedOriginDirectoryCleanupTestCase(MarionetteTestCase):
"""
)
+ def read_prefs_file(self):
+ pref_path = Path(self.marionette.profile_path) / "prefs.js"
+ with open(pref_path) as f:
+ return f.read()
+
def removeAllCookies(self):
with self.marionette.using_context("chrome"):
self.marionette.execute_script(
@@ -83,6 +88,12 @@ class MovedOriginDirectoryCleanupTestCase(MarionetteTestCase):
message="privacy.sanitize.pending must include offlineApps",
)
+ # Make sure the pref is written to the file
+ Wait(self.marionette).until(
+ lambda _: "offlineApps" in self.read_prefs_file(),
+ message="prefs.js must include offlineApps",
+ )
+
# Cleanup happens via Sanitizer.onStartup after restart
self.marionette.restart(in_app=False)
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);
+});