OLD | NEW |
---|---|
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 ResourceRequest resource_request(input_url); | 514 ResourceRequest resource_request(input_url); |
515 | 515 |
516 fetch_context->AddClientHintsIfNecessary(hints_preferences, resource_width, | 516 fetch_context->AddClientHintsIfNecessary(hints_preferences, resource_width, |
517 resource_request); | 517 resource_request); |
518 | 518 |
519 EXPECT_EQ(is_present ? String(header_value) : String(), | 519 EXPECT_EQ(is_present ? String(header_value) : String(), |
520 resource_request.HttpHeaderField(header_name)); | 520 resource_request.HttpHeaderField(header_name)); |
521 } | 521 } |
522 }; | 522 }; |
523 | 523 |
524 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.
| |
525 ExpectHeader("http://www.example.com/1.gif", "device-ram", false, ""); | |
526 ClientHintsPreferences preferences; | |
527 preferences.SetShouldSendDeviceRam(true); | |
528 document->GetClientHintsPreferences().UpdateFrom(preferences); | |
529 ExpectHeader("http://www.example.com/1.gif", "device-ram", true, "4"); | |
530 dummy_page_holder->GetPage().SetDeviceScaleFactorDeprecated(2.5); | |
531 ExpectHeader("http://www.example.com/1.gif", "device-ram", true, "2.5"); | |
532 ExpectHeader("http://www.example.com/1.gif", "Width", false, ""); | |
533 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); | |
534 } | |
535 | |
524 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) { | 536 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) { |
525 ExpectHeader("http://www.example.com/1.gif", "DPR", false, ""); | 537 ExpectHeader("http://www.example.com/1.gif", "DPR", false, ""); |
526 ClientHintsPreferences preferences; | 538 ClientHintsPreferences preferences; |
527 preferences.SetShouldSendDPR(true); | 539 preferences.SetShouldSendDPR(true); |
528 document->GetClientHintsPreferences().UpdateFrom(preferences); | 540 document->GetClientHintsPreferences().UpdateFrom(preferences); |
529 ExpectHeader("http://www.example.com/1.gif", "DPR", true, "1"); | 541 ExpectHeader("http://www.example.com/1.gif", "DPR", true, "1"); |
530 dummy_page_holder->GetPage().SetDeviceScaleFactorDeprecated(2.5); | 542 dummy_page_holder->GetPage().SetDeviceScaleFactorDeprecated(2.5); |
531 ExpectHeader("http://www.example.com/1.gif", "DPR", true, "2.5"); | 543 ExpectHeader("http://www.example.com/1.gif", "DPR", true, "2.5"); |
532 ExpectHeader("http://www.example.com/1.gif", "Width", false, ""); | 544 ExpectHeader("http://www.example.com/1.gif", "Width", false, ""); |
533 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); | 545 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); |
(...skipping 20 matching lines...) Expand all Loading... | |
554 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); | 566 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); |
555 dummy_page_holder->GetFrameView().SetLayoutSizeFixedToFrameSize(false); | 567 dummy_page_holder->GetFrameView().SetLayoutSizeFixedToFrameSize(false); |
556 dummy_page_holder->GetFrameView().SetLayoutSize(IntSize(800, 800)); | 568 dummy_page_holder->GetFrameView().SetLayoutSize(IntSize(800, 800)); |
557 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800"); | 569 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800"); |
558 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800", | 570 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800", |
559 666.6666); | 571 666.6666); |
560 ExpectHeader("http://www.example.com/1.gif", "DPR", false, ""); | 572 ExpectHeader("http://www.example.com/1.gif", "DPR", false, ""); |
561 } | 573 } |
562 | 574 |
563 TEST_F(FrameFetchContextHintsTest, MonitorAllHints) { | 575 TEST_F(FrameFetchContextHintsTest, MonitorAllHints) { |
576 ExpectHeader("http://www.example.com/1.gif", "device-ram", false, ""); | |
564 ExpectHeader("http://www.example.com/1.gif", "DPR", false, ""); | 577 ExpectHeader("http://www.example.com/1.gif", "DPR", false, ""); |
565 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); | 578 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); |
566 ExpectHeader("http://www.example.com/1.gif", "Width", false, ""); | 579 ExpectHeader("http://www.example.com/1.gif", "Width", false, ""); |
567 | 580 |
568 ClientHintsPreferences preferences; | 581 ClientHintsPreferences preferences; |
582 preferences.SetShouldSendDeviceRam(true); | |
569 preferences.SetShouldSendDPR(true); | 583 preferences.SetShouldSendDPR(true); |
570 preferences.SetShouldSendResourceWidth(true); | 584 preferences.SetShouldSendResourceWidth(true); |
571 preferences.SetShouldSendViewportWidth(true); | 585 preferences.SetShouldSendViewportWidth(true); |
572 document->GetClientHintsPreferences().UpdateFrom(preferences); | 586 document->GetClientHintsPreferences().UpdateFrom(preferences); |
587 ExpectHeader("http://www.example.com/1.gif", "device-ram", true, "4"); | |
573 ExpectHeader("http://www.example.com/1.gif", "DPR", true, "1"); | 588 ExpectHeader("http://www.example.com/1.gif", "DPR", true, "1"); |
574 ExpectHeader("http://www.example.com/1.gif", "Width", true, "400", 400); | 589 ExpectHeader("http://www.example.com/1.gif", "Width", true, "400", 400); |
575 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); | 590 ExpectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); |
576 } | 591 } |
577 | 592 |
578 TEST_F(FrameFetchContextTest, MainResourceCachePolicy) { | 593 TEST_F(FrameFetchContextTest, MainResourceCachePolicy) { |
579 // Default case | 594 // Default case |
580 ResourceRequest request("http://www.example.com"); | 595 ResourceRequest request("http://www.example.com"); |
581 EXPECT_EQ(WebCachePolicy::kUseProtocolCachePolicy, | 596 EXPECT_EQ(WebCachePolicy::kUseProtocolCachePolicy, |
582 fetch_context->ResourceRequestCachePolicy( | 597 fetch_context->ResourceRequestCachePolicy( |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 SetFilterPolicy(WebDocumentSubresourceFilter::kWouldDisallow); | 918 SetFilterPolicy(WebDocumentSubresourceFilter::kWouldDisallow); |
904 | 919 |
905 EXPECT_EQ(ResourceRequestBlockedReason::kNone, CanRequest()); | 920 EXPECT_EQ(ResourceRequestBlockedReason::kNone, CanRequest()); |
906 EXPECT_EQ(0, GetFilteredLoadCallCount()); | 921 EXPECT_EQ(0, GetFilteredLoadCallCount()); |
907 | 922 |
908 EXPECT_EQ(ResourceRequestBlockedReason::kNone, CanRequestPreload()); | 923 EXPECT_EQ(ResourceRequestBlockedReason::kNone, CanRequestPreload()); |
909 EXPECT_EQ(0, GetFilteredLoadCallCount()); | 924 EXPECT_EQ(0, GetFilteredLoadCallCount()); |
910 } | 925 } |
911 | 926 |
912 } // namespace blink | 927 } // namespace blink |
OLD | NEW |