-
-
Save Trikolon/9f216496e1d6a3ac9a5cf3d6c80b0267 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/browser/base/content/test/sanitize/browser_sanitize-timespans.js b/browser/base/content/test/sanitize/browser_sanitize-timespans.js | |
--- a/browser/base/content/test/sanitize/browser_sanitize-timespans.js | |
+++ b/browser/base/content/test/sanitize/browser_sanitize-timespans.js | |
@@ -1187,6 +1187,10 @@ async function setupDownloads() { | |
); | |
} | |
+async function setupCookies() { | |
+ | |
+} | |
+ | |
/** | |
* Checks to see if the downloads with the specified id exists. | |
* | |
diff --git a/netwerk/cookie/CookieService.cpp b/netwerk/cookie/CookieService.cpp | |
--- a/netwerk/cookie/CookieService.cpp | |
+++ b/netwerk/cookie/CookieService.cpp | |
@@ -808,7 +808,25 @@ CookieService::Add(const nsACString& aHo | |
} | |
return AddNative(aHost, aPath, aName, aValue, aIsSecure, aIsHttpOnly, | |
- aIsSession, aExpiry, &attrs, aSameSite, aSchemeMap); | |
+ aIsSession, aExpiry, &attrs, aSameSite, aSchemeMap, -1); | |
+} | |
+ | |
+NS_IMETHODIMP | |
+CookieService::AddForTest(const nsACString& aHost, const nsACString& aPath, | |
+ const nsACString& aName, const nsACString& aValue, | |
+ bool aIsSecure, bool aIsHttpOnly, bool aIsSession, | |
+ int64_t aExpiry, JS::Handle<JS::Value> aOriginAttributes, | |
+ int32_t aSameSite, nsICookie::schemeType aSchemeMap, | |
+ int64_t aCreationTimeOverrideUsec, | |
+ JSContext* aCx) { | |
+ OriginAttributes attrs; | |
+ | |
+ if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { | |
+ return NS_ERROR_INVALID_ARG; | |
+ } | |
+ | |
+ return AddNative(aHost, aPath, aName, aValue, aIsSecure, aIsHttpOnly, | |
+ aIsSession, aExpiry, &attrs, aSameSite, aSchemeMap, aCreationTimeOverrideUsec); | |
} | |
NS_IMETHODIMP_(nsresult) | |
@@ -816,7 +834,7 @@ CookieService::AddNative(const nsACStrin | |
const nsACString& aName, const nsACString& aValue, | |
bool aIsSecure, bool aIsHttpOnly, bool aIsSession, | |
int64_t aExpiry, OriginAttributes* aOriginAttributes, | |
- int32_t aSameSite, nsICookie::schemeType aSchemeMap) { | |
+ int32_t aSameSite, nsICookie::schemeType aSchemeMap, int64_t aCreationTimeOverrideUsec) { | |
if (NS_WARN_IF(!aOriginAttributes)) { | |
return NS_ERROR_FAILURE; | |
} | |
@@ -836,7 +854,14 @@ CookieService::AddNative(const nsACStrin | |
rv = CookieCommons::GetBaseDomainFromHost(mTLDService, host, baseDomain); | |
NS_ENSURE_SUCCESS(rv, rv); | |
- int64_t currentTimeInUsec = PR_Now(); | |
+ // Test callers may override creation time. | |
+ int64_t currentTimeInUsec; | |
+ if(aCreationTimeOverrideUsec > 0) { | |
+ currentTimeInUsec = aCreationTimeOverrideUsec; | |
+ } else { | |
+ currentTimeInUsec = PR_Now(); | |
+ } | |
+ | |
CookieKey key = CookieKey(baseDomain, *aOriginAttributes); | |
CookieStruct cookieData(nsCString(aName), nsCString(aValue), nsCString(aHost), | |
diff --git a/netwerk/cookie/nsICookieManager.idl b/netwerk/cookie/nsICookieManager.idl | |
--- a/netwerk/cookie/nsICookieManager.idl | |
+++ b/netwerk/cookie/nsICookieManager.idl | |
@@ -131,6 +131,20 @@ interface nsICookieManager : nsISupports | |
in int32_t aSameSite, | |
in nsICookie_schemeType aSchemeMap); | |
+ [implicit_jscontext] | |
+ void addForTest(in AUTF8String aHost, | |
+ in AUTF8String aPath, | |
+ in ACString aName, | |
+ in AUTF8String aValue, | |
+ in boolean aIsSecure, | |
+ in boolean aIsHttpOnly, | |
+ in boolean aIsSession, | |
+ in int64_t aExpiry, | |
+ in jsval aOriginAttributes, | |
+ in int32_t aSameSite, | |
+ in nsICookie_schemeType aSchemeMap, | |
+ in int64_t aCreationTimeOverrideUsec); | |
+ | |
[notxpcom] | |
nsresult addNative(in AUTF8String aHost, | |
in AUTF8String aPath, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment