| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/loader/FrameFetchContext.h" | 31 #include "core/loader/FrameFetchContext.h" |
| 32 | 32 |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/fetch/FetchInitiatorInfo.h" | 34 #include "core/fetch/FetchInitiatorInfo.h" |
| 35 #include "core/fetch/UniqueIdentifier.h" | 35 #include "core/fetch/UniqueIdentifier.h" |
| 36 #include "core/frame/FrameHost.h" | 36 #include "core/frame/FrameHost.h" |
| 37 #include "core/frame/FrameOwner.h" | 37 #include "core/frame/FrameOwner.h" |
| 38 #include "core/frame/FrameTypes.h" |
| 38 #include "core/frame/FrameView.h" | 39 #include "core/frame/FrameView.h" |
| 39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
| 40 #include "core/html/HTMLIFrameElement.h" | 41 #include "core/html/HTMLIFrameElement.h" |
| 41 #include "core/loader/DocumentLoader.h" | 42 #include "core/loader/DocumentLoader.h" |
| 42 #include "core/loader/EmptyClients.h" | 43 #include "core/loader/EmptyClients.h" |
| 43 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
| 44 #include "core/testing/DummyPageHolder.h" | 45 #include "core/testing/DummyPageHolder.h" |
| 45 #include "platform/network/ResourceRequest.h" | 46 #include "platform/network/ResourceRequest.h" |
| 46 #include "platform/weborigin/KURL.h" | 47 #include "platform/weborigin/KURL.h" |
| 47 #include "public/platform/WebAddressSpace.h" | 48 #include "public/platform/WebAddressSpace.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 78 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&)); | 79 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&)); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 class FrameFetchContextTest : public ::testing::Test { | 82 class FrameFetchContextTest : public ::testing::Test { |
| 82 protected: | 83 protected: |
| 83 void SetUp() override { | 84 void SetUp() override { |
| 84 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); | 85 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); |
| 85 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 86 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
| 86 documentLoader = DocumentLoader::create( | 87 documentLoader = DocumentLoader::create( |
| 87 &dummyPageHolder->frame(), ResourceRequest("http://www.example.com"), | 88 &dummyPageHolder->frame(), ResourceRequest("http://www.example.com"), |
| 88 SubstituteData()); | 89 SubstituteData(), ClientRedirectPolicy::NotClientRedirect); |
| 89 document = &dummyPageHolder->document(); | 90 document = &dummyPageHolder->document(); |
| 90 fetchContext = | 91 fetchContext = |
| 91 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); | 92 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); |
| 92 owner = DummyFrameOwner::create(); | 93 owner = DummyFrameOwner::create(); |
| 93 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); | 94 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void TearDown() override { | 97 void TearDown() override { |
| 97 documentLoader->detachFromFrame(); | 98 documentLoader->detachFromFrame(); |
| 98 documentLoader.clear(); | 99 documentLoader.clear(); |
| 99 | 100 |
| 100 if (childFrame) { | 101 if (childFrame) { |
| 101 childDocumentLoader->detachFromFrame(); | 102 childDocumentLoader->detachFromFrame(); |
| 102 childDocumentLoader.clear(); | 103 childDocumentLoader.clear(); |
| 103 childFrame->detach(FrameDetachType::Remove); | 104 childFrame->detach(FrameDetachType::Remove); |
| 104 } | 105 } |
| 105 } | 106 } |
| 106 | 107 |
| 107 FrameFetchContext* createChildFrame() { | 108 FrameFetchContext* createChildFrame() { |
| 108 childClient = StubFrameLoaderClientWithParent::create(document->frame()); | 109 childClient = StubFrameLoaderClientWithParent::create(document->frame()); |
| 109 childFrame = LocalFrame::create(childClient.get(), | 110 childFrame = LocalFrame::create(childClient.get(), |
| 110 document->frame()->host(), owner.get()); | 111 document->frame()->host(), owner.get()); |
| 111 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500))); | 112 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500))); |
| 112 childFrame->init(); | 113 childFrame->init(); |
| 113 childDocumentLoader = DocumentLoader::create( | 114 childDocumentLoader = DocumentLoader::create( |
| 114 childFrame.get(), ResourceRequest("http://www.example.com"), | 115 childFrame.get(), ResourceRequest("http://www.example.com"), |
| 115 SubstituteData()); | 116 SubstituteData(), ClientRedirectPolicy::NotClientRedirect); |
| 116 childDocument = childFrame->document(); | 117 childDocument = childFrame->document(); |
| 117 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>( | 118 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>( |
| 118 &childDocumentLoader->fetcher()->context()); | 119 &childDocumentLoader->fetcher()->context()); |
| 119 FrameFetchContext::provideDocumentToContext(*childFetchContext, | 120 FrameFetchContext::provideDocumentToContext(*childFetchContext, |
| 120 childDocument.get()); | 121 childDocument.get()); |
| 121 return childFetchContext; | 122 return childFetchContext; |
| 122 } | 123 } |
| 123 | 124 |
| 124 std::unique_ptr<DummyPageHolder> dummyPageHolder; | 125 std::unique_ptr<DummyPageHolder> dummyPageHolder; |
| 125 // We don't use the DocumentLoader directly in any tests, but need to keep it | 126 // We don't use the DocumentLoader directly in any tests, but need to keep it |
| (...skipping 16 matching lines...) Expand all Loading... |
| 142 : public FrameFetchContextTest { | 143 : public FrameFetchContextTest { |
| 143 protected: | 144 protected: |
| 144 void SetUp() override { | 145 void SetUp() override { |
| 145 url = KURL(KURL(), "https://example.test/foo"); | 146 url = KURL(KURL(), "https://example.test/foo"); |
| 146 mainResourceUrl = KURL(KURL(), "https://www.example.test"); | 147 mainResourceUrl = KURL(KURL(), "https://www.example.test"); |
| 147 MockFrameLoaderClient* client = new MockFrameLoaderClient; | 148 MockFrameLoaderClient* client = new MockFrameLoaderClient; |
| 148 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); | 149 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); |
| 149 dummyPageHolder = | 150 dummyPageHolder = |
| 150 DummyPageHolder::create(IntSize(500, 500), nullptr, client); | 151 DummyPageHolder::create(IntSize(500, 500), nullptr, client); |
| 151 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 152 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
| 152 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), | 153 documentLoader = DocumentLoader::create( |
| 153 ResourceRequest(mainResourceUrl), | 154 &dummyPageHolder->frame(), ResourceRequest(mainResourceUrl), |
| 154 SubstituteData()); | 155 SubstituteData(), ClientRedirectPolicy::NotClientRedirect); |
| 155 document = &dummyPageHolder->document(); | 156 document = &dummyPageHolder->document(); |
| 156 document->setURL(mainResourceUrl); | 157 document->setURL(mainResourceUrl); |
| 157 fetchContext = | 158 fetchContext = |
| 158 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); | 159 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); |
| 159 owner = DummyFrameOwner::create(); | 160 owner = DummyFrameOwner::create(); |
| 160 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); | 161 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); |
| 161 } | 162 } |
| 162 | 163 |
| 163 KURL url; | 164 KURL url; |
| 164 KURL mainResourceUrl; | 165 KURL mainResourceUrl; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); | 806 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); |
| 806 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); | 807 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); |
| 807 | 808 |
| 808 ResourceRequest subRequest(test.url); | 809 ResourceRequest subRequest(test.url); |
| 809 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 810 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 810 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); | 811 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); |
| 811 } | 812 } |
| 812 } | 813 } |
| 813 | 814 |
| 814 } // namespace blink | 815 } // namespace blink |
| OLD | NEW |