| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 Member<Frame> m_parent; | 76 Member<Frame> m_parent; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class MockFrameLoaderClient : public EmptyFrameLoaderClient { | 79 class MockFrameLoaderClient : public EmptyFrameLoaderClient { |
| 80 public: | 80 public: |
| 81 MockFrameLoaderClient() | 81 MockFrameLoaderClient() |
| 82 : EmptyFrameLoaderClient() | 82 : EmptyFrameLoaderClient() |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 MOCK_METHOD2(didDisplayContentWithCertificateErrors, void(const KURL&, const
CString&)); | 85 MOCK_METHOD1(didDisplayContentWithCertificateErrors, void(const KURL&)); |
| 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 = &dummyPageHolder->document(); | 95 document = &dummyPageHolder->document(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 Persistent<DummyFrameOwner> owner; | 137 Persistent<DummyFrameOwner> owner; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 // This test class sets up a mock frame loader client that expects a | 140 // This test class sets up a mock frame loader client that expects a |
| 141 // call to didDisplayContentWithCertificateErrors(). | 141 // call to didDisplayContentWithCertificateErrors(). |
| 142 class FrameFetchContextDisplayedCertificateErrorsTest : public FrameFetchContext
Test { | 142 class FrameFetchContextDisplayedCertificateErrorsTest : public FrameFetchContext
Test { |
| 143 protected: | 143 protected: |
| 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"; | |
| 148 mainResourceUrl = KURL(KURL(), "https://www.example.test"); | 147 mainResourceUrl = KURL(KURL(), "https://www.example.test"); |
| 149 MockFrameLoaderClient* client = new MockFrameLoaderClient; | 148 MockFrameLoaderClient* client = new MockFrameLoaderClient; |
| 150 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securit
yInfo)); | 149 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url)); |
| 151 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, cl
ient); | 150 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, cl
ient); |
| 152 dummyPageHolder->page().setDeviceScaleFactor(1.0); | 151 dummyPageHolder->page().setDeviceScaleFactor(1.0); |
| 153 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest(mainResourceUrl), SubstituteData()); | 152 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou
rceRequest(mainResourceUrl), SubstituteData()); |
| 154 document = &dummyPageHolder->document(); | 153 document = &dummyPageHolder->document(); |
| 155 document->setURL(mainResourceUrl); | 154 document->setURL(mainResourceUrl); |
| 156 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); | 155 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher(
)->context()); |
| 157 owner = DummyFrameOwner::create(); | 156 owner = DummyFrameOwner::create(); |
| 158 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); | 157 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get(
)); |
| 159 } | 158 } |
| 160 | 159 |
| 161 KURL url; | 160 KURL url; |
| 162 KURL mainResourceUrl; | 161 KURL mainResourceUrl; |
| 163 CString securityInfo; | |
| 164 }; | 162 }; |
| 165 | 163 |
| 166 class FrameFetchContextUpgradeTest : public FrameFetchContextTest { | 164 class FrameFetchContextUpgradeTest : public FrameFetchContextTest { |
| 167 public: | 165 public: |
| 168 FrameFetchContextUpgradeTest() | 166 FrameFetchContextUpgradeTest() |
| 169 : exampleOrigin(SecurityOrigin::create(KURL(ParsedURLString, "https://ex
ample.test/"))) | 167 : exampleOrigin(SecurityOrigin::create(KURL(ParsedURLString, "https://ex
ample.test/"))) |
| 170 , secureOrigin(SecurityOrigin::create(KURL(ParsedURLString, "https://sec
ureorigin.test/image.png"))) | 168 , secureOrigin(SecurityOrigin::create(KURL(ParsedURLString, "https://sec
ureorigin.test/image.png"))) |
| 171 { | 169 { |
| 172 } | 170 } |
| 173 | 171 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 EXPECT_STREQ("", resourceRequest.httpHeaderField("Save-Data").utf8().data())
; | 544 EXPECT_STREQ("", resourceRequest.httpHeaderField("Save-Data").utf8().data())
; |
| 547 } | 545 } |
| 548 | 546 |
| 549 // Tests that when a resource with certificate errors is loaded from the | 547 // Tests that when a resource with certificate errors is loaded from the |
| 550 // memory cache, the embedder is notified. | 548 // memory cache, the embedder is notified. |
| 551 TEST_F(FrameFetchContextDisplayedCertificateErrorsTest, MemoryCacheCertificateEr
ror) | 549 TEST_F(FrameFetchContextDisplayedCertificateErrorsTest, MemoryCacheCertificateEr
ror) |
| 552 { | 550 { |
| 553 ResourceRequest resourceRequest(url); | 551 ResourceRequest resourceRequest(url); |
| 554 ResourceResponse response; | 552 ResourceResponse response; |
| 555 response.setURL(url); | 553 response.setURL(url); |
| 556 response.setSecurityInfo(securityInfo); | |
| 557 response.setHasMajorCertificateErrors(true); | 554 response.setHasMajorCertificateErrors(true); |
| 558 Resource* resource = Resource::create(resourceRequest, Resource::Image); | 555 Resource* resource = Resource::create(resourceRequest, Resource::Image); |
| 559 resource->setResponse(response); | 556 resource->setResponse(response); |
| 560 fetchContext->dispatchDidLoadResourceFromMemoryCache(createUniqueIdentifier(
), resource, WebURLRequest::FrameTypeNone, WebURLRequest::RequestContextImage); | 557 fetchContext->dispatchDidLoadResourceFromMemoryCache(createUniqueIdentifier(
), resource, WebURLRequest::FrameTypeNone, WebURLRequest::RequestContextImage); |
| 561 } | 558 } |
| 562 | 559 |
| 563 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPublicDocument) | 560 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPublicDocument) |
| 564 { | 561 { |
| 565 EXPECT_EQ(WebAddressSpacePublic, document->addressSpace()); | 562 EXPECT_EQ(WebAddressSpacePublic, document->addressSpace()); |
| 566 | 563 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); | 693 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); |
| 697 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); | 694 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); |
| 698 | 695 |
| 699 ResourceRequest subRequest(test.url); | 696 ResourceRequest subRequest(test.url); |
| 700 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 697 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 701 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); | 698 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); |
| 702 } | 699 } |
| 703 } | 700 } |
| 704 | 701 |
| 705 } // namespace blink | 702 } // namespace blink |
| OLD | NEW |