Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp

Issue 2080653002: SameSite: Correctly set requests' initiator for new tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: firstPartyForCookiesFix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
index 8e8aa81b628772857b19df076b07cbf2a646fc14..f65305645c75f6e3451fdfc75b14f5bf6de59ac0 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
@@ -43,6 +43,7 @@
#include "core/testing/DummyPageHolder.h"
#include "platform/network/ResourceRequest.h"
#include "platform/weborigin/KURL.h"
+#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/WebAddressSpace.h"
#include "public/platform/WebCachePolicy.h"
#include "public/platform/WebInsecureRequestPolicy.h"
@@ -636,4 +637,32 @@ TEST_F(FrameFetchContextTest, SetIsExternalRequestForLocalDocument)
}
}
+TEST_F(FrameFetchContextTest, PopulateRequestorData)
+{
+ FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
+ KURL documentURL(ParsedURLString, "http://example.com/document.html");
+ document->setURL(documentURL);
+ document->setSecurityOrigin(SecurityOrigin::create(documentURL));
+
+ {
+ ResourceRequest request("http://not-example.com/");
+ request.setFrameType(WebURLRequest::FrameTypeNone);
+
+ fetchContext->populateRequestorDataIfNecessary(request);
+
+ EXPECT_TRUE(SecurityOrigin::create(document->url())->isSameSchemeHostPortAndSuborigin(request.requestorOrigin().get()));
+ EXPECT_EQ(document->firstPartyForCookies(), request.firstPartyForCookies());
+ }
+
+ {
+ ResourceRequest request("http://not-example.com/");
+ request.setFrameType(WebURLRequest::FrameTypeTopLevel);
+
+ fetchContext->populateRequestorDataIfNecessary(request);
+
+ EXPECT_TRUE(request.requestorOrigin()->isUnique());
+ EXPECT_EQ(KURL(), request.firstPartyForCookies());
+ }
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698