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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 private: | 66 private: |
67 explicit StubFrameLoaderClientWithParent(Frame* parent) | 67 explicit StubFrameLoaderClientWithParent(Frame* parent) |
68 : m_parent(parent) | 68 : m_parent(parent) |
69 { | 69 { |
70 } | 70 } |
71 | 71 |
72 RawPtrWillBeMember<Frame> m_parent; | 72 RawPtrWillBeMember<Frame> m_parent; |
73 }; | 73 }; |
74 | 74 |
75 class StubFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<StubFrameOwn
er>, public FrameOwner { | |
76 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StubFrameOwner); | |
77 public: | |
78 static PassOwnPtrWillBeRawPtr<StubFrameOwner> create() | |
79 { | |
80 return adoptPtrWillBeNoop(new StubFrameOwner); | |
81 } | |
82 | |
83 DEFINE_INLINE_VIRTUAL_TRACE() { FrameOwner::trace(visitor); } | |
84 | |
85 bool isLocal() const override { return false; } | |
86 SandboxFlags getSandboxFlags() const override { return SandboxNone; } | |
87 void dispatchLoad() override { } | |
88 void renderFallbackContent() override { } | |
89 ScrollbarMode scrollingMode() const override { return ScrollbarAuto; } | |
90 int marginWidth() const override { return -1; } | |
91 int marginHeight() const override { return -1; } | |
92 }; | |
93 | |
94 class MockFrameLoaderClient : public EmptyFrameLoaderClient { | 75 class MockFrameLoaderClient : public EmptyFrameLoaderClient { |
95 public: | 76 public: |
96 MockFrameLoaderClient() | 77 MockFrameLoaderClient() |
97 : EmptyFrameLoaderClient() | 78 : EmptyFrameLoaderClient() |
98 { | 79 { |
99 } | 80 } |
100 MOCK_METHOD4(didDisplayContentWithCertificateErrors, void(const KURL&, const
CString&, const WebURL&, const CString&)); | 81 MOCK_METHOD4(didDisplayContentWithCertificateErrors, void(const KURL&, const
CString&, const WebURL&, const CString&)); |
101 }; | 82 }; |
102 | 83 |
103 class FrameFetchContextTest : public ::testing::Test { | 84 class FrameFetchContextTest : public ::testing::Test { |
104 protected: | 85 protected: |
105 void SetUp() override | 86 void SetUp() override |
106 { | 87 { |
107 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); | 88 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); |
108 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 89 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
109 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest("http://www.example.com"), SubstituteData()); | 90 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest("http://www.example.com"), SubstituteData()); |
110 document = toHTMLDocument(&dummyPageHolder->document()); | 91 document = toHTMLDocument(&dummyPageHolder->document()); |
111 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); | 92 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); |
112 owner = StubFrameOwner::create(); | 93 owner = DummyFrameOwner::create(); |
113 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); | 94 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); |
114 } | 95 } |
115 | 96 |
116 void TearDown() override | 97 void TearDown() override |
117 { | 98 { |
118 documentLoader->detachFromFrame(); | 99 documentLoader->detachFromFrame(); |
119 documentLoader.clear(); | 100 documentLoader.clear(); |
120 | 101 |
121 if (childFrame) { | 102 if (childFrame) { |
122 childDocumentLoader->detachFromFrame(); | 103 childDocumentLoader->detachFromFrame(); |
(...skipping 19 matching lines...) Expand all Loading... |
142 // We don't use the DocumentLoader directly in any tests, but need to keep i
t around as long | 123 // We don't use the DocumentLoader directly in any tests, but need to keep i
t around as long |
143 // as the ResourceFetcher and Document live due to indirect usage. | 124 // as the ResourceFetcher and Document live due to indirect usage. |
144 RefPtrWillBePersistent<DocumentLoader> documentLoader; | 125 RefPtrWillBePersistent<DocumentLoader> documentLoader; |
145 RefPtrWillBePersistent<Document> document; | 126 RefPtrWillBePersistent<Document> document; |
146 Persistent<FrameFetchContext> fetchContext; | 127 Persistent<FrameFetchContext> fetchContext; |
147 | 128 |
148 OwnPtrWillBePersistent<StubFrameLoaderClientWithParent> childClient; | 129 OwnPtrWillBePersistent<StubFrameLoaderClientWithParent> childClient; |
149 RefPtrWillBePersistent<LocalFrame> childFrame; | 130 RefPtrWillBePersistent<LocalFrame> childFrame; |
150 RefPtrWillBePersistent<DocumentLoader> childDocumentLoader; | 131 RefPtrWillBePersistent<DocumentLoader> childDocumentLoader; |
151 RefPtrWillBePersistent<Document> childDocument; | 132 RefPtrWillBePersistent<Document> childDocument; |
152 OwnPtrWillBePersistent<StubFrameOwner> owner; | 133 OwnPtrWillBePersistent<DummyFrameOwner> owner; |
153 }; | 134 }; |
154 | 135 |
155 // This test class sets up a mock frame loader client that expects a | 136 // This test class sets up a mock frame loader client that expects a |
156 // call to didDisplayContentWithCertificateErrors(). | 137 // call to didDisplayContentWithCertificateErrors(). |
157 class FrameFetchContextDisplayedCertificateErrorsTest : public FrameFetchContext
Test { | 138 class FrameFetchContextDisplayedCertificateErrorsTest : public FrameFetchContext
Test { |
158 protected: | 139 protected: |
159 void SetUp() override | 140 void SetUp() override |
160 { | 141 { |
161 url = KURL(KURL(), "https://example.test/foo"); | 142 url = KURL(KURL(), "https://example.test/foo"); |
162 securityInfo = "security info"; | 143 securityInfo = "security info"; |
163 mainResourceUrl = KURL(KURL(), "https://www.example.test"); | 144 mainResourceUrl = KURL(KURL(), "https://www.example.test"); |
164 MockFrameLoaderClient* client = new MockFrameLoaderClient; | 145 MockFrameLoaderClient* client = new MockFrameLoaderClient; |
165 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit
yInfo, WebURL(mainResourceUrl), CString())); | 146 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit
yInfo, WebURL(mainResourceUrl), CString())); |
166 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, ad
optPtrWillBeNoop(client)); | 147 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, ad
optPtrWillBeNoop(client)); |
167 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 148 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
168 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest(mainResourceUrl), SubstituteData()); | 149 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest(mainResourceUrl), SubstituteData()); |
169 document = toHTMLDocument(&dummyPageHolder->document()); | 150 document = toHTMLDocument(&dummyPageHolder->document()); |
170 document->setURL(mainResourceUrl); | 151 document->setURL(mainResourceUrl); |
171 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); | 152 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); |
172 owner = StubFrameOwner::create(); | 153 owner = DummyFrameOwner::create(); |
173 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); | 154 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); |
174 } | 155 } |
175 | 156 |
176 KURL url; | 157 KURL url; |
177 KURL mainResourceUrl; | 158 KURL mainResourceUrl; |
178 CString securityInfo; | 159 CString securityInfo; |
179 }; | 160 }; |
180 | 161 |
181 class FrameFetchContextUpgradeTest : public FrameFetchContextTest { | 162 class FrameFetchContextUpgradeTest : public FrameFetchContextTest { |
182 public: | 163 public: |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); | 709 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); |
729 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); | 710 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); |
730 | 711 |
731 ResourceRequest subRequest(test.url); | 712 ResourceRequest subRequest(test.url); |
732 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 713 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
733 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); | 714 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); |
734 } | 715 } |
735 } | 716 } |
736 | 717 |
737 } // namespace blink | 718 } // namespace blink |
OLD | NEW |