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

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

Issue 2724543002: Renamed deviceScaleFactor() to deviceScaleFactorDeprecated() in Page (Closed)
Patch Set: Rebase 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 unified diff | Download patch
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 private: 99 private:
100 const LoadPolicy m_policy; 100 const LoadPolicy m_policy;
101 int* m_filteredLoadCounter; 101 int* m_filteredLoadCounter;
102 }; 102 };
103 103
104 class FrameFetchContextTest : public ::testing::Test { 104 class FrameFetchContextTest : public ::testing::Test {
105 protected: 105 protected:
106 void SetUp() override { 106 void SetUp() override {
107 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 107 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
108 dummyPageHolder->page().setDeviceScaleFactor(1.0); 108 dummyPageHolder->page().setDeviceScaleFactorDeprecated(1.0);
109 document = &dummyPageHolder->document(); 109 document = &dummyPageHolder->document();
110 fetchContext = 110 fetchContext =
111 static_cast<FrameFetchContext*>(&document->fetcher()->context()); 111 static_cast<FrameFetchContext*>(&document->fetcher()->context());
112 owner = DummyFrameOwner::create(); 112 owner = DummyFrameOwner::create();
113 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); 113 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
114 } 114 }
115 115
116 void TearDown() override { 116 void TearDown() override {
117 if (childFrame) 117 if (childFrame)
118 childFrame->detach(FrameDetachType::Remove); 118 childFrame->detach(FrameDetachType::Remove);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // This test class sets up a mock frame loader client. 190 // This test class sets up a mock frame loader client.
191 class FrameFetchContextMockedLocalFrameClientTest 191 class FrameFetchContextMockedLocalFrameClientTest
192 : public FrameFetchContextTest { 192 : public FrameFetchContextTest {
193 protected: 193 protected:
194 void SetUp() override { 194 void SetUp() override {
195 url = KURL(KURL(), "https://example.test/foo"); 195 url = KURL(KURL(), "https://example.test/foo");
196 mainResourceUrl = KURL(KURL(), "https://www.example.test"); 196 mainResourceUrl = KURL(KURL(), "https://www.example.test");
197 client = new testing::NiceMock<MockLocalFrameClient>(); 197 client = new testing::NiceMock<MockLocalFrameClient>();
198 dummyPageHolder = 198 dummyPageHolder =
199 DummyPageHolder::create(IntSize(500, 500), nullptr, client); 199 DummyPageHolder::create(IntSize(500, 500), nullptr, client);
200 dummyPageHolder->page().setDeviceScaleFactor(1.0); 200 dummyPageHolder->page().setDeviceScaleFactorDeprecated(1.0);
201 document = &dummyPageHolder->document(); 201 document = &dummyPageHolder->document();
202 document->setURL(mainResourceUrl); 202 document->setURL(mainResourceUrl);
203 fetchContext = 203 fetchContext =
204 static_cast<FrameFetchContext*>(&document->fetcher()->context()); 204 static_cast<FrameFetchContext*>(&document->fetcher()->context());
205 owner = DummyFrameOwner::create(); 205 owner = DummyFrameOwner::create();
206 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); 206 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
207 } 207 }
208 208
209 KURL url; 209 KURL url;
210 KURL mainResourceUrl; 210 KURL mainResourceUrl;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 resourceRequest.httpHeaderField(headerName)); 488 resourceRequest.httpHeaderField(headerName));
489 } 489 }
490 }; 490 };
491 491
492 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) { 492 TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) {
493 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 493 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
494 ClientHintsPreferences preferences; 494 ClientHintsPreferences preferences;
495 preferences.setShouldSendDPR(true); 495 preferences.setShouldSendDPR(true);
496 document->clientHintsPreferences().updateFrom(preferences); 496 document->clientHintsPreferences().updateFrom(preferences);
497 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 497 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
498 dummyPageHolder->page().setDeviceScaleFactor(2.5); 498 dummyPageHolder->page().setDeviceScaleFactorDeprecated(2.5);
499 expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5"); 499 expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5");
500 expectHeader("http://www.example.com/1.gif", "Width", false, ""); 500 expectHeader("http://www.example.com/1.gif", "Width", false, "");
501 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); 501 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
502 } 502 }
503 503
504 TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints) { 504 TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints) {
505 expectHeader("http://www.example.com/1.gif", "Width", false, ""); 505 expectHeader("http://www.example.com/1.gif", "Width", false, "");
506 ClientHintsPreferences preferences; 506 ClientHintsPreferences preferences;
507 preferences.setShouldSendResourceWidth(true); 507 preferences.setShouldSendResourceWidth(true);
508 document->clientHintsPreferences().updateFrom(preferences); 508 document->clientHintsPreferences().updateFrom(preferences);
509 expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500); 509 expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500);
510 expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666); 510 expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666);
511 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); 511 expectHeader("http://www.example.com/1.gif", "DPR", false, "");
512 dummyPageHolder->page().setDeviceScaleFactor(2.5); 512 dummyPageHolder->page().setDeviceScaleFactorDeprecated(2.5);
513 expectHeader("http://www.example.com/1.gif", "Width", true, "1250", 500); 513 expectHeader("http://www.example.com/1.gif", "Width", true, "1250", 500);
514 expectHeader("http://www.example.com/1.gif", "Width", true, "1667", 666.6666); 514 expectHeader("http://www.example.com/1.gif", "Width", true, "1667", 666.6666);
515 } 515 }
516 516
517 TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints) { 517 TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints) {
518 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); 518 expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, "");
519 ClientHintsPreferences preferences; 519 ClientHintsPreferences preferences;
520 preferences.setShouldSendViewportWidth(true); 520 preferences.setShouldSendViewportWidth(true);
521 document->clientHintsPreferences().updateFrom(preferences); 521 document->clientHintsPreferences().updateFrom(preferences);
522 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); 522 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500");
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 {"http://example.test", false, "", WebURLRequest::FrameTypeTopLevel, ""}, 630 {"http://example.test", false, "", WebURLRequest::FrameTypeTopLevel, ""},
631 {"http://example.test", false, "", WebURLRequest::FrameTypeAuxiliary, ""}, 631 {"http://example.test", false, "", WebURLRequest::FrameTypeAuxiliary, ""},
632 {"http://example.test", false, "", WebURLRequest::FrameTypeNested, ""}, 632 {"http://example.test", false, "", WebURLRequest::FrameTypeNested, ""},
633 }; 633 };
634 634
635 for (const auto& test : cases) { 635 for (const auto& test : cases) {
636 SCOPED_TRACE(::testing::Message() << test.documentURL << " => " 636 SCOPED_TRACE(::testing::Message() << test.documentURL << " => "
637 << test.serializedOrigin); 637 << test.serializedOrigin);
638 // Set up a new document to ensure sandbox flags are cleared: 638 // Set up a new document to ensure sandbox flags are cleared:
639 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 639 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
640 dummyPageHolder->page().setDeviceScaleFactor(1.0); 640 dummyPageHolder->page().setDeviceScaleFactorDeprecated(1.0);
641 document = &dummyPageHolder->document(); 641 document = &dummyPageHolder->document();
642 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); 642 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
643 643
644 // Setup the test: 644 // Setup the test:
645 document->setURL(KURL(ParsedURLString, test.documentURL)); 645 document->setURL(KURL(ParsedURLString, test.documentURL));
646 document->setSecurityOrigin(SecurityOrigin::create(document->url())); 646 document->setSecurityOrigin(SecurityOrigin::create(document->url()));
647 647
648 if (test.documentSandboxed) 648 if (test.documentSandboxed)
649 document->enforceSandboxFlags(SandboxOrigin); 649 document->enforceSandboxFlags(SandboxOrigin);
650 650
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 setFilterPolicy(WebDocumentSubresourceFilter::WouldDisallow); 901 setFilterPolicy(WebDocumentSubresourceFilter::WouldDisallow);
902 902
903 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequest()); 903 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequest());
904 EXPECT_EQ(0, getFilteredLoadCallCount()); 904 EXPECT_EQ(0, getFilteredLoadCallCount());
905 905
906 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequestPreload()); 906 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequestPreload());
907 EXPECT_EQ(0, getFilteredLoadCallCount()); 907 EXPECT_EQ(0, getFilteredLoadCallCount());
908 } 908 }
909 909
910 } // namespace blink 910 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698