Bug 1482055 - Cleanup old cookies at shutdown if network.cookie.lifetimePolicy is ACCEPT_SESSION, r=johannh
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 17 Oct 2018 19:53:51 +0200
changeset 490036 2c633215c5148a0ea416237b749032e44e7708fb
parent 490035 31175b7c468b1f8f8589728f8a29d433e1594cd6
child 490037 200b836d3aa5a1375edebcec36f8afa3c0cb24c0
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjohannh
bugs1482055
milestone64.0a1
Bug 1482055 - Cleanup old cookies at shutdown if network.cookie.lifetimePolicy is ACCEPT_SESSION, r=johannh
browser/modules/Sanitizer.jsm
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -706,16 +706,24 @@ async function sanitizeOnShutdown(progre
 }
 
 async function sanitizeSessionPrincipals() {
   if (Services.prefs.getIntPref(PREF_COOKIE_LIFETIME,
                                 Ci.nsICookieService.ACCEPT_NORMALLY) != Ci.nsICookieService.ACCEPT_SESSION) {
     return;
   }
 
+  // When PREF_COOKIE_LIFETIME is set to ACCEPT_SESSION, any new cookie will be
+  // marked as session only. But we don't touch the existing ones. For this
+  // reason, here we delete any existing cookie, at shutdown.
+  await new Promise(resolve => {
+    Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_COOKIES,
+                                  resolve);
+  });
+
   let principals = await new Promise(resolve => {
     quotaManagerService.getUsage(request => {
       if (request.resultCode != Cr.NS_OK) {
         // We are probably shutting down. We don't want to propagate the
         // error, rejecting the promise.
         resolve([]);
         return;
       }