Backed out 2 changesets (bug 1529836) for mochitest failures on test_documentcookies_maxage.html . CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Tue, 26 Feb 2019 17:57:02 +0200
changeset 519051 68e3a5f4e4e3e352ae3e3c8ed57fd5f59eff14cb
parent 519050 fb90471fe73746e4a508b540c9860380a5e99691
child 519052 5dfd3339e5cc52a4a7c6b9539756dc8d77a3674b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1529836
milestone67.0a1
backs outd8ec58f95f80e67432601ad43e0ea492e9d09b73
2fa205089aead069478b712dba42ea45bd82ea0b
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
Backed out 2 changesets (bug 1529836) for mochitest failures on test_documentcookies_maxage.html . CLOSED TREE Backed out changeset d8ec58f95f80 (bug 1529836) Backed out changeset 2fa205089aea (bug 1529836)
modules/libpref/init/StaticPrefList.h
netwerk/cookie/nsCookieService.cpp
netwerk/cookie/nsCookieService.h
netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js
netwerk/test/mochitests/mochitest.ini
netwerk/test/mochitests/subResources.sjs
netwerk/test/mochitests/test_documentcookies_maxage.html
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -1936,23 +1936,16 @@ VARCACHE_PREF(
 
 // Anti-tracking user-interaction document interval
 VARCACHE_PREF(
   "privacy.userInteraction.document.interval",
    privacy_userInteraction_document_interval,
   uint32_t, 1800 // 30 minutes (in seconds)
 )
 
-// Maximum client-side cookie life-time cap
-VARCACHE_PREF(
-  "privacy.documentCookies.maxage",
-   privacy_documentCookies_maxage,
-  uint32_t, 0 // Disabled (in seconds, set to 0 to disable)
-)
-
 // Anti-fingerprinting, disabled by default
 VARCACHE_PREF(
   "privacy.resistFingerprinting",
    privacy_resistFingerprinting,
   RelaxedAtomicBool, false
 )
 
 VARCACHE_PREF(
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -3270,19 +3270,18 @@ bool nsCookieService::CanSetCookie(nsIUR
                                 (isHTTPS ? 0x02 : 0x00) |
                                 (aCookieAttributes.isSecure ? 0x01 : 0x00));
     }
   }
 
   int64_t currentTimeInUsec = PR_Now();
 
   // calculate expiry time of cookie.
