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

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

Issue 2126753003: `about:blank` is not mixed content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/MixedContentChecker.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 10 matching lines...) Expand all
21 TEST(MixedContentCheckerTest, IsMixedContent) 21 TEST(MixedContentCheckerTest, IsMixedContent)
22 { 22 {
23 struct TestCase { 23 struct TestCase {
24 const char* origin; 24 const char* origin;
25 const char* target; 25 const char* target;
26 bool expectation; 26 bool expectation;
27 } cases[] = { 27 } cases[] = {
28 {"http://example.com/foo", "http://example.com/foo", false}, 28 {"http://example.com/foo", "http://example.com/foo", false},
29 {"http://example.com/foo", "https://example.com/foo", false}, 29 {"http://example.com/foo", "https://example.com/foo", false},
30 {"http://example.com/foo", "data:text/html,<p>Hi!</p>", false}, 30 {"http://example.com/foo", "data:text/html,<p>Hi!</p>", false},
31 {"http://example.com/foo", "about:blank", false},
31 {"https://example.com/foo", "https://example.com/foo", false}, 32 {"https://example.com/foo", "https://example.com/foo", false},
32 {"https://example.com/foo", "wss://example.com/foo", false}, 33 {"https://example.com/foo", "wss://example.com/foo", false},
33 {"https://example.com/foo", "data:text/html,<p>Hi!</p>", false}, 34 {"https://example.com/foo", "data:text/html,<p>Hi!</p>", false},
34 {"https://example.com/foo", "http://127.0.0.1/", false}, 35 {"https://example.com/foo", "http://127.0.0.1/", false},
35 {"https://example.com/foo", "http://[::1]/", false}, 36 {"https://example.com/foo", "http://[::1]/", false},
36 37
37 {"https://example.com/foo", "http://example.com/foo", true}, 38 {"https://example.com/foo", "http://example.com/foo", true},
38 {"https://example.com/foo", "http://google.com/foo", true}, 39 {"https://example.com/foo", "http://google.com/foo", true},
39 {"https://example.com/foo", "ws://example.com/foo", true}, 40 {"https://example.com/foo", "ws://example.com/foo", true},
40 {"https://example.com/foo", "ws://google.com/foo", true}, 41 {"https://example.com/foo", "ws://google.com/foo", true},
41 {"https://example.com/foo", "http://192.168.1.1/", true}, 42 {"https://example.com/foo", "http://192.168.1.1/", true},
42 {"https://example.com/foo", "http://localhost/", true}, 43 {"https://example.com/foo", "http://localhost/", true},
43 }; 44 };
44 45
45 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); ++i) { 46 for (const auto& test : cases) {
46 const char* origin = cases[i].origin; 47 SCOPED_TRACE(::testing::Message() << "Origin: " << test.origin << ", Tar get: " << test.target << ", Expectation: " << test.expectation);
47 const char* target = cases[i].target; 48 KURL originUrl(KURL(), test.origin);
48 bool expectation = cases[i].expectation;
49
50 KURL originUrl(KURL(), origin);
51 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)) ; 49 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)) ;
52 KURL targetUrl(KURL(), target); 50 KURL targetUrl(KURL(), test.target);
53 EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigi n.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Exp ectation: " << expectation; 51 EXPECT_EQ(test.expectation, MixedContentChecker::isMixedContent(security Origin.get(), targetUrl));
54 } 52 }
55 } 53 }
56 54
57 TEST(MixedContentCheckerTest, ContextTypeForInspector) 55 TEST(MixedContentCheckerTest, ContextTypeForInspector)
58 { 56 {
59 std::unique_ptr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(I ntSize(1, 1)); 57 std::unique_ptr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(I ntSize(1, 1));
60 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("http://example.test")); 58 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("http://example.test"));
61 59
62 ResourceRequest notMixedContent("https://example.test/foo.jpg"); 60 ResourceRequest notMixedContent("https://example.test/foo.jpg");
63 notMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary); 61 notMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 ResourceResponse response2; 109 ResourceResponse response2;
112 WebURLRequest::RequestContext requestContext = WebURLRequest::RequestContext Image; 110 WebURLRequest::RequestContext requestContext = WebURLRequest::RequestContext Image;
113 ASSERT_EQ(WebMixedContent::ContextType::OptionallyBlockable, WebMixedContent ::contextTypeFromRequestContext(requestContext, dummyPageHolder->frame().setting s()->strictMixedContentCheckingForPlugin())); 111 ASSERT_EQ(WebMixedContent::ContextType::OptionallyBlockable, WebMixedContent ::contextTypeFromRequestContext(requestContext, dummyPageHolder->frame().setting s()->strictMixedContentCheckingForPlugin()));
114 response2.setURL(displayedUrl); 112 response2.setURL(displayedUrl);
115 response2.setSecurityInfo("security info2"); 113 response2.setSecurityInfo("security info2");
116 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(displayedUrl, re sponse2.getSecurityInfo())); 114 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(displayedUrl, re sponse2.getSecurityInfo()));
117 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), respo nse2, WebURLRequest::FrameTypeNone, requestContext); 115 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), respo nse2, WebURLRequest::FrameTypeNone, requestContext);
118 } 116 }
119 117
120 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/MixedContentChecker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698