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

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

Issue 2416523002: Expose the initiating origin/URL of a navigation in the Blink public API (Closed)
Patch Set: rebase Created 4 years 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&)); 79 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&));
80 }; 80 };
81 81
82 class FrameFetchContextTest : public ::testing::Test { 82 class FrameFetchContextTest : public ::testing::Test {
83 protected: 83 protected:
84 void SetUp() override { 84 void SetUp() override {
85 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 85 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
86 dummyPageHolder->page().setDeviceScaleFactor(1.0); 86 dummyPageHolder->page().setDeviceScaleFactor(1.0);
87 documentLoader = DocumentLoader::create( 87 documentLoader = DocumentLoader::create(
88 &dummyPageHolder->frame(), ResourceRequest("http://www.example.com"), 88 &dummyPageHolder->frame(), ResourceRequest("http://www.example.com"),
89 SubstituteData(), ClientRedirectPolicy::NotClientRedirect); 89 SubstituteData(), ClientRedirectPolicy::NotClientRedirect, nullptr);
90 document = &dummyPageHolder->document(); 90 document = &dummyPageHolder->document();
91 fetchContext = 91 fetchContext =
92 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); 92 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context());
93 owner = DummyFrameOwner::create(); 93 owner = DummyFrameOwner::create();
94 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); 94 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
95 } 95 }
96 96
97 void TearDown() override { 97 void TearDown() override {
98 documentLoader->detachFromFrame(); 98 documentLoader->detachFromFrame();
99 documentLoader.clear(); 99 documentLoader.clear();
100 100
101 if (childFrame) { 101 if (childFrame) {
102 childDocumentLoader->detachFromFrame(); 102 childDocumentLoader->detachFromFrame();
103 childDocumentLoader.clear(); 103 childDocumentLoader.clear();
104 childFrame->detach(FrameDetachType::Remove); 104 childFrame->detach(FrameDetachType::Remove);
105 } 105 }
106 } 106 }
107 107
108 FrameFetchContext* createChildFrame() { 108 FrameFetchContext* createChildFrame() {
109 childClient = StubFrameLoaderClientWithParent::create(document->frame()); 109 childClient = StubFrameLoaderClientWithParent::create(document->frame());
110 childFrame = LocalFrame::create(childClient.get(), 110 childFrame = LocalFrame::create(childClient.get(),
111 document->frame()->host(), owner.get()); 111 document->frame()->host(), owner.get());
112 childFrame->setView(FrameView::create(*childFrame, IntSize(500, 500))); 112 childFrame->setView(FrameView::create(*childFrame, IntSize(500, 500)));
113 childFrame->init(); 113 childFrame->init();
114 childDocumentLoader = DocumentLoader::create( 114 childDocumentLoader = DocumentLoader::create(
115 childFrame.get(), ResourceRequest("http://www.example.com"), 115 childFrame.get(), ResourceRequest("http://www.example.com"),
116 SubstituteData(), ClientRedirectPolicy::NotClientRedirect); 116 SubstituteData(), ClientRedirectPolicy::NotClientRedirect, nullptr);
117 childDocument = childFrame->document(); 117 childDocument = childFrame->document();
118 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>( 118 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(
119 &childDocumentLoader->fetcher()->context()); 119 &childDocumentLoader->fetcher()->context());
120 FrameFetchContext::provideDocumentToContext(*childFetchContext, 120 FrameFetchContext::provideDocumentToContext(*childFetchContext,
121 childDocument.get()); 121 childDocument.get());
122 return childFetchContext; 122 return childFetchContext;
123 } 123 }
124 124
125 std::unique_ptr<DummyPageHolder> dummyPageHolder; 125 std::unique_ptr<DummyPageHolder> dummyPageHolder;
126 // 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 18 matching lines...) Expand all
145 void SetUp() override { 145 void SetUp() override {
146 url = KURL(KURL(), "https://example.test/foo"); 146 url = KURL(KURL(), "https://example.test/foo");
147 mainResourceUrl = KURL(KURL(), "https://www.example.test"); 147 mainResourceUrl = KURL(KURL(), "https://www.example.test");
148 MockFrameLoaderClient* client = new MockFrameLoaderClient; 148 MockFrameLoaderClient* client = new MockFrameLoaderClient;
149 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); 149 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url));
150 dummyPageHolder = 150 dummyPageHolder =
151 DummyPageHolder::create(IntSize(500, 500), nullptr, client); 151 DummyPageHolder::create(IntSize(500, 500), nullptr, client);
152 dummyPageHolder->page().setDeviceScaleFactor(1.0); 152 dummyPageHolder->page().setDeviceScaleFactor(1.0);
153 documentLoader = DocumentLoader::create( 153 documentLoader = DocumentLoader::create(
154 &dummyPageHolder->frame(), ResourceRequest(mainResourceUrl), 154 &dummyPageHolder->frame(), ResourceRequest(mainResourceUrl),
155 SubstituteData(), ClientRedirectPolicy::NotClientRedirect); 155 SubstituteData(), ClientRedirectPolicy::NotClientRedirect, nullptr);
156 document = &dummyPageHolder->document(); 156 document = &dummyPageHolder->document();
157 document->setURL(mainResourceUrl); 157 document->setURL(mainResourceUrl);
158 fetchContext = 158 fetchContext =
159 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context()); 159 static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context());
160 owner = DummyFrameOwner::create(); 160 owner = DummyFrameOwner::create();
161 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get()); 161 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
162 } 162 }
163 163
164 KURL url; 164 KURL url;
165 KURL mainResourceUrl; 165 KURL mainResourceUrl;
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); 804 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource);
805 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); 805 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest());
806 806
807 ResourceRequest subRequest(test.url); 807 ResourceRequest subRequest(test.url);
808 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); 808 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource);
809 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); 809 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest());
810 } 810 }
811 } 811 }
812 812
813 } // namespace blink 813 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/EmptyClients.cpp ('k') | third_party/WebKit/Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698