diff options
Diffstat (limited to 'toolkit/components/cleardata')
5 files changed, 85 insertions, 3 deletions
diff --git a/toolkit/components/cleardata/PrincipalsCollector.sys.mjs b/toolkit/components/cleardata/PrincipalsCollector.sys.mjs index 2b5917c6ce..e4f5e827f6 100644 --- a/toolkit/components/cleardata/PrincipalsCollector.sys.mjs +++ b/toolkit/components/cleardata/PrincipalsCollector.sys.mjs @@ -17,7 +17,7 @@ let logConsole; function log(msg) { if (!logConsole) { logConsole = console.createInstance({ - prefix: "** PrincipalsCollector.jsm", + prefix: "PrincipalsCollector", maxLogLevelPref: "browser.sanitizer.loglevel", }); } diff --git a/toolkit/components/cleardata/ServiceWorkerCleanUp.sys.mjs b/toolkit/components/cleardata/ServiceWorkerCleanUp.sys.mjs index 1c49b2be08..b513e47aba 100644 --- a/toolkit/components/cleardata/ServiceWorkerCleanUp.sys.mjs +++ b/toolkit/components/cleardata/ServiceWorkerCleanUp.sys.mjs @@ -15,7 +15,7 @@ XPCOMUtils.defineLazyServiceGetter( if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) { throw new Error( - "ServiceWorkerCleanUp.jsm can only be used in the parent process" + "ServiceWorkerCleanUp.sys.mjs can only be used in the parent process" ); } diff --git a/toolkit/components/cleardata/nsIClearDataService.idl b/toolkit/components/cleardata/nsIClearDataService.idl index 0dff281dbe..ea17059bbe 100644 --- a/toolkit/components/cleardata/nsIClearDataService.idl +++ b/toolkit/components/cleardata/nsIClearDataService.idl @@ -140,7 +140,7 @@ interface nsIClearDataService : nsISupports * whose base domain does not have any storage associated with it. * * The principals to be considered will need to be passed by the API consumer. - * It is recommended to use PrincipalsCollector.jsm for that. + * It is recommended to use PrincipalsCollector.sys.mjs for that. * * @param aPrincipalsWithStorage principals to be excluded from clearing * @param aFrom microseconds from the epoch 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); +}); |