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

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

Issue 1415923015: Downgrade lock icon for broken-HTTPS subresources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove console message; see comment to mike Created 5 years 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 "config.h" 5 #include "config.h"
6 #include "core/loader/MixedContentChecker.h" 6 #include "core/loader/MixedContentChecker.h"
7 7
8 #include "core/loader/EmptyClients.h"
8 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "platform/network/ResourceResponse.h"
9 #include "platform/weborigin/KURL.h" 11 #include "platform/weborigin/KURL.h"
10 #include "platform/weborigin/SecurityOrigin.h" 12 #include "platform/weborigin/SecurityOrigin.h"
13 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 #include "wtf/RefPtr.h" 15 #include "wtf/RefPtr.h"
13 #include <base/macros.h> 16 #include <base/macros.h>
14 17
15 namespace blink { 18 namespace blink {
16 19
17 TEST(MixedContentCheckerTest, IsMixedContent) 20 TEST(MixedContentCheckerTest, IsMixedContent)
18 { 21 {
19 struct TestCase { 22 struct TestCase {
20 const char* origin; 23 const char* origin;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 blockableMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary); 63 blockableMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
61 blockableMixedContent.setRequestContext(WebURLRequest::RequestContextScript) ; 64 blockableMixedContent.setRequestContext(WebURLRequest::RequestContextScript) ;
62 EXPECT_EQ(MixedContentChecker::ContextTypeBlockable, MixedContentChecker::co ntextTypeForInspector(&dummyPageHolder->frame(), blockableMixedContent)); 65 EXPECT_EQ(MixedContentChecker::ContextTypeBlockable, MixedContentChecker::co ntextTypeForInspector(&dummyPageHolder->frame(), blockableMixedContent));
63 66
64 ResourceRequest optionallyBlockableMixedContent("http://example.test/foo.jpg "); 67 ResourceRequest optionallyBlockableMixedContent("http://example.test/foo.jpg ");
65 blockableMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary); 68 blockableMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
66 blockableMixedContent.setRequestContext(WebURLRequest::RequestContextImage); 69 blockableMixedContent.setRequestContext(WebURLRequest::RequestContextImage);
67 EXPECT_EQ(MixedContentChecker::ContextTypeOptionallyBlockable, MixedContentC hecker::contextTypeForInspector(&dummyPageHolder->frame(), blockableMixedContent )); 70 EXPECT_EQ(MixedContentChecker::ContextTypeOptionallyBlockable, MixedContentC hecker::contextTypeForInspector(&dummyPageHolder->frame(), blockableMixedContent ));
68 } 71 }
69 72
73 namespace {
74
75 class MockFrameLoaderClient : public EmptyFrameLoaderClient {
76 public:
77 MockFrameLoaderClient()
78 : EmptyFrameLoaderClient()
79 {
80 }
81 MOCK_METHOD4(didDisplayContentWithCertificateErrors, void(const KURL&, c onst CString&, const WebURL&, const CString&));
82 MOCK_METHOD4(didRunContentWithCertificateErrors, void(const KURL&, const CString&, const WebURL&, const CString&));
83 };
84
85 } // namespace
86
87 TEST(MixedContentCheckerTest, HandleCertificateError)
88 {
89 MockFrameLoaderClient* client = new MockFrameLoaderClient;
90 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(1, 1), nullptr, adoptPtrWillBeNoop(client));
91
92 KURL mainResourceUrl(KURL(), "https://example.test");
93 KURL displayedUrl(KURL(), "https://example-displayed.test");
94 KURL ranUrl(KURL(), "https://example-ran.test");
95
96 dummyPageHolder->frame().document()->setURL(mainResourceUrl);
97 ResourceRequest request1(ranUrl);
98 request1.setRequestContext(WebURLRequest::RequestContextScript);
99 request1.setFrameType(WebURLRequest::FrameTypeNone);
100 ResourceResponse response1;
101 response1.setURL(ranUrl);
102 response1.setSecurityInfo("security info1");
103 EXPECT_CALL(*client, didRunContentWithCertificateErrors(ranUrl, response1.ge tSecurityInfo(), WebURL(mainResourceUrl), CString()));
104 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), reque st1, response1);
105
106 ResourceRequest request2(displayedUrl);
107 request2.setRequestContext(WebURLRequest::RequestContextImage);
108 request2.setFrameType(WebURLRequest::FrameTypeNone);
109 ResourceResponse response2;
110 ASSERT_EQ(MixedContentChecker::ContextTypeOptionallyBlockable, MixedContentC hecker::contextTypeFromContext(request2.requestContext(), &dummyPageHolder->fram e()));
111 response2.setURL(displayedUrl);
112 response2.setSecurityInfo("security info2");
113 EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(displayedUrl, re sponse2.getSecurityInfo(), WebURL(mainResourceUrl), CString()));
114 MixedContentChecker::handleCertificateError(&dummyPageHolder->frame(), reque st2, response2);
115 }
116
70 } // namespace blink 117 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698