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

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

Issue 1287783003: Make ClientHintsPreferences class work like a class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | Source/core/loader/FrameLoader.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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 RefPtrWillBePersistent<DocumentLoader> documentLoader; 267 RefPtrWillBePersistent<DocumentLoader> documentLoader;
268 RefPtrWillBePersistent<Document> document; 268 RefPtrWillBePersistent<Document> document;
269 Persistent<FrameFetchContext> fetchContext; 269 Persistent<FrameFetchContext> fetchContext;
270 }; 270 };
271 271
272 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) 272 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints)
273 { 273 {
274 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 274 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
275 ClientHintsPreferences preferences; 275 ClientHintsPreferences preferences;
276 preferences.setShouldSendDPR(true); 276 preferences.setShouldSendDPR(true);
277 document->setClientHintsPreferences(preferences); 277 document->clientHintsPreferences().updateFrom(preferences);
278 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 278 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
279 dummyPageHolder->page().setDeviceScaleFactor(2.5); 279 dummyPageHolder->page().setDeviceScaleFactor(2.5);
280 expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5"); 280 expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5");
281 expectHeader("http://www.example.com/1.gif", "Width", false, ""); 281 expectHeader("http://www.example.com/1.gif", "Width", false, "");
282 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); 282 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
283 } 283 }
284 284
285 TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints) 285 TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints)
286 { 286 {
287 expectHeader("http://www.example.com/1.gif", "Width", false, ""); 287 expectHeader("http://www.example.com/1.gif", "Width", false, "");
288 ClientHintsPreferences preferences; 288 ClientHintsPreferences preferences;
289 preferences.setShouldSendResourceWidth(true); 289 preferences.setShouldSendResourceWidth(true);
290 document->setClientHintsPreferences(preferences); 290 document->clientHintsPreferences().updateFrom(preferences);
291 expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500); 291 expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500);
292 expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666) ; 292 expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666) ;
293 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 293 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
294 } 294 }
295 295
296 TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints) 296 TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints)
297 { 297 {
298 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); 298 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
299 ClientHintsPreferences preferences; 299 ClientHintsPreferences preferences;
300 preferences.setShouldSendViewportWidth(true); 300 preferences.setShouldSendViewportWidth(true);
301 document->setClientHintsPreferences(preferences); 301 document->clientHintsPreferences().updateFrom(preferences);
302 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); 302 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500");
303 dummyPageHolder->frameView().setLayoutSizeFixedToFrameSize(false); 303 dummyPageHolder->frameView().setLayoutSizeFixedToFrameSize(false);
304 dummyPageHolder->frameView().setLayoutSize(IntSize(800, 800)); 304 dummyPageHolder->frameView().setLayoutSize(IntSize(800, 800));
305 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800"); 305 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800");
306 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800", 666.6666); 306 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800", 666.6666);
307 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 307 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
308 } 308 }
309 309
310 TEST_F(FrameFetchContextHintsTest, MonitorAllHints) 310 TEST_F(FrameFetchContextHintsTest, MonitorAllHints)
311 { 311 {
312 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 312 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
313 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); 313 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
314 expectHeader("http://www.example.com/1.gif", "Width", false, ""); 314 expectHeader("http://www.example.com/1.gif", "Width", false, "");
315 315
316 ClientHintsPreferences preferences; 316 ClientHintsPreferences preferences;
317 preferences.setShouldSendDPR(true); 317 preferences.setShouldSendDPR(true);
318 preferences.setShouldSendResourceWidth(true); 318 preferences.setShouldSendResourceWidth(true);
319 preferences.setShouldSendViewportWidth(true); 319 preferences.setShouldSendViewportWidth(true);
320 document->setClientHintsPreferences(preferences); 320 document->clientHintsPreferences().updateFrom(preferences);
321 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 321 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
322 expectHeader("http://www.example.com/1.gif", "Width", true, "400", 400); 322 expectHeader("http://www.example.com/1.gif", "Width", true, "400", 400);
323 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); 323 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500");
324 } 324 }
325 325
326 class StubFrameLoaderClientWithParent : public EmptyFrameLoaderClient { 326 class StubFrameLoaderClientWithParent : public EmptyFrameLoaderClient {
327 public: 327 public:
328 explicit StubFrameLoaderClientWithParent(Frame* parent) 328 explicit StubFrameLoaderClientWithParent(Frame* parent)
329 : m_parent(parent) 329 : m_parent(parent)
330 { 330 {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // Child frame as part of end to end reload 430 // Child frame as part of end to end reload
431 document->frame()->loader().setLoadType(FrameLoadTypeReloadFromOrigin); 431 document->frame()->loader().setLoadType(FrameLoadTypeReloadFromOrigin);
432 EXPECT_EQ(ReloadBypassingCache, childFetchContext->resourceRequestCachePolic y(request, Resource::MainResource)); 432 EXPECT_EQ(ReloadBypassingCache, childFetchContext->resourceRequestCachePolic y(request, Resource::MainResource));
433 433
434 childDocumentLoader->detachFromFrame(); 434 childDocumentLoader->detachFromFrame();
435 childDocumentLoader.clear(); 435 childDocumentLoader.clear();
436 childFrame->detach(FrameDetachType::Remove); 436 childFrame->detach(FrameDetachType::Remove);
437 } 437 }
438 438
439 } // namespace 439 } // namespace
OLDNEW
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698