Bug 1239671 - Don't let session store override persistent cookies, r=ehsan
authorHonza Bambas <honzab.moz@firemni.cz>
Tue, 23 Feb 2016 14:32:00 +0100
changeset 321643 9cc28ef28c0f8995726615e3a150881821e9bde5
parent 321642 e8a80985911bcf2921223e0a2365a9e591e18d97
child 321644 e0cc363043ade8f69a600bfd68edaf88b35b7c96
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1239671
milestone47.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 1239671 - Don't let session store override persistent cookies, r=ehsan
browser/components/sessionstore/SessionCookies.jsm
--- a/browser/components/sessionstore/SessionCookies.jsm
+++ b/browser/components/sessionstore/SessionCookies.jsm
@@ -112,19 +112,26 @@ var SessionCookiesInternal = {
   },
 
   /**
    * Restores a given list of session cookies.
    */
   restore(cookies) {
     for (let cookie of cookies) {
       let expiry = "expiry" in cookie ? cookie.expiry : MAX_EXPIRY;
-      Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
-                           cookie.value, !!cookie.secure, !!cookie.httponly,
-                           /* isSession = */ true, expiry);
+      let cookieObj = {
+        host: cookie.host,
+        path: cookie.path || "",
+        name: cookie.name || ""
+      };
+      if (!Services.cookies.cookieExists(cookieObj)) {
+        Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
+                             cookie.value, !!cookie.secure, !!cookie.httponly,
+                             /* isSession = */ true, expiry);
+      }
     }
   },
 
   /**
    * Handles observers notifications that are sent whenever cookies are added,
    * changed, or removed. Ensures that the storage is updated accordingly.
    */
   observe: function (subject, topic, data) {
@@ -236,16 +243,18 @@ var SessionCookiesInternal = {
   /**
    * Updates or adds a given cookie to the store.
    */
   _updateCookie: function (cookie) {
     cookie.QueryInterface(Ci.nsICookie2);
 
     if (cookie.isSession) {
       CookieStore.set(cookie);
+    } else {
+      CookieStore.delete(cookie);
     }
   },
 
   /**
    * Removes a given cookie from the store.
    */
   _removeCookie: function (cookie) {
     cookie.QueryInterface(Ci.nsICookie2);