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

Unified Diff: third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp

Issue 1526903002: Make FetchResponseData::createCORSFilteredResponse() consult isForbiddenResponseHeaderName() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
index 9f8ab7728117341d6ce41c121546e34e36a37c06..8c866e05c5c9155c45675f967fe45f5af94bbb26 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
@@ -34,6 +34,26 @@ public:
}
};
+TEST_F(FetchResponseDataTest, HeaderList)
+{
+ FetchResponseData* responseData = createInternalResponse();
+
+ Vector<String> setCookieValues;
+ responseData->headerList()->getAll("set-cookie", setCookieValues);
+ ASSERT_EQ(1U, setCookieValues.size());
+ EXPECT_EQ("foo", setCookieValues[0]);
+
+ Vector<String> barValues;
+ responseData->headerList()->getAll("bar", barValues);
+ ASSERT_EQ(1U, barValues.size());
+ EXPECT_EQ("bar", barValues[0]);
+
+ Vector<String> cacheControlValues;
+ responseData->headerList()->getAll("cache-control", cacheControlValues);
+ ASSERT_EQ(1U, cacheControlValues.size());
+ EXPECT_EQ("no-cache", cacheControlValues[0]);
+}
+
TEST_F(FetchResponseDataTest, ToWebServiceWorkerDefaultType)
{
WebServiceWorkerResponse webResponse;
@@ -44,6 +64,24 @@ TEST_F(FetchResponseDataTest, ToWebServiceWorkerDefaultType)
CheckHeaders(webResponse);
}
+TEST_F(FetchResponseDataTest, BasicFilter)
+{
+ FetchResponseData* internalResponse = createInternalResponse();
+ FetchResponseData* basicResponseData = internalResponse->createBasicFilteredResponse();
+
+ EXPECT_FALSE(basicResponseData->headerList()->has("set-cookie"));
+
+ Vector<String> barValues;
+ basicResponseData->headerList()->getAll("bar", barValues);
+ ASSERT_EQ(1U, barValues.size());
+ EXPECT_EQ("bar", barValues[0]);
+
+ Vector<String> cacheControlValues;
+ basicResponseData->headerList()->getAll("cache-control", cacheControlValues);
+ ASSERT_EQ(1U, cacheControlValues.size());
+ EXPECT_EQ("no-cache", cacheControlValues[0]);
+}
+
TEST_F(FetchResponseDataTest, ToWebServiceWorkerBasicType)
{
WebServiceWorkerResponse webResponse;
@@ -55,6 +93,36 @@ TEST_F(FetchResponseDataTest, ToWebServiceWorkerBasicType)
CheckHeaders(webResponse);
}
+TEST_F(FetchResponseDataTest, CORSFilter)
+{
+ FetchResponseData* internalResponse = createInternalResponse();
+ FetchResponseData* corsResponseData = internalResponse->createCORSFilteredResponse();
+
+ EXPECT_FALSE(corsResponseData->headerList()->has("set-cookie"));
+
+ EXPECT_FALSE(corsResponseData->headerList()->has("bar"));
+
+ Vector<String> cacheControlValues;
+ corsResponseData->headerList()->getAll("cache-control", cacheControlValues);
+ ASSERT_EQ(1U, cacheControlValues.size());
+ EXPECT_EQ("no-cache", cacheControlValues[0]);
+}
+
+TEST_F(FetchResponseDataTest, CORSFilterOnResponseWithAccessControlExposeHeaders)
+{
+ FetchResponseData* internalResponse = createInternalResponse();
+ internalResponse->headerList()->append("access-control-expose-headers", "set-cookie, bar");
+
+ FetchResponseData* corsResponseData = internalResponse->createCORSFilteredResponse();
+
+ EXPECT_FALSE(corsResponseData->headerList()->has("set-cookie"));
+
+ Vector<String> barValues;
+ corsResponseData->headerList()->getAll("bar", barValues);
+ ASSERT_EQ(1U, barValues.size());
+ EXPECT_EQ("bar", barValues[0]);
+}
+
TEST_F(FetchResponseDataTest, ToWebServiceWorkerCORSType)
{
WebServiceWorkerResponse webResponse;
@@ -66,6 +134,28 @@ TEST_F(FetchResponseDataTest, ToWebServiceWorkerCORSType)
CheckHeaders(webResponse);
}
+TEST_F(FetchResponseDataTest, OpaqueFilter)
+{
+ FetchResponseData* internalResponse = createInternalResponse();
+ FetchResponseData* opaqueResponseData = internalResponse->createOpaqueFilteredResponse();
+
+ EXPECT_FALSE(opaqueResponseData->headerList()->has("set-cookie"));
+ EXPECT_FALSE(opaqueResponseData->headerList()->has("bar"));
+ EXPECT_FALSE(opaqueResponseData->headerList()->has("cache-control"));
+}
+
+TEST_F(FetchResponseDataTest, OpaqueFilterOnResponseWithAccessControlExposeHeaders)
+{
+ FetchResponseData* internalResponse = createInternalResponse();
+ internalResponse->headerList()->append("access-control-expose-headers", "set-cookie, bar");
+
+ FetchResponseData* opaqueResponseData = internalResponse->createOpaqueFilteredResponse();
+
+ EXPECT_FALSE(opaqueResponseData->headerList()->has("set-cookie"));
+ EXPECT_FALSE(opaqueResponseData->headerList()->has("bar"));
+ EXPECT_FALSE(opaqueResponseData->headerList()->has("cache-control"));
+}
+
TEST_F(FetchResponseDataTest, ToWebServiceWorkerOpaqueType)
{
WebServiceWorkerResponse webResponse;
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698