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

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

Issue 2860093003: Implement device-ram client hints header (Closed)
Patch Set: Created 3 years, 7 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 96ab8d11ce312f6a715b734d6a92788f2519922d..c829a04f5375a7ab903282bb03ba27e9d0feee8a 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp
@@ -521,6 +521,18 @@ class FrameFetchContextHintsTest : public FrameFetchContextTest {
}
};
+TEST_F(FrameFetchContextHintsTest, MonitorDeviceRamHints) {
panicker 2017/05/05 17:19:30 Also add a unittest with different values of physi
fmeawad 2017/05/23 20:50:54 Done.
+ ExpectHeader("http://www.example.com/1.gif", "device-ram", false, "");
+ ClientHintsPreferences preferences;
+ preferences.SetShouldSendDeviceRam(true);
+ document->GetClientHintsPreferences().UpdateFrom(preferences);
+ ExpectHeader("http://www.example.com/1.gif", "device-ram", true, "4");
+ dummy_page_holder->GetPage().SetDeviceScaleFactorDeprecated(2.5);
+ ExpectHeader("http://www.example.com/1.gif", "device-ram", true, "2.5");
+ ExpectHeader("http://www.example.com/1.gif", "Width", false, "");
+ ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
+}
+
TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) {
ExpectHeader("http://www.example.com/1.gif", "DPR", false, "");
ClientHintsPreferences preferences;
@@ -561,15 +573,18 @@ TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints) {
}
TEST_F(FrameFetchContextHintsTest, MonitorAllHints) {
+ ExpectHeader("http://www.example.com/1.gif", "device-ram", false, "");
ExpectHeader("http://www.example.com/1.gif", "DPR", false, "");
ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
ExpectHeader("http://www.example.com/1.gif", "Width", false, "");
ClientHintsPreferences preferences;
+ preferences.SetShouldSendDeviceRam(true);
preferences.SetShouldSendDPR(true);
preferences.SetShouldSendResourceWidth(true);
preferences.SetShouldSendViewportWidth(true);
document->GetClientHintsPreferences().UpdateFrom(preferences);
+ ExpectHeader("http://www.example.com/1.gif", "device-ram", true, "4");
ExpectHeader("http://www.example.com/1.gif", "DPR", true, "1");
ExpectHeader("http://www.example.com/1.gif", "Width", true, "400", 400);
ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500");

Powered by Google App Engine
This is Rietveld 408576698