diff --git a/CLOBBER b/CLOBBER index d4cdfaff33de..2cdfae55cfeb 100644 --- a/CLOBBER +++ b/CLOBBER @@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -Merge day clobber \ No newline at end of file +Bug 1280590 - xpcshell failure in windows7 diff --git a/browser/components/sessionstore/SessionCookies.jsm b/browser/components/sessionstore/SessionCookies.jsm index 01da2bbc92d0..347ebdbf1a56 100644 --- a/browser/components/sessionstore/SessionCookies.jsm +++ b/browser/components/sessionstore/SessionCookies.jsm @@ -115,6 +115,7 @@ 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; let cookieObj = { @@ -122,7 +123,7 @@ var SessionCookiesInternal = { path: cookie.path || "", name: cookie.name || "" }; - if (!Services.cookies.cookieExists(cookieObj)) { + if (!Services.cookies.cookieExists(cookieObj, cookie.originAttributes || {})) { Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "", cookie.value, !!cookie.secure, !!cookie.httponly, /* isSession = */ true, expiry, cookie.originAttributes || {}); diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index cc97c19daa8a..b867c4ab21df 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -4356,10 +4356,42 @@ nsCookieService::PurgeCookies(int64_t aCurrentTimeInUsec) // find whether a given cookie has been previously set. this is provided by the // nsICookieManager2 interface. NS_IMETHODIMP -nsCookieService::CookieExists(nsICookie2 *aCookie, - bool *aFoundCookie) +nsCookieService::CookieExists(nsICookie2* aCookie, + JS::HandleValue aOriginAttributes, + JSContext* aCx, + uint8_t aArgc, + bool* aFoundCookie) { NS_ENSURE_ARG_POINTER(aCookie); + NS_ENSURE_ARG_POINTER(aCx); + NS_ENSURE_ARG_POINTER(aFoundCookie); + + MOZ_ASSERT(aArgc == 0 || aArgc == 1); + + nsresult rv; + NeckoOriginAttributes attrs; + + if (aArgc == 1) { + rv = InitializeOriginAttributes(&attrs, + aOriginAttributes, + aCx, + aArgc, + u"nsICookieManager2.cookieExists()", + u"2"); + NS_ENSURE_SUCCESS(rv, rv); + } + + return CookieExistsNative(aCookie, &attrs, aFoundCookie); +} + +NS_IMETHODIMP_(nsresult) +nsCookieService::CookieExistsNative(nsICookie2* aCookie, + NeckoOriginAttributes* aOriginAttributes, + bool* aFoundCookie) +{ + NS_ENSURE_ARG_POINTER(aCookie); + NS_ENSURE_ARG_POINTER(aOriginAttributes); + NS_ENSURE_ARG_POINTER(aFoundCookie); if (!mDBState) { NS_WARNING("No DBState! Profile already closed?"); @@ -4379,7 +4411,8 @@ nsCookieService::CookieExists(nsICookie2 *aCookie, NS_ENSURE_SUCCESS(rv, rv); nsListIter iter; - *aFoundCookie = FindCookie(DEFAULT_APP_KEY(baseDomain), host, name, path, iter); + *aFoundCookie = FindCookie(nsCookieKey(baseDomain, *aOriginAttributes), + host, name, path, iter); return NS_OK; } diff --git a/netwerk/cookie/nsICookieManager2.idl b/netwerk/cookie/nsICookieManager2.idl index 98071890d408..f20618bfae91 100644 --- a/netwerk/cookie/nsICookieManager2.idl +++ b/netwerk/cookie/nsICookieManager2.idl @@ -76,11 +76,23 @@ interface nsICookieManager2 : nsICookieManager * * @param aCookie * the cookie to look for + * @param aOriginAttributes + * nsICookie2 contains an originAttributes but if nsICookie2 is + * implemented in JS, we can't retrieve its originAttributes because + * the getter is marked [implicit_jscontext]. This optional parameter + * is a workaround. * * @return true if a cookie was found which matches the host, path, and name * fields of aCookie */ - boolean cookieExists(in nsICookie2 aCookie); + [implicit_jscontext, optional_argc] + boolean cookieExists(in nsICookie2 aCookie, + [optional] in jsval aOriginAttributes); + + [notxpcom] + nsresult cookieExistsNative(in nsICookie2 aCookie, + in NeckoOriginAttributesPtr aOriginAttributes, + out boolean aExists); /** * Count how many cookies exist within the base domain of 'aHost'. diff --git a/netwerk/test/TestCookie.cpp b/netwerk/test/TestCookie.cpp index 513ed77ce824..f1b259c2c985 100644 --- a/netwerk/test/TestCookie.cpp +++ b/netwerk/test/TestCookie.cpp @@ -757,9 +757,9 @@ main(int32_t argc, char *argv[]) uint32_t hostCookies = 0; rv[8] = NS_SUCCEEDED(cookieMgr2->CountCookiesFromHost(NS_LITERAL_CSTRING("cookiemgr.test"), &hostCookies)) && hostCookies == 2; - // check CookieExists() using the third cookie + // check CookieExistsNative() using the third cookie bool found; - rv[9] = NS_SUCCEEDED(cookieMgr2->CookieExists(newDomainCookie, &found)) && found; + rv[9] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)) && found; // remove the cookie, block it, and ensure it can't be added again @@ -768,7 +768,7 @@ main(int32_t argc, char *argv[]) NS_LITERAL_CSTRING("/rabbit"), // path true, // is blocked &attrs)); // originAttributes - rv[11] = NS_SUCCEEDED(cookieMgr2->CookieExists(newDomainCookie, &found)) && !found; + rv[11] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)) && !found; rv[12] = NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"), // domain NS_LITERAL_CSTRING("/rabbit"), // path NS_LITERAL_CSTRING("test3"), // name @@ -778,14 +778,14 @@ main(int32_t argc, char *argv[]) true, // is session INT64_MIN, // expiry time &attrs)); // originAttributes - rv[13] = NS_SUCCEEDED(cookieMgr2->CookieExists(newDomainCookie, &found)) && !found; + rv[13] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)) && !found; // sleep four seconds, to make sure the second cookie has expired PR_Sleep(4 * PR_TicksPerSecond()); - // check that both CountCookiesFromHost() and CookieExists() count the + // check that both CountCookiesFromHost() and CookieExistsNative() count the // expired cookie rv[14] = NS_SUCCEEDED(cookieMgr2->CountCookiesFromHost(NS_LITERAL_CSTRING("cookiemgr.test"), &hostCookies)) && hostCookies == 2; - rv[15] = NS_SUCCEEDED(cookieMgr2->CookieExists(expiredCookie, &found)) && found; + rv[15] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(expiredCookie, &attrs, &found)) && found; // double-check RemoveAll() using the enumerator rv[16] = NS_SUCCEEDED(cookieMgr->RemoveAll()); rv[17] = NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))) &&