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

Side by Side Diff: Source/core/loader/FrameFetchContextTest.cpp

Issue 1183233002: Split RW hint into Width and Viewport-Width (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed and added layout tests Created 5 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 unified diff | Download patch
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015, Google Inc. All rights reserved. 2 * Copyright (c) 2015, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) 257 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints)
258 { 258 {
259 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 259 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
260 ClientHintsPreferences preferences; 260 ClientHintsPreferences preferences;
261 preferences.setShouldSendDPR(true); 261 preferences.setShouldSendDPR(true);
262 document->setClientHintsPreferences(preferences); 262 document->setClientHintsPreferences(preferences);
263 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 263 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
264 dummyPageHolder->page().setDeviceScaleFactor(2.5); 264 dummyPageHolder->page().setDeviceScaleFactor(2.5);
265 expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5"); 265 expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5");
266 expectHeader("http://www.example.com/1.gif", "RW", false, ""); 266 expectHeader("http://www.example.com/1.gif", "Width", false, "");
267 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
267 } 268 }
268 269
269 TEST_F(FrameFetchContextHintsTest, MonitorRWHints) 270 TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints)
270 { 271 {
271 expectHeader("http://www.example.com/1.gif", "RW", false, ""); 272 expectHeader("http://www.example.com/1.gif", "Width", false, "");
272 ClientHintsPreferences preferences; 273 ClientHintsPreferences preferences;
273 preferences.setShouldSendRW(true); 274 preferences.setShouldSendResourceWidth(true);
274 document->setClientHintsPreferences(preferences); 275 document->setClientHintsPreferences(preferences);
275 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); 276 expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500);
276 dummyPageHolder->frameView().setLayoutSizeFixedToFrameSize(false); 277 expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666) ;
277 dummyPageHolder->frameView().setLayoutSize(IntSize(800, 800));
278 expectHeader("http://www.example.com/1.gif", "RW", true, "800");
279 expectHeader("http://www.example.com/1.gif", "RW", true, "667", 666.6666);
280 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 278 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
281 } 279 }
282 280
283 TEST_F(FrameFetchContextHintsTest, MonitorBothHints) 281 TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints)
282 {
283 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
284 ClientHintsPreferences preferences;
285 preferences.setShouldSendViewportWidth(true);
286 document->setClientHintsPreferences(preferences);
287 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500");
288 dummyPageHolder->frameView().setLayoutSizeFixedToFrameSize(false);
289 dummyPageHolder->frameView().setLayoutSize(IntSize(800, 800));
290 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800");
291 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800", 666.6666);
292 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
293 }
294
295 TEST_F(FrameFetchContextHintsTest, MonitorAllHints)
284 { 296 {
285 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 297 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
286 expectHeader("http://www.example.com/1.gif", "RW", false, ""); 298 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
299 expectHeader("http://www.example.com/1.gif", "Width", false, "");
287 300
288 ClientHintsPreferences preferences; 301 ClientHintsPreferences preferences;
289 preferences.setShouldSendDPR(true); 302 preferences.setShouldSendDPR(true);
290 preferences.setShouldSendRW(true); 303 preferences.setShouldSendResourceWidth(true);
304 preferences.setShouldSendViewportWidth(true);
291 document->setClientHintsPreferences(preferences); 305 document->setClientHintsPreferences(preferences);
292 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 306 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
293 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); 307 expectHeader("http://www.example.com/1.gif", "Width", true, "400", 400);
308 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500");
294 } 309 }
295 310
296 } // namespace 311 } // namespace
297 312
OLDNEW
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698