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

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

Issue 2715173002: Final rename from FrameLoaderClient to LocalFrameClient: (Closed)
Patch Set: 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ResourceRequest resourceRequest(inputURL); 181 ResourceRequest resourceRequest(inputURL);
182 return fetchContext->canRequest( 182 return fetchContext->canRequest(
183 Resource::Image, resourceRequest, inputURL, ResourceLoaderOptions(), 183 Resource::Image, resourceRequest, inputURL, ResourceLoaderOptions(),
184 reportingPolicy, FetchRequest::UseDefaultOriginRestrictionForType); 184 reportingPolicy, FetchRequest::UseDefaultOriginRestrictionForType);
185 } 185 }
186 186
187 int m_filteredLoadCallbackCounter; 187 int m_filteredLoadCallbackCounter;
188 }; 188 };
189 189
190 // This test class sets up a mock frame loader client. 190 // This test class sets up a mock frame loader client.
191 class FrameFetchContextMockedFrameLoaderClientTest 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().setDeviceScaleFactor(1.0);
201 document = &dummyPageHolder->document(); 201 document = &dummyPageHolder->document();
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 706
707 TEST_F(FrameFetchContextTest, DisabledDataSaver) { 707 TEST_F(FrameFetchContextTest, DisabledDataSaver) {
708 ResourceRequest resourceRequest("http://www.example.com"); 708 ResourceRequest resourceRequest("http://www.example.com");
709 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource); 709 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
710 EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data")); 710 EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data"));
711 } 711 }
712 712
713 // Tests that the embedder gets correct notification when a resource is loaded 713 // Tests that the embedder gets correct notification when a resource is loaded
714 // from the memory cache. 714 // from the memory cache.
715 TEST_F(FrameFetchContextMockedFrameLoaderClientTest, 715 TEST_F(FrameFetchContextMockedLocalFrameClientTest,
716 DispatchDidLoadResourceFromMemoryCache) { 716 DispatchDidLoadResourceFromMemoryCache) {
717 ResourceRequest resourceRequest(url); 717 ResourceRequest resourceRequest(url);
718 Resource* resource = MockResource::create(resourceRequest); 718 Resource* resource = MockResource::create(resourceRequest);
719 EXPECT_CALL( 719 EXPECT_CALL(
720 *client, 720 *client,
721 dispatchDidLoadResourceFromMemoryCache( 721 dispatchDidLoadResourceFromMemoryCache(
722 testing::AllOf(testing::Property(&ResourceRequest::url, url), 722 testing::AllOf(testing::Property(&ResourceRequest::url, url),
723 testing::Property(&ResourceRequest::frameType, 723 testing::Property(&ResourceRequest::frameType,
724 WebURLRequest::FrameTypeNone), 724 WebURLRequest::FrameTypeNone),
725 testing::Property(&ResourceRequest::requestContext, 725 testing::Property(&ResourceRequest::requestContext,
726 WebURLRequest::RequestContextImage)), 726 WebURLRequest::RequestContextImage)),
727 ResourceResponse())); 727 ResourceResponse()));
728 fetchContext->dispatchDidLoadResourceFromMemoryCache( 728 fetchContext->dispatchDidLoadResourceFromMemoryCache(
729 createUniqueIdentifier(), resource, WebURLRequest::FrameTypeNone, 729 createUniqueIdentifier(), resource, WebURLRequest::FrameTypeNone,
730 WebURLRequest::RequestContextImage); 730 WebURLRequest::RequestContextImage);
731 } 731 }
732 732
733 // Tests that when a resource with certificate errors is loaded from the memory 733 // Tests that when a resource with certificate errors is loaded from the memory
734 // cache, the embedder is notified. 734 // cache, the embedder is notified.
735 TEST_F(FrameFetchContextMockedFrameLoaderClientTest, 735 TEST_F(FrameFetchContextMockedLocalFrameClientTest,
736 MemoryCacheCertificateError) { 736 MemoryCacheCertificateError) {
737 ResourceRequest resourceRequest(url); 737 ResourceRequest resourceRequest(url);
738 ResourceResponse response; 738 ResourceResponse response;
739 response.setURL(url); 739 response.setURL(url);
740 response.setHasMajorCertificateErrors(true); 740 response.setHasMajorCertificateErrors(true);
741 Resource* resource = MockResource::create(resourceRequest); 741 Resource* resource = MockResource::create(resourceRequest);
742 resource->setResponse(response); 742 resource->setResponse(response);
743 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); 743 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url));
744 fetchContext->dispatchDidLoadResourceFromMemoryCache( 744 fetchContext->dispatchDidLoadResourceFromMemoryCache(
745 createUniqueIdentifier(), resource, WebURLRequest::FrameTypeNone, 745 createUniqueIdentifier(), resource, WebURLRequest::FrameTypeNone,
(...skipping 155 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