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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/loader/MixedContentChecker.h" 5 #include "core/loader/MixedContentChecker.h"
6 6
7 #include "core/frame/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/loader/EmptyClients.h" 8 #include "core/loader/EmptyClients.h"
9 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "platform/network/ResourceResponse.h" 10 #include "platform/network/ResourceResponse.h"
11 #include "platform/weborigin/KURL.h" 11 #include "platform/weborigin/KURL.h"
12 #include "platform/weborigin/SecurityOrigin.h" 12 #include "platform/weborigin/SecurityOrigin.h"
13 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h" 13 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "wtf/RefPtr.h" 15 #include "wtf/RefPtr.h"
16 #include <base/macros.h> 16 #include <base/macros.h>
17 #include <memory>
18 17
19 namespace blink { 18 namespace blink {
20 19
21 TEST(MixedContentCheckerTest, IsMixedContent) 20 TEST(MixedContentCheckerTest, IsMixedContent)
22 { 21 {
23 struct TestCase { 22 struct TestCase {
24 const char* origin; 23 const char* origin;
25 const char* target; 24 const char* target;
26 bool expectation; 25 bool expectation;
27 } cases[] = { 26 } cases[] = {
(...skipping 14 matching lines...) Expand all
42 41
43 KURL originUrl(KURL(), origin); 42 KURL originUrl(KURL(), origin);
44 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)) ; 43 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)) ;
45 KURL targetUrl(KURL(), target); 44 KURL targetUrl(KURL(), target);
46 EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigi n.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Exp ectation: " << expectation; 45 EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigi n.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Exp ectation: " << expectation;
47 } 46 }
48 } 47 }
49 48
50 TEST(MixedContentCheckerTest, ContextTypeForInspector) 49 TEST(MixedContentCheckerTest, ContextTypeForInspector)
51 { 50 {
52 std::unique_ptr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(I ntSize(1, 1)); 51 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(1, 1));
53 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("http://example.test")); 52 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("http://example.test"));
54 53
55 ResourceRequest notMixedContent("https://example.test/foo.jpg"); 54 ResourceRequest notMixedContent("https://example.test/foo.jpg");
56 notMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary); 55 notMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
57 notMixedContent.setRequestContext(WebURLRequest::RequestContextScript); 56 notMixedContent.setRequestContext(WebURLRequest::RequestContextScript);
58 EXPECT_EQ(WebMixedContent::ContextType::NotMixedContent, MixedContentChecker ::contextTypeForInspector(&dummyPageHolder->frame(), notMixedContent)); 57 EXPECT_EQ(WebMixedContent::ContextType::NotMixedContent, MixedContentChecker ::contextTypeForInspector(&dummyPageHolder->frame(), notMixedContent));
59 58
60 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("https://example.test")); 59 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("https://example.test"));
61 EXPECT_EQ(WebMixedContent::ContextType::NotMixedContent, MixedContentChecker ::contextTypeForInspector(&dummyPageHolder->frame(), notMixedContent)); 60 EXPECT_EQ(WebMixedContent::ContextType::NotMixedContent, MixedContentChecker ::contextTypeForInspector(&dummyPageHolder->frame(), notMixedContent));
62 61
(...skipping 18 matching lines...) Expand all
81 } 80 }
82 MOCK_METHOD2(didDisplayContentWithCertificateErrors, void(const KURL&, c onst CString&)); 81 MOCK_METHOD2(didDisplayContentWithCertificateErrors, void(const KURL&, c onst CString&));
83 MOCK_METHOD2(didRunContentWithCertificateErrors, void(const KURL&, const CString&)); 82 MOCK_METHOD2(didRunContentWithCertificateErrors, void(const KURL&, const CString&));
84 }; 83 };
85 84
86 } // namespace 85 } // namespace
87 86
88 TEST(MixedContentCheckerTest, HandleCertificateError) 87 TEST(MixedContentCheckerTest, HandleCertificateError)
89 { 88 {
90 MockFrameLoaderClient* client = new MockFrameLoaderClient; 89 MockFrameLoaderClient* client = new MockFrameLoaderClient;
91 std::unique_ptr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(I ntSize(1, 1), nullptr, client); 90 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(1, 1), nullptr, client);
92 91
93 KURL mainResourceUrl(KURL(), "https://example.test"); 92 KURL mainResourceUrl(KURL(), "https://example.test");
94 KURL displayedUrl(KURL(), "https://example-displayed.test"); 93 KURL displayedUrl(KURL(), "https://example-displayed.test");
95 KURL ranUrl(KURL(), "https://example-ran.test"); 94 KURL ranUrl(KURL(), "https://example-ran.test");
96 95
97 dummyPageHolder->frame().document()->setURL(mainResourceUrl); 96 dummyPageHolder->frame().document()->setURL(mainResourceUrl);
98 ResourceResponse response1; 97 ResourceResponse response1;
99 response1.setURL(ranUrl); 98 response1.setURL(ranUrl);
100 response1.setSecurityInfo("security info1"); 99 response1.setSecurityInfo("security info1");
101 EXPECT_CALL(*client, didRunContentWithCertificateErrors(ranUrl, response1.ge tSecurityInfo())); 100 EXPECT_CALL(*client, didRunContentWithCertificateErrors(ranUrl, response1.ge tSecurityInfo()));
102 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), respo nse1, WebURLRequest::FrameTypeNone, WebURLRequest::RequestContextScript); 101 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), respo nse1, WebURLRequest::FrameTypeNone, WebURLRequest::RequestContextScript);
103 102
104 ResourceResponse response2; 103 ResourceResponse response2;
105 WebURLRequest::RequestContext requestContext = WebURLRequest::RequestContext Image; 104 WebURLRequest::RequestContext requestContext = WebURLRequest::RequestContext Image;
106 ASSERT_EQ(WebMixedContent::ContextType::OptionallyBlockable, WebMixedContent ::contextTypeFromRequestContext(requestContext, dummyPageHolder->frame().setting s()->strictMixedContentCheckingForPlugin())); 105 ASSERT_EQ(WebMixedContent::ContextType::OptionallyBlockable, WebMixedContent ::contextTypeFromRequestContext(requestContext, dummyPageHolder->frame().setting s()->strictMixedContentCheckingForPlugin()));
107 response2.setURL(displayedUrl); 106 response2.setURL(displayedUrl);
108 response2.setSecurityInfo("security info2"); 107 response2.setSecurityInfo("security info2");
109 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(displayedUrl, re sponse2.getSecurityInfo())); 108 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(displayedUrl, re sponse2.getSecurityInfo()));
110 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), respo nse2, WebURLRequest::FrameTypeNone, requestContext); 109 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), respo nse2, WebURLRequest::FrameTypeNone, requestContext);
111 } 110 }
112 111
113 } // namespace blink 112 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp ('k') | third_party/WebKit/Source/core/loader/MockThreadableLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698