diff --git a/netwerk/cookie/Cookie.cpp b/netwerk/cookie/Cookie.cpp index ae9ccdad3a96..e83a2fcae212 100644 --- a/netwerk/cookie/Cookie.cpp +++ b/netwerk/cookie/Cookie.cpp @@ -148,6 +148,10 @@ NS_IMETHODIMP Cookie::GetSameSite(int32_t* aSameSite) { } return NS_OK; } +NS_IMETHODIMP Cookie::GetSchemeMap(nsICookie::schemeType* aSchemeMap) { + *aSchemeMap = static_cast(SchemeMap()); + return NS_OK; +} NS_IMETHODIMP Cookie::GetOriginAttributes(JSContext* aCx, JS::MutableHandle aVal) { diff --git a/netwerk/cookie/Cookie.h b/netwerk/cookie/Cookie.h index af410cdb8d45..b6654df3101d 100644 --- a/netwerk/cookie/Cookie.h +++ b/netwerk/cookie/Cookie.h @@ -84,6 +84,7 @@ class Cookie final : public nsICookie { } inline int32_t SameSite() const { return mData.sameSite(); } inline int32_t RawSameSite() const { return mData.rawSameSite(); } + inline uint8_t SchemeMap() const { return mData.schemeMap(); } // setters inline void SetExpiry(int64_t aExpiry) { mData.expiry() = aExpiry; } diff --git a/netwerk/cookie/CookieLogging.cpp b/netwerk/cookie/CookieLogging.cpp index 7e68366b1689..d0e47b0cea6f 100644 --- a/netwerk/cookie/CookieLogging.cpp +++ b/netwerk/cookie/CookieLogging.cpp @@ -131,6 +131,13 @@ void CookieLogging::LogCookie(Cookie* aCookie) { ("sameSite: %s - rawSameSite: %s\n", SameSiteToString(aCookie->SameSite()), SameSiteToString(aCookie->RawSameSite()))); + MOZ_LOG( + gCookieLog, LogLevel::Debug, + ("schemeMap %d (http: %s | https: %s | file: %s)\n", + aCookie->SchemeMap(), + (aCookie->SchemeMap() & nsICookie::SCHEME_HTTP ? "true" : "false"), + (aCookie->SchemeMap() & nsICookie::SCHEME_HTTPS ? "true" : "false"), + (aCookie->SchemeMap() & nsICookie::SCHEME_FILE ? "true" : "false"))); nsAutoCString suffix; aCookie->OriginAttributesRef().CreateSuffix(suffix); diff --git a/netwerk/cookie/CookiePersistentStorage.cpp b/netwerk/cookie/CookiePersistentStorage.cpp index 7986a714186d..901ef3a3cd1a 100644 --- a/netwerk/cookie/CookiePersistentStorage.cpp +++ b/netwerk/cookie/CookiePersistentStorage.cpp @@ -1686,9 +1686,9 @@ UniquePtr CookiePersistentStorage::GetCookieFromRow( int32_t rawSameSite = aRow->AsInt32(IDX_RAW_SAME_SITE); // Create a new constCookie and assign the data. - return MakeUnique(name, value, host, path, expiry, lastAccessed, - creationTime, isHttpOnly, false, isSecure, - sameSite, rawSameSite); + return MakeUnique( + name, value, host, path, expiry, lastAccessed, creationTime, isHttpOnly, + false, isSecure, sameSite, rawSameSite, nsICookie::SCHEME_UNSET); } void CookiePersistentStorage::EnsureReadComplete() { diff --git a/netwerk/cookie/CookieService.cpp b/netwerk/cookie/CookieService.cpp index 514f4d0dd9de..249d307390ac 100644 --- a/netwerk/cookie/CookieService.cpp +++ b/netwerk/cookie/CookieService.cpp @@ -732,7 +732,7 @@ CookieService::AddNative(const nsACString& aHost, const nsACString& aPath, nsCString(aPath), aExpiry, currentTimeInUsec, Cookie::GenerateUniqueCreationTime(currentTimeInUsec), aIsHttpOnly, aIsSession, aIsSecure, aSameSite, - aSameSite); + aSameSite, nsICookie::SCHEME_UNSET); RefPtr cookie = Cookie::Create(cookieData, key.mOriginAttributes); MOZ_ASSERT(cookie); diff --git a/netwerk/cookie/nsICookie.idl b/netwerk/cookie/nsICookie.idl index 7478a39ddbbb..e50576d507f9 100644 --- a/netwerk/cookie/nsICookie.idl +++ b/netwerk/cookie/nsICookie.idl @@ -119,4 +119,21 @@ interface nsICookie : nsISupports { * - SAMESITE_STRICT - the SameSite attribute is present and strict */ readonly attribute int32_t sameSite; + + /** + * The list of possible schemes of cookies. It's a bitmap because a cookie + * can be set on HTTP and HTTPS. At the moment, we treat it as the same + * cookie. + */ + cenum schemeType : 8 { + SCHEME_UNSET = 0x00, + SCHEME_HTTP = 0x01, + SCHEME_HTTPS = 0x02, + SCHEME_FILE = 0x04, + }; + + /** + * Bitmap of schemes. + */ + readonly attribute nsICookie_schemeType schemeMap; }; diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 69b9af45b0a5..1a11085475d1 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -436,6 +436,7 @@ struct CookieStruct bool isSecure; int32_t sameSite; int32_t rawSameSite; + uint8_t schemeMap; }; struct DocumentChannelCreationArgs {