| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "core/testing/DummyPageHolder.h" | 42 #include "core/testing/DummyPageHolder.h" |
| 43 #include "platform/network/ResourceRequest.h" | 43 #include "platform/network/ResourceRequest.h" |
| 44 #include "platform/weborigin/KURL.h" | 44 #include "platform/weborigin/KURL.h" |
| 45 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h" | 45 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h" |
| 46 #include "testing/gtest/include/gtest/gtest.h" | 46 #include "testing/gtest/include/gtest/gtest.h" |
| 47 | 47 |
| 48 namespace blink { | 48 namespace blink { |
| 49 | 49 |
| 50 class StubFrameLoaderClientWithParent final : public EmptyFrameLoaderClient { | 50 class StubFrameLoaderClientWithParent final : public EmptyFrameLoaderClient { |
| 51 public: | 51 public: |
| 52 static PassOwnPtrWillBeRawPtr<StubFrameLoaderClientWithParent> create(Frame*
parent) | 52 static RawPtr<StubFrameLoaderClientWithParent> create(Frame* parent) |
| 53 { | 53 { |
| 54 return adoptPtrWillBeNoop(new StubFrameLoaderClientWithParent(parent)); | 54 return (new StubFrameLoaderClientWithParent(parent)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 DEFINE_INLINE_VIRTUAL_TRACE() | 57 DEFINE_INLINE_VIRTUAL_TRACE() |
| 58 { | 58 { |
| 59 visitor->trace(m_parent); | 59 visitor->trace(m_parent); |
| 60 EmptyFrameLoaderClient::trace(visitor); | 60 EmptyFrameLoaderClient::trace(visitor); |
| 61 } | 61 } |
| 62 | 62 |
| 63 Frame* parent() const override { return m_parent.get(); } | 63 Frame* parent() const override { return m_parent.get(); } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 explicit StubFrameLoaderClientWithParent(Frame* parent) | 66 explicit StubFrameLoaderClientWithParent(Frame* parent) |
| 67 : m_parent(parent) | 67 : m_parent(parent) |
| 68 { | 68 { |
| 69 } | 69 } |
| 70 | 70 |
| 71 RawPtrWillBeMember<Frame> m_parent; | 71 Member<Frame> m_parent; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class StubFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<StubFrameOwn
er>, public FrameOwner { | 74 class StubFrameOwner : public GarbageCollectedFinalized<StubFrameOwner>, public
FrameOwner { |
| 75 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StubFrameOwner); | 75 USING_GARBAGE_COLLECTED_MIXIN(StubFrameOwner); |
| 76 public: | 76 public: |
| 77 static PassOwnPtrWillBeRawPtr<StubFrameOwner> create() | 77 static RawPtr<StubFrameOwner> create() |
| 78 { | 78 { |
| 79 return adoptPtrWillBeNoop(new StubFrameOwner); | 79 return (new StubFrameOwner); |
| 80 } | 80 } |
| 81 | 81 |
| 82 DEFINE_INLINE_VIRTUAL_TRACE() { FrameOwner::trace(visitor); } | 82 DEFINE_INLINE_VIRTUAL_TRACE() { FrameOwner::trace(visitor); } |
| 83 | 83 |
| 84 bool isLocal() const override { return false; } | 84 bool isLocal() const override { return false; } |
| 85 SandboxFlags sandboxFlags() const override { return SandboxNone; } | 85 SandboxFlags sandboxFlags() const override { return SandboxNone; } |
| 86 void dispatchLoad() override { } | 86 void dispatchLoad() override { } |
| 87 void renderFallbackContent() override { } | 87 void renderFallbackContent() override { } |
| 88 ScrollbarMode scrollingMode() const override { return ScrollbarAuto; } | 88 ScrollbarMode scrollingMode() const override { return ScrollbarAuto; } |
| 89 int marginWidth() const override { return -1; } | 89 int marginWidth() const override { return -1; } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 childDocumentLoader = DocumentLoader::create(childFrame.get(), ResourceR
equest("http://www.example.com"), SubstituteData()); | 133 childDocumentLoader = DocumentLoader::create(childFrame.get(), ResourceR
equest("http://www.example.com"), SubstituteData()); |
| 134 childDocument = childFrame->document(); | 134 childDocument = childFrame->document(); |
| 135 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(&
childDocumentLoader->fetcher()->context()); | 135 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(&
childDocumentLoader->fetcher()->context()); |
| 136 FrameFetchContext::provideDocumentToContext(*childFetchContext, childDoc
ument.get()); | 136 FrameFetchContext::provideDocumentToContext(*childFetchContext, childDoc
ument.get()); |
| 137 return childFetchContext; | 137 return childFetchContext; |
| 138 } | 138 } |
| 139 | 139 |
| 140 OwnPtr<DummyPageHolder> dummyPageHolder; | 140 OwnPtr<DummyPageHolder> dummyPageHolder; |
| 141 // We don't use the DocumentLoader directly in any tests, but need to keep i
t around as long | 141 // We don't use the DocumentLoader directly in any tests, but need to keep i
t around as long |
| 142 // as the ResourceFetcher and Document live due to indirect usage. | 142 // as the ResourceFetcher and Document live due to indirect usage. |
| 143 RefPtrWillBePersistent<DocumentLoader> documentLoader; | 143 Persistent<DocumentLoader> documentLoader; |
| 144 RefPtrWillBePersistent<Document> document; | 144 Persistent<Document> document; |
| 145 Persistent<FrameFetchContext> fetchContext; | 145 Persistent<FrameFetchContext> fetchContext; |
| 146 | 146 |
| 147 OwnPtrWillBePersistent<StubFrameLoaderClientWithParent> childClient; | 147 Persistent<StubFrameLoaderClientWithParent> childClient; |
| 148 RefPtrWillBePersistent<LocalFrame> childFrame; | 148 Persistent<LocalFrame> childFrame; |
| 149 RefPtrWillBePersistent<DocumentLoader> childDocumentLoader; | 149 Persistent<DocumentLoader> childDocumentLoader; |
| 150 RefPtrWillBePersistent<Document> childDocument; | 150 Persistent<Document> childDocument; |
| 151 OwnPtrWillBePersistent<StubFrameOwner> owner; | 151 Persistent<StubFrameOwner> owner; |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 // This test class sets up a mock frame loader client that expects a | 154 // This test class sets up a mock frame loader client that expects a |
| 155 // call to didDisplayContentWithCertificateErrors(). | 155 // call to didDisplayContentWithCertificateErrors(). |
| 156 class FrameFetchContextDisplayedCertificateErrorsTest : public FrameFetchContext
Test { | 156 class FrameFetchContextDisplayedCertificateErrorsTest : public FrameFetchContext
Test { |
| 157 protected: | 157 protected: |
| 158 void SetUp() override | 158 void SetUp() override |
| 159 { | 159 { |
| 160 url = KURL(KURL(), "https://example.test/foo"); | 160 url = KURL(KURL(), "https://example.test/foo"); |
| 161 securityInfo = "security info"; | 161 securityInfo = "security info"; |
| 162 mainResourceUrl = KURL(KURL(), "https://www.example.test"); | 162 mainResourceUrl = KURL(KURL(), "https://www.example.test"); |
| 163 MockFrameLoaderClient* client = new MockFrameLoaderClient; | 163 MockFrameLoaderClient* client = new MockFrameLoaderClient; |
| 164 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit
yInfo, WebURL(mainResourceUrl), CString())); | 164 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit
yInfo, WebURL(mainResourceUrl), CString())); |
| 165 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, ad
optPtrWillBeNoop(client)); | 165 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, (c
lient)); |
| 166 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 166 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
| 167 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest(mainResourceUrl), SubstituteData()); | 167 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest(mainResourceUrl), SubstituteData()); |
| 168 document = toHTMLDocument(&dummyPageHolder->document()); | 168 document = toHTMLDocument(&dummyPageHolder->document()); |
| 169 document->setURL(mainResourceUrl); | 169 document->setURL(mainResourceUrl); |
| 170 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); | 170 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); |
| 171 owner = StubFrameOwner::create(); | 171 owner = StubFrameOwner::create(); |
| 172 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); | 172 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 KURL url; | 175 KURL url; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 | 568 |
| 569 // Tests that when a resource with certificate errors is loaded from the | 569 // Tests that when a resource with certificate errors is loaded from the |
| 570 // memory cache, the embedder is notified. | 570 // memory cache, the embedder is notified. |
| 571 TEST_F(FrameFetchContextDisplayedCertificateErrorsTest, MemoryCacheCertificateEr
ror) | 571 TEST_F(FrameFetchContextDisplayedCertificateErrorsTest, MemoryCacheCertificateEr
ror) |
| 572 { | 572 { |
| 573 ResourceRequest resourceRequest(url); | 573 ResourceRequest resourceRequest(url); |
| 574 ResourceResponse response; | 574 ResourceResponse response; |
| 575 response.setURL(url); | 575 response.setURL(url); |
| 576 response.setSecurityInfo(securityInfo); | 576 response.setSecurityInfo(securityInfo); |
| 577 response.setHasMajorCertificateErrors(true); | 577 response.setHasMajorCertificateErrors(true); |
| 578 RefPtrWillBeRawPtr<Resource> resource = Resource::create(resourceRequest, Re
source::Image); | 578 RawPtr<Resource> resource = Resource::create(resourceRequest, Resource::Imag
e); |
| 579 resource->setResponse(response); | 579 resource->setResponse(response); |
| 580 fetchContext->dispatchDidLoadResourceFromMemoryCache(resource.get(), WebURLR
equest::FrameTypeNone, WebURLRequest::RequestContextImage); | 580 fetchContext->dispatchDidLoadResourceFromMemoryCache(resource.get(), WebURLR
equest::FrameTypeNone, WebURLRequest::RequestContextImage); |
| 581 } | 581 } |
| 582 | 582 |
| 583 } // namespace blink | 583 } // namespace blink |
| OLD | NEW |