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

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

Issue 1299493003: Attach mixed content status to resource requests when sent to devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add contextTypeForInspector() unit test Created 5 years, 4 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 | « Source/core/loader/MixedContentChecker.cpp ('k') | Source/devtools/protocol.json » ('j') | 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 "config.h" 5 #include "config.h"
6 #include "core/loader/MixedContentChecker.h" 6 #include "core/loader/MixedContentChecker.h"
7 7
8 #include "core/testing/DummyPageHolder.h"
8 #include "platform/weborigin/KURL.h" 9 #include "platform/weborigin/KURL.h"
9 #include "platform/weborigin/SecurityOrigin.h" 10 #include "platform/weborigin/SecurityOrigin.h"
10 #include "wtf/RefPtr.h" 11 #include "wtf/RefPtr.h"
11 12
12 #include <base/macros.h> 13 #include <base/macros.h>
13 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
14 15
15 namespace blink { 16 namespace blink {
16 17
17 TEST(MixedContentCheckerTest, IsMixedContent) 18 TEST(MixedContentCheckerTest, IsMixedContent)
(...skipping 18 matching lines...) Expand all
36 const char* target = cases[i].target; 37 const char* target = cases[i].target;
37 bool expectation = cases[i].expectation; 38 bool expectation = cases[i].expectation;
38 39
39 KURL originUrl(KURL(), origin); 40 KURL originUrl(KURL(), origin);
40 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)) ; 41 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)) ;
41 KURL targetUrl(KURL(), target); 42 KURL targetUrl(KURL(), target);
42 EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigi n.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Exp ectation: " << expectation; 43 EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigi n.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Exp ectation: " << expectation;
43 } 44 }
44 } 45 }
45 46
47 TEST(MixedContentCheckerTest, ContextTypeForInspector)
48 {
49 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(1, 1));
50 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("http://example.test"));
51
52 ResourceRequest notMixedContent("https://example.test/foo.jpg");
53 notMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
54 notMixedContent.setRequestContext(WebURLRequest::RequestContextScript);
55 EXPECT_EQ(MixedContentChecker::ContextTypeNotMixedContent, MixedContentCheck er::contextTypeForInspector(&dummyPageHolder->frame(), notMixedContent));
56
57 dummyPageHolder->frame().document()->setSecurityOrigin(SecurityOrigin::creat eFromString("https://example.test"));
58 EXPECT_EQ(MixedContentChecker::ContextTypeNotMixedContent, MixedContentCheck er::contextTypeForInspector(&dummyPageHolder->frame(), notMixedContent));
59
60 ResourceRequest blockableMixedContent("http://example.test/foo.jpg");
61 blockableMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
62 blockableMixedContent.setRequestContext(WebURLRequest::RequestContextScript) ;
63 EXPECT_EQ(MixedContentChecker::ContextTypeBlockable, MixedContentChecker::co ntextTypeForInspector(&dummyPageHolder->frame(), blockableMixedContent));
64
65 ResourceRequest optionallyBlockableMixedContent("http://example.test/foo.jpg ");
66 blockableMixedContent.setFrameType(WebURLRequest::FrameTypeAuxiliary);
67 blockableMixedContent.setRequestContext(WebURLRequest::RequestContextImage);
68 EXPECT_EQ(MixedContentChecker::ContextTypeOptionallyBlockable, MixedContentC hecker::contextTypeForInspector(&dummyPageHolder->frame(), blockableMixedContent ));
69 }
70
46 } // namespace blink 71 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/MixedContentChecker.cpp ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698