| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&)); | 78 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&)); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class FrameFetchContextTest : public ::testing::Test { | 81 class FrameFetchContextTest : public ::testing::Test { |
| 82 protected: | 82 protected: |
| 83 void SetUp() override { | 83 void SetUp() override { |
| 84 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); | 84 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); |
| 85 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 85 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
| 86 documentLoader = DocumentLoader::create( | 86 documentLoader = DocumentLoader::create( |
| 87 &dummyPageHolder->frame(), ResourceRequest("http://www.example.com"), | 87 &dummyPageHolder->frame(), ResourceRequest("http://www.example.com"), |
| 88 SubstituteData()); | 88 SubstituteData(), false); |
| 89 document = &dummyPageHolder->document(); | 89 document = &dummyPageHolder->document(); |
| 90 fetchContext = | 90 fetchContext = |
| 91 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); | 91 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); |
| 92 owner = DummyFrameOwner::create(); | 92 owner = DummyFrameOwner::create(); |
| 93 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); | 93 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TearDown() override { | 96 void TearDown() override { |
| 97 documentLoader->detachFromFrame(); | 97 documentLoader->detachFromFrame(); |
| 98 documentLoader.clear(); | 98 documentLoader.clear(); |
| 99 | 99 |
| 100 if (childFrame) { | 100 if (childFrame) { |
| 101 childDocumentLoader->detachFromFrame(); | 101 childDocumentLoader->detachFromFrame(); |
| 102 childDocumentLoader.clear(); | 102 childDocumentLoader.clear(); |
| 103 childFrame->detach(FrameDetachType::Remove); | 103 childFrame->detach(FrameDetachType::Remove); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 FrameFetchContext* createChildFrame() { | 107 FrameFetchContext* createChildFrame() { |
| 108 childClient = StubFrameLoaderClientWithParent::create(document->frame()); | 108 childClient = StubFrameLoaderClientWithParent::create(document->frame()); |
| 109 childFrame = LocalFrame::create(childClient.get(), | 109 childFrame = LocalFrame::create(childClient.get(), |
| 110 document->frame()->host(), owner.get()); | 110 document->frame()->host(), owner.get()); |
| 111 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500))); | 111 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500))); |
| 112 childFrame->init(); | 112 childFrame->init(); |
| 113 childDocumentLoader = DocumentLoader::create( | 113 childDocumentLoader = DocumentLoader::create( |
| 114 childFrame.get(), ResourceRequest("http://www.example.com"), | 114 childFrame.get(), ResourceRequest("http://www.example.com"), |
| 115 SubstituteData()); | 115 SubstituteData(), false); |
| 116 childDocument = childFrame->document(); | 116 childDocument = childFrame->document(); |
| 117 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>( | 117 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>( |
| 118 &childDocumentLoader->fetcher()->context()); | 118 &childDocumentLoader->fetcher()->context()); |
| 119 FrameFetchContext::provideDocumentToContext(*childFetchContext, | 119 FrameFetchContext::provideDocumentToContext(*childFetchContext, |
| 120 childDocument.get()); | 120 childDocument.get()); |
| 121 return childFetchContext; | 121 return childFetchContext; |
| 122 } | 122 } |
| 123 | 123 |
| 124 std::unique_ptr<DummyPageHolder> dummyPageHolder; | 124 std::unique_ptr<DummyPageHolder> dummyPageHolder; |
| 125 // We don't use the DocumentLoader directly in any tests, but need to keep it | 125 // We don't use the DocumentLoader directly in any tests, but need to keep it |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 void SetUp() override { | 144 void SetUp() override { |
| 145 url = KURL(KURL(), "https://example.test/foo"); | 145 url = KURL(KURL(), "https://example.test/foo"); |
| 146 mainResourceUrl = KURL(KURL(), "https://www.example.test"); | 146 mainResourceUrl = KURL(KURL(), "https://www.example.test"); |
| 147 MockFrameLoaderClient* client = new MockFrameLoaderClient; | 147 MockFrameLoaderClient* client = new MockFrameLoaderClient; |
| 148 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); | 148 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); |
| 149 dummyPageHolder = | 149 dummyPageHolder = |
| 150 DummyPageHolder::create(IntSize(500, 500), nullptr, client); | 150 DummyPageHolder::create(IntSize(500, 500), nullptr, client); |
| 151 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 151 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
| 152 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), | 152 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), |
| 153 ResourceRequest(mainResourceUrl), | 153 ResourceRequest(mainResourceUrl), |
| 154 SubstituteData()); | 154 SubstituteData(), false); |
| 155 document = &dummyPageHolder->document(); | 155 document = &dummyPageHolder->document(); |
| 156 document->setURL(mainResourceUrl); | 156 document->setURL(mainResourceUrl); |
| 157 fetchContext = | 157 fetchContext = |
| 158 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); | 158 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); |
| 159 owner = DummyFrameOwner::create(); | 159 owner = DummyFrameOwner::create(); |
| 160 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); | 160 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 KURL url; | 163 KURL url; |
| 164 KURL mainResourceUrl; | 164 KURL mainResourceUrl; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); | 805 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); |
| 806 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); | 806 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); |
| 807 | 807 |
| 808 ResourceRequest subRequest(test.url); | 808 ResourceRequest subRequest(test.url); |
| 809 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 809 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 810 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); | 810 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 | 813 |
| 814 } // namespace blink | 814 } // namespace blink |
| OLD | NEW |