-  aCookieAttributes.isSession =
-      GetExpiry(aCookieAttributes, aServerTime,
-                currentTimeInUsec / PR_USEC_PER_SEC, aFromHttp);
+  aCookieAttributes.isSession = GetExpiry(aCookieAttributes, aServerTime,
+                                          currentTimeInUsec / PR_USEC_PER_SEC);
   if (aStatus == STATUS_ACCEPT_SESSION) {
     // force lifetime to session. note that the expiration time, if set above,
     // will still apply.
     aCookieAttributes.isSession = true;
   }
 
   // reject cookie if it's over the size limit, per RFC2109
   if ((aCookieAttributes.name.Length() + aCookieAttributes.value.Length()) >
@@ -4231,23 +4230,17 @@ bool nsCookieService::CheckPrefixes(nsCo
       return false;
     }
   }
 
   return true;
 }
 
 bool nsCookieService::GetExpiry(nsCookieAttributes &aCookieAttributes,
-                                int64_t aServerTime, int64_t aCurrentTime,
-                                bool aFromHttp) {
-  // maxageCap is in seconds.
-  // Disabled for HTTP cookies.
-  int64_t maxageCap =
-      aFromHttp ? 0 : StaticPrefs::privacy_documentCookies_maxage();
-
+                                int64_t aServerTime, int64_t aCurrentTime) {
   /* Determine when the cookie should expire. This is done by taking the
    * difference between the server time and the time the server wants the cookie
    * to expire, and adding that difference to the client time. This localizes
    * the client time regardless of whether or not the TZ environment variable
    * was set on the client.
    *
    * Note: We need to consider accounting for network lag here, per RFC.
    */
@@ -4260,47 +4253,36 @@ bool nsCookieService::GetExpiry(nsCookie
 
     // default to session cookie if the conversion failed
     if (numInts != 1) {
       return true;
     }
 
     // if this addition overflows, expiryTime will be less than currentTime
     // and the cookie will be expired - that's okay.
-    if (maxageCap) {
-      aCookieAttributes.expiryTime = aCurrentTime + std::min(maxage, maxageCap);
-    } else {
-      aCookieAttributes.expiryTime = aCurrentTime + maxage;
-    }
+    aCookieAttributes.expiryTime = aCurrentTime + maxage;
 
     // check for expires attribute
   } else if (!aCookieAttributes.expires.IsEmpty()) {
     PRTime expires;
 
     // parse expiry time
     if (PR_ParseTimeString(aCookieAttributes.expires.get(), true, &expires) !=
         PR_SUCCESS) {
       return true;
     }
 
     // If set-cookie used absolute time to set expiration, and it can't use
     // client time to set expiration.
     // Because if current time be set in the future, but the cookie expire
     // time be set less than current time and more than server time.
     // The cookie item have to be used to the expired cookie.
-    if (maxageCap) {
-      aCookieAttributes.expiryTime = std::min(
-          expires / int64_t(PR_USEC_PER_SEC), aCurrentTime + maxageCap);
-    } else {
-      aCookieAttributes.expiryTime = expires / int64_t(PR_USEC_PER_SEC);
-    }
-
-    // default to session cookie if no attributes found.  Here we don't need to
-    // enforce the maxage cap, because session cookies are short-lived by
-    // definition.
+    aCookieAttributes.expiryTime = expires / int64_t(PR_USEC_PER_SEC);
+
+    // default to session cookie if no attributes found
   } else {
     return true;
   }
 
   return false;
 }
 
 /******************************************************************************
--- a/netwerk/cookie/nsCookieService.h
+++ b/netwerk/cookie/nsCookieService.h
@@ -339,17 +339,17 @@ class nsCookieService final : public nsI
   static bool ParseAttributes(nsDependentCString &aCookieHeader,
                               nsCookieAttributes &aCookie);
   bool RequireThirdPartyCheck();
   static bool CheckDomain(nsCookieAttributes &aCookie, nsIURI *aHostURI,
                           const nsCString &aBaseDomain, bool aRequireHostMatch);
   static bool CheckPath(nsCookieAttributes &aCookie, nsIURI *aHostURI);
   static bool CheckPrefixes(nsCookieAttributes &aCookie, bool aSecureRequest);
   static bool GetExpiry(nsCookieAttributes &aCookie, int64_t aServerTime,
-                        int64_t aCurrentTime, bool aFromHttp);
+                        int64_t aCurrentTime);
   void RemoveAllFromMemory();
   already_AddRefed<nsIArray> PurgeCookies(int64_t aCurrentTimeInUsec);
   bool FindCookie(const nsCookieKey &aKey, const nsCString &aHost,
                   const nsCString &aName, const nsCString &aPath,
                   nsListIter &aIter);
   bool FindSecureCookie(const nsCookieKey &aKey, nsCookie *aCookie);
   void FindStaleCookies(nsCookieEntry *aEntry, int64_t aCurrentTime,
                         bool aIsSecure, nsTArray<nsListIter> &aOutput,
deleted file mode 100644
--- a/netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js
+++ /dev/null
@@ -1,41 +0,0 @@
-function getCookieService() {
-  return Cc["@mozilla.org/cookiemanager;1"]
-           .getService(Ci.nsICookieManager);
-}
-
-function getCookies(cs) {
-  let cookies = [];
-  for (let cookie of cs.enumerator) {
-    cookies.push({
-      host: cookie.host,
-      path: cookie.path,
-      name: cookie.name,
-      value: cookie.value,
-      expires: cookie.expires,
-    });
-  }
-  return cookies;
-}
-
-function removeAllCookies(cs) {
-  cs.removeAll();
-}
-
-addMessageListener("init", _ => {
-  let cs = getCookieService();
-  removeAllCookies(cs);
-  sendAsyncMessage("init:return");
-});
-
-addMessageListener("getCookies", _ => {
-  let cs = getCookieService();
-  let cookies = getCookies(cs);
-  removeAllCookies(cs);
-  sendAsyncMessage("getCookies:return", { cookies });
-});
-
-addMessageListener("shutdown", _ => {
-  let cs = getCookieService();
-  removeAllCookies(cs);
-  sendAsyncMessage("shutdown:return");
-});
--- a/netwerk/test/mochitests/mochitest.ini
+++ b/netwerk/test/mochitests/mochitest.ini
@@ -3,33 +3,30 @@ support-files =
   method.sjs
   partial_content.sjs
   rel_preconnect.sjs
   user_agent.sjs
   user_agent_update.sjs
   set_cookie_xhr.sjs
   reset_cookie_xhr.sjs
   web_packaged_app.sjs
-  file_documentcookie_maxage_chromescript.js
   file_loadinfo_redirectchain.sjs
   file_1331680.js
   file_1503201.sjs
   file_iframe_allow_scripts.html
   file_iframe_allow_same_origin.html
   redirect_idn.html^headers^
   redirect_idn.html
   empty.html
   redirect.sjs
   origin_header.sjs
   origin_header_form_post.html
   origin_header_form_post_xorigin.html
-  subResources.sjs
 
 [test_arraybufferinputstream.html]
-[test_documentcookies_maxage.html]
 [test_idn_redirect.html]
 [test_loadinfo_redirectchain.html]
 [test_partially_cached_content.html]
 [test_rel_preconnect.html]
 [test_redirect_ref.html]
 [test_uri_scheme.html]
 [test_user_agent_overrides.html]
 [test_user_agent_updates.html]
deleted file mode 100644
--- a/netwerk/test/mochitests/subResources.sjs
+++ /dev/null
@@ -1,47 +0,0 @@
-const kTwoDays = 2 * 24 * 60 * 60;
-const kInTwoDays = (new Date().getTime() + kTwoDays * 1000);
-
-function getDateInTwoDays()
-{
-  let date2 = new Date(kInTwoDays);
-  let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
-  let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
-                "Nov", "Dec"];
-  let day = date2.getDate();
-  if (day < 10) {
-    day = "0" + day;
-  }
-  let month = months[date2.getMonth()];
-  let year = date2.getFullYear();
-  let hour = date2.getHours();
-  if (hour < 10) {
-    hour = "0" + hour;
-  }
-  let minute = date2.getMinutes();
-  if (minute < 10) {
-    minute = "0" + minute;
-  }
-  let second = date2.getSeconds();
-  if (second < 10) {
-    second = "0" + second;
-  }
-  return days[date2.getDay()] + ", " + day + "-" + month + "-" +
-         year + " " + hour + ":" + minute + ":" + second + " GMT";
-}
-
-function handleRequest(aRequest, aResponse) {
-  aResponse.setStatusLine(aRequest.httpVersion, 200);
-
-  let suffix = " path=/; domain:.mochi.test";
-
-  if (aRequest.queryString.includes("3")) {
-    aResponse.setHeader("Set-Cookie", "test3=value3; expires=Fri, 02-Jan-2037 00:00:01 GMT;" + suffix);
-  } else if (aRequest.queryString.includes("4")) {
-    let date2 = getDateInTwoDays();
-
-    aResponse.setHeader("Set-Cookie", "test4=value4; expires=" + date2 + ";" + suffix);
-  }
-
-  aResponse.setHeader("Content-Type", "text/javascript", false);
-  aResponse.write("42;");
-}
deleted file mode 100644
--- a/netwerk/test/mochitests/test_documentcookies_maxage.html
+++ /dev/null
@@ -1,150 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
--->
-<head>
-  <title>Test for document.cookie max-age pref</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-
-<script type="text/javascript">
-const kTwoDays = 2 * 24 * 60 * 60;
-const kSevenDays = 7 * 24 * 60 * 60;
-const kInTwoDays = (new Date().getTime() + kTwoDays * 1000);
-const kInSevenDays = (new Date().getTime() + kSevenDays * 1000);
-const kScriptURL = SimpleTest.getTestFileURL("file_documentcookie_maxage_chromescript.js");
-
-let gScript;
-
-function getDateInTwoDays()
-{
-  let date2 = new Date(kInTwoDays);
-  let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
-  let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
-                "Nov", "Dec"];
-  let day = date2.getDate();
-  if (day < 10) {
-    day = "0" + day;
-  }
-  let month = months[date2.getMonth()];
-  let year = date2.getFullYear();
-  let hour = date2.getHours();
-  if (hour < 10) {
-    hour = "0" + hour;
-  }
-  let minute = date2.getMinutes();
-  if (minute < 10) {
-    minute = "0" + minute;
-  }
-  let second = date2.getSeconds();
-  if (second < 10) {
-    second = "0" + second;
-  }
-  return days[date2.getDay()] + ", " + day + "-" + month + "-" +
-         year + " " + hour + ":" + minute + ":" + second + " GMT";
-}
-
-function dotest()
-{
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPrefEnv({
-    set: [["privacy.documentCookies.maxage", kSevenDays]],
-  }).then(_ => {
-    gScript = SpecialPowers.loadChromeScript(kScriptURL);
-
-    return new Promise(resolve => {
-      gScript.addMessageListener("init:return", resolve);
-      gScript.sendAsyncMessage("init");
-    });
-  }).then(_ => {
-    let date2 = getDateInTwoDays();
-
-    document.cookie = "test1=value1; expires=Fri, 02-Jan-2037 00:00:01 GMT;";
-    document.cookie = "test2=value2; expires=" + date2 + ";";
-
-    return fetch("subResources.sjs?3");
-  }).then(_ => {
-    return fetch("subResources.sjs?4");
-  }).then(_ => {
-    return new Promise(resolve => {
-      gScript.addMessageListener("getCookies:return", resolve);
-      gScript.sendAsyncMessage("getCookies");
-    });
-  }).then(_ => {
-    for (let cookie of _.cookies) {
-      switch (cookie.name) {
-        case "test1": {
-          is(cookie.value, "value1", "The correct value expected");
-          let d = new Date(cookie.expires * 1000);
-          let [day, month, year] = [d.getDate(), d.getMonth(), d.getFullYear()];
-          let d2 = new Date(kInSevenDays);
-          let [day2, month2, year2] = [d2.getDate(), d2.getMonth(), d2.getFullYear()];
-          is(day, day2, "Days match");
-          is(month, month2, "Months match");
-          is(year, year2, "Years match");
-        }
-        break;
-
-      case "test2": {
-          is(cookie.value, "value2", "The correct value expected");
-          let d = new Date(cookie.expires * 1000);
-          let [day, month, year] = [d.getDate(), d.getMonth(), d.getFullYear()];
-          let d2 = new Date(kInTwoDays);
-          let [day2, month2, year2] = [d2.getDate(), d2.getMonth(), d2.getFullYear()];
-          is(day, day2, "Days match");
-          is(month, month2, "Months match");
-          is(year, year2, "Years match");
-        }
-        break;
-
-      case "test3": {
-          is(cookie.value, "value3", "The correct value expected");
-          let d = new Date(cookie.expires * 1000);
-          let [day, month, year] = [d.getDate(), d.getMonth(), d.getFullYear()];
-          let d2 = new Date("Fri, 02 Jan 2037 00:00:01 GMT");
-          let [day2, month2, year2] = [d2.getDate(), d2.getMonth(), d2.getFullYear()];
-          is(day, day2, "Days match");
-          is(month, month2, "Months match");
-          is(year, year2, "Years match");
-        }
-        break;
-
-      case "test4": {
-          is(cookie.value, "value4", "The correct value expected");
-          let d = new Date(cookie.expires * 1000);
-          let [day, month, year] = [d.getDate(), d.getMonth(), d.getFullYear()];
-          let d2 = new Date(kInTwoDays);
-          let [day2, month2, year2] = [d2.getDate(), d2.getMonth(), d2.getFullYear()];
-          is(day, day2, "Days match");
-          is(month, month2, "Months match");
-          is(year, year2, "Years match");
-        }
-        break;
-
-      default:
-        ok(false, "Unexpected cookie found!");
-        break;
-      }
-    }
-
-    return new Promise(resolve => {
-      gScript.addMessageListener("shutdown:return", resolve);
-      gScript.sendAsyncMessage("shutdown");
-    });
-  }).then(finish);
-}
-
-function finish()
-{
-  SimpleTest.finish();
-}
-</script>
-</head>
-<body onload="dotest();">
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-</pre>
-</body>
-</html>
-