Bug 1522776 - Unsupported permission values should be ignored by Sanitizer.jsm, r=johannh
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 25 Jan 2019 11:44:40 +0100
changeset 512558 fa81629b009aebec457ef311088aa0508976be4e
parent 512557 569e83cc7e4c3a6fa343f0db093d82f4b5add3d0
child 512559 cdb9aa894138d831002974b80e7d7dbb6efcc0ba
push id10566
push userarchaeopteryx@coole-files.de
push dateMon, 28 Jan 2019 12:41:12 +0000
treeherdermozilla-beta@69a3d7c8d04b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1522776
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1522776 - Unsupported permission values should be ignored by Sanitizer.jsm, r=johannh
browser/base/content/test/sanitize/browser_cookiePermission.js
browser/modules/Sanitizer.jsm
--- a/browser/base/content/test/sanitize/browser_cookiePermission.js
+++ b/browser/base/content/test/sanitize/browser_cookiePermission.js
@@ -245,16 +245,36 @@ tests.forEach(methods => {
           expectedForOrg: true,
           expectedForCom: false,
           fullHost: true,
         });
     });
   });
 });
 
+// Session mode, but with unsupported custom permission, data in
+// www.example.com, cookie permission set for www.example.com
+tests.forEach(methods => {
+  attributes.forEach(originAttributes => {
+    add_task(async function deleteStorageOnlyCustomPermission() {
+      info(methods.name + ": All is session only, but with unsupported custom custom permission, data in www.example.com, cookie permission set for www.example.com - OA: " + originAttributes.name);
+      await deleteOnShutdown(
+        { lifetimePolicy: Ci.nsICookieService.ACCEPT_SESSION,
+          createData: methods.createData,
+          checkData: methods.checkData,
+          originAttributes: originAttributes.oa,
+          cookiePermission: 123, // invalid cookie permission
+          expectedForOrg: false,
+          expectedForCom: false,
+          fullHost: true,
+        });
+    });
+  });
+});
+
 add_task(async function deleteStorageInAboutURL() {
   info("Test about:newtab");
 
   // Let's clean up all the data.
   await new Promise(resolve => {
     Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
   });
 
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -683,17 +683,16 @@ async function sanitizeOnShutdown(progre
   // are also other ways to think about and accomplish this, but this is what
   // the logic below currently does!
   if (Services.prefs.getIntPref(PREF_COOKIE_LIFETIME,
                                 Ci.nsICookieService.ACCEPT_NORMALLY) == Ci.nsICookieService.ACCEPT_SESSION) {
     let principals = await getAllPrincipals();
     await maybeSanitizeSessionPrincipals(principals);
   }
 
-
   // Let's see if we have to forget some particular site.
   for (let permission of Services.perms.enumerator) {
     if (permission.type != "cookie" ||
         permission.capability != Ci.nsICookiePermission.ACCESS_SESSION) {
       continue;
     }
 
     // We consider just permissions set for http, https and file URLs.
@@ -803,16 +802,21 @@ function cookiesAllowedForDomainOrSubDom
     return true;
   }
 
   if (p == Ci.nsICookiePermission.ACCESS_DENY ||
       p == Ci.nsICookiePermission.ACCESS_SESSION) {
     return false;
   }
 
+  // This is an old profile with unsupported permission values
+  if (p != Ci.nsICookiePermission.ACCESS_DEFAULT) {
+    return false;
+  }
+
   for (let perm of Services.perms.enumerator) {
     if (perm.type != "cookie") {
       continue;
     }
 
     // We consider just permissions set for http, https and file URLs.
     if (!isSupportedURI(perm.principal.URI)) {
       continue;