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

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

Issue 2769033004: Should reset "Save-Data" header on all kinds of reloads (Closed)
Patch Set: test Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.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/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 f55e46de1bc8e156184cf291981cdfc8847e7ba9..008bad659ad6836f9f8f00fb3825359fe91dd0a1 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
@@ -696,6 +696,7 @@ TEST_F(FrameFetchContextTest, ModifyPriorityForLowPriorityIframes) {
ResourceLoadPriorityMedium));
}
+// Tests if "Save-Data" header is correctly added on the first load and reload.
TEST_F(FrameFetchContextTest, EnableDataSaver) {
Settings* settings = document->frame()->settings();
settings->setDataSaverEnabled(true);
@@ -709,12 +710,36 @@ TEST_F(FrameFetchContextTest, EnableDataSaver) {
EXPECT_EQ("on", resourceRequest.httpHeaderField("Save-Data"));
}
+// Tests if "Save-Data" header is not added when the data saver is disabled.
TEST_F(FrameFetchContextTest, DisabledDataSaver) {
ResourceRequest resourceRequest("http://www.example.com");
fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data"));
}
+// Tests if reload variants can reflect the current data saver setting.
+TEST_F(FrameFetchContextTest, ChangeDataSaverConfig) {
+ Settings* settings = document->frame()->settings();
+ settings->setDataSaverEnabled(true);
+ ResourceRequest resourceRequest("http://www.example.com");
+ fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
+ EXPECT_EQ("on", resourceRequest.httpHeaderField("Save-Data"));
+
+ settings->setDataSaverEnabled(false);
+ document->loader()->setLoadType(FrameLoadTypeReloadMainResource);
+ fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
+ EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data"));
+
+ settings->setDataSaverEnabled(true);
+ fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
+ EXPECT_EQ("on", resourceRequest.httpHeaderField("Save-Data"));
+
+ settings->setDataSaverEnabled(false);
+ document->loader()->setLoadType(FrameLoadTypeReloadMainResource);
+ fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
+ EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data"));
+}
+
// Tests that the embedder gets correct notification when a resource is loaded
// from the memory cache.
TEST_F(FrameFetchContextMockedLocalFrameClientTest,
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698