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

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

Issue 2751143003: Move FrameFetchContext::dispatchDidLoadResourceFromMemoryCache logic into ResourceFetcher (Closed)
Patch Set: addressed comments 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 ResourceRequest resourceRequest("http://www.example.com"); 713 ResourceRequest resourceRequest("http://www.example.com");
714 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource); 714 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource);
715 EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data")); 715 EXPECT_EQ(String(), resourceRequest.httpHeaderField("Save-Data"));
716 } 716 }
717 717
718 // Tests that the embedder gets correct notification when a resource is loaded 718 // Tests that the embedder gets correct notification when a resource is loaded
719 // from the memory cache. 719 // from the memory cache.
720 TEST_F(FrameFetchContextMockedLocalFrameClientTest, 720 TEST_F(FrameFetchContextMockedLocalFrameClientTest,
721 DispatchDidLoadResourceFromMemoryCache) { 721 DispatchDidLoadResourceFromMemoryCache) {
722 ResourceRequest resourceRequest(url); 722 ResourceRequest resourceRequest(url);
723 resourceRequest.setRequestContext(WebURLRequest::RequestContextImage);
723 Resource* resource = MockResource::create(resourceRequest); 724 Resource* resource = MockResource::create(resourceRequest);
724 EXPECT_CALL( 725 EXPECT_CALL(
725 *client, 726 *client,
726 dispatchDidLoadResourceFromMemoryCache( 727 dispatchDidLoadResourceFromMemoryCache(
727 testing::AllOf(testing::Property(&ResourceRequest::url, url), 728 testing::AllOf(testing::Property(&ResourceRequest::url, url),
728 testing::Property(&ResourceRequest::frameType, 729 testing::Property(&ResourceRequest::frameType,
729 WebURLRequest::FrameTypeNone), 730 WebURLRequest::FrameTypeNone),
730 testing::Property(&ResourceRequest::requestContext, 731 testing::Property(&ResourceRequest::requestContext,
731 WebURLRequest::RequestContextImage)), 732 WebURLRequest::RequestContextImage)),
732 ResourceResponse())); 733 ResourceResponse()));
733 fetchContext->dispatchDidLoadResourceFromMemoryCache( 734 fetchContext->dispatchDidLoadResourceFromMemoryCache(
734 createUniqueIdentifier(), resource, WebURLRequest::FrameTypeNone, 735 createUniqueIdentifier(), resourceRequest, resource->response());
735 WebURLRequest::RequestContextImage);
736 } 736 }
737 737
738 // Tests that when a resource with certificate errors is loaded from the memory 738 // Tests that when a resource with certificate errors is loaded from the memory
739 // cache, the embedder is notified. 739 // cache, the embedder is notified.
740 TEST_F(FrameFetchContextMockedLocalFrameClientTest, 740 TEST_F(FrameFetchContextMockedLocalFrameClientTest,
741 MemoryCacheCertificateError) { 741 MemoryCacheCertificateError) {
742 ResourceRequest resourceRequest(url); 742 ResourceRequest resourceRequest(url);
743 resourceRequest.setRequestContext(WebURLRequest::RequestContextImage);
743 ResourceResponse response; 744 ResourceResponse response;
744 response.setURL(url); 745 response.setURL(url);
745 response.setHasMajorCertificateErrors(true); 746 response.setHasMajorCertificateErrors(true);
746 Resource* resource = MockResource::create(resourceRequest); 747 Resource* resource = MockResource::create(resourceRequest);
747 resource->setResponse(response); 748 resource->setResponse(response);
748 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); 749 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url));
749 fetchContext->dispatchDidLoadResourceFromMemoryCache( 750 fetchContext->dispatchDidLoadResourceFromMemoryCache(
750 createUniqueIdentifier(), resource, WebURLRequest::FrameTypeNone, 751 createUniqueIdentifier(), resourceRequest, resource->response());
751 WebURLRequest::RequestContextImage);
752 } 752 }
753 753
754 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPublicDocument) { 754 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPublicDocument) {
755 EXPECT_EQ(WebAddressSpacePublic, document->addressSpace()); 755 EXPECT_EQ(WebAddressSpacePublic, document->addressSpace());
756 756
757 struct TestCase { 757 struct TestCase {
758 const char* url; 758 const char* url;
759 bool isExternalExpectation; 759 bool isExternalExpectation;
760 } cases[] = { 760 } cases[] = {
761 {"data:text/html,whatever", false}, {"file:///etc/passwd", false}, 761 {"data:text/html,whatever", false}, {"file:///etc/passwd", false},
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 setFilterPolicy(WebDocumentSubresourceFilter::WouldDisallow); 906 setFilterPolicy(WebDocumentSubresourceFilter::WouldDisallow);
907 907
908 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequest()); 908 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequest());
909 EXPECT_EQ(0, getFilteredLoadCallCount()); 909 EXPECT_EQ(0, getFilteredLoadCallCount());
910 910
911 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequestPreload()); 911 EXPECT_EQ(ResourceRequestBlockedReason::None, canRequestPreload());
912 EXPECT_EQ(0, getFilteredLoadCallCount()); 912 EXPECT_EQ(0, getFilteredLoadCallCount());
913 } 913 }
914 914
915 } // namespace blink 915 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698