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

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

Issue 2197953002: Remove unnecessary uses of HTMLDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify Created 4 years, 4 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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/fetch/FetchInitiatorInfo.h" 34 #include "core/fetch/FetchInitiatorInfo.h"
34 #include "core/fetch/UniqueIdentifier.h" 35 #include "core/fetch/UniqueIdentifier.h"
35 #include "core/frame/FrameHost.h" 36 #include "core/frame/FrameHost.h"
36 #include "core/frame/FrameOwner.h" 37 #include "core/frame/FrameOwner.h"
37 #include "core/frame/FrameView.h" 38 #include "core/frame/FrameView.h"
38 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
39 #include "core/html/HTMLDocument.h"
40 #include "core/loader/DocumentLoader.h" 40 #include "core/loader/DocumentLoader.h"
41 #include "core/loader/EmptyClients.h" 41 #include "core/loader/EmptyClients.h"
42 #include "core/page/Page.h" 42 #include "core/page/Page.h"
43 #include "core/testing/DummyPageHolder.h" 43 #include "core/testing/DummyPageHolder.h"
44 #include "platform/network/ResourceRequest.h" 44 #include "platform/network/ResourceRequest.h"
45 #include "platform/weborigin/KURL.h" 45 #include "platform/weborigin/KURL.h"
46 #include "public/platform/WebAddressSpace.h" 46 #include "public/platform/WebAddressSpace.h"
47 #include "public/platform/WebCachePolicy.h" 47 #include "public/platform/WebCachePolicy.h"
48 #include "public/platform/WebInsecureRequestPolicy.h" 48 #include "public/platform/WebInsecureRequestPolicy.h"
49 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h" 49 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 MOCK_METHOD2(didDisplayContentWithCertificateErrors, void(const KURL&, const CString&)); 85 MOCK_METHOD2(didDisplayContentWithCertificateErrors, void(const KURL&, const CString&));
86 }; 86 };
87 87
88 class FrameFetchContextTest : public ::testing::Test { 88 class FrameFetchContextTest : public ::testing::Test {
89 protected: 89 protected:
90 void SetUp() override 90 void SetUp() override
91 { 91 {
92 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 92 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
93 dummyPageHolder->page().setDeviceScaleFactor(1.0); 93 dummyPageHolder->page().setDeviceScaleFactor(1.0);
94 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou rceRequest("http://www.example.com"), SubstituteData()); 94 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou rceRequest("http://www.example.com"), SubstituteData());
95 document = toHTMLDocument(&dummyPageHolder->document()); 95 document = &dummyPageHolder->document();
96 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher( )->context()); 96 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher( )->context());
97 owner = DummyFrameOwner::create(); 97 owner = DummyFrameOwner::create();
98 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( )); 98 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( ));
99 } 99 }
100 100
101 void TearDown() override 101 void TearDown() override
102 { 102 {
103 documentLoader->detachFromFrame(); 103 documentLoader->detachFromFrame();
104 documentLoader.clear(); 104 documentLoader.clear();
105 105
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void SetUp() override 144 void SetUp() override
145 { 145 {
146 url = KURL(KURL(), "https://example.test/foo"); 146 url = KURL(KURL(), "https://example.test/foo");
147 securityInfo = "security info"; 147 securityInfo = "security info";
148 mainResourceUrl = KURL(KURL(), "https://www.example.test"); 148 mainResourceUrl = KURL(KURL(), "https://www.example.test");
149 MockFrameLoaderClient* client = new MockFrameLoaderClient; 149 MockFrameLoaderClient* client = new MockFrameLoaderClient;
150 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit yInfo)); 150 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit yInfo));
151 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, cl ient); 151 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, cl ient);
152 dummyPageHolder->page().setDeviceScaleFactor(1.0); 152 dummyPageHolder->page().setDeviceScaleFactor(1.0);
153 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou rceRequest(mainResourceUrl), SubstituteData()); 153 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou rceRequest(mainResourceUrl), SubstituteData());
154 document = toHTMLDocument(&dummyPageHolder->document()); 154 document = &dummyPageHolder->document();
155 document->setURL(mainResourceUrl); 155 document->setURL(mainResourceUrl);
156 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher( )->context()); 156 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher( )->context());
157 owner = DummyFrameOwner::create(); 157 owner = DummyFrameOwner::create();
158 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( )); 158 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( ));
159 } 159 }
160 160
161 KURL url; 161 KURL url;
162 KURL mainResourceUrl; 162 KURL mainResourceUrl;
163 CString securityInfo; 163 CString securityInfo;
164 }; 164 };
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 { "http://example.test", false, "", WebURLRequest::FrameTypeTopLevel, "" }, 473 { "http://example.test", false, "", WebURLRequest::FrameTypeTopLevel, "" },
474 { "http://example.test", false, "", WebURLRequest::FrameTypeAuxiliary, " " }, 474 { "http://example.test", false, "", WebURLRequest::FrameTypeAuxiliary, " " },
475 { "http://example.test", false, "", WebURLRequest::FrameTypeNested, "" } , 475 { "http://example.test", false, "", WebURLRequest::FrameTypeNested, "" } ,
476 }; 476 };
477 477
478 for (const auto& test : cases) { 478 for (const auto& test : cases) {
479 SCOPED_TRACE(::testing::Message() << test.documentURL << " => " << test. serializedOrigin); 479 SCOPED_TRACE(::testing::Message() << test.documentURL << " => " << test. serializedOrigin);
480 // Set up a new document to ensure sandbox flags are cleared: 480 // Set up a new document to ensure sandbox flags are cleared:
481 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 481 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
482 dummyPageHolder->page().setDeviceScaleFactor(1.0); 482 dummyPageHolder->page().setDeviceScaleFactor(1.0);
483 document = toHTMLDocument(&dummyPageHolder->document()); 483 document = &dummyPageHolder->document();
484 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( )); 484 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( ));
485 485
486 // Setup the test: 486 // Setup the test:
487 document->setURL(KURL(ParsedURLString, test.documentURL)); 487 document->setURL(KURL(ParsedURLString, test.documentURL));
488 document->setSecurityOrigin(SecurityOrigin::create(document->url())); 488 document->setSecurityOrigin(SecurityOrigin::create(document->url()));
489 489
490 if (test.documentSandboxed) 490 if (test.documentSandboxed)
491 document->enforceSandboxFlags(SandboxOrigin); 491 document->enforceSandboxFlags(SandboxOrigin);
492 492
493 ResourceRequest request("http://example.test/"); 493 ResourceRequest request("http://example.test/");
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource ); 696 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource );
697 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); 697 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation);
698 698
699 ResourceRequest subRequest(test.url); 699 ResourceRequest subRequest(test.url);
700 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); 700 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource);
701 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); 701 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation);
702 } 702 }
703 } 703 }
704 704
705 } // namespace blink 705 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeTest.cpp ('k') | third_party/WebKit/Source/core/loader/HttpEquiv.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698