OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/macros.h" | |
6 #include "content/browser/frame_host/mixed_content_navigation_throttle.h" | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace content { | |
10 | |
11 // Tests that MixedContentNavigationThrottle correctly detects or ignores many | |
12 // cases where there is or there is not mixed content, respectively. | |
13 // Note: Browser side version of MixedContentCheckerTest.IsMixedContent. Must be | |
14 // kept in sync manually! | |
15 TEST(MixedContentNavigationThrottleTest, IsMixedContent) { | |
16 struct TestCase { | |
17 const char* origin; | |
18 const char* target; | |
19 const bool expectation; | |
20 } cases[] = { | |
21 {"http://example.com/foo", "http://example.com/foo", false}, | |
22 {"http://example.com/foo", "https://example.com/foo", false}, | |
23 {"http://example.com/foo", "data:text/html,<p>Hi!</p>", false}, | |
24 {"http://example.com/foo", "about:blank", false}, | |
25 {"https://example.com/foo", "https://example.com/foo", false}, | |
26 {"https://example.com/foo", "wss://example.com/foo", false}, | |
27 {"https://example.com/foo", "data:text/html,<p>Hi!</p>", false}, | |
28 {"https://example.com/foo", "http://127.0.0.1/", false}, | |
29 {"https://example.com/foo", "http://[::1]/", false}, | |
30 {"https://example.com/foo", "blob:https://example.com/foo", false}, | |
31 {"https://example.com/foo", "blob:http://example.com/foo", false}, | |
32 {"https://example.com/foo", "blob:null/foo", false}, | |
33 {"https://example.com/foo", "filesystem:https://example.com/foo", false}, | |
34 {"https://example.com/foo", "filesystem:http://example.com/foo", false}, | |
35 {"https://example.com/foo", "filesystem:null/foo", false}, | |
36 | |
37 {"https://example.com/foo", "http://example.com/foo", true}, | |
38 {"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://google.com/foo", true}, | |
41 {"https://example.com/foo", "http://192.168.1.1/", true}, | |
42 {"https://example.com/foo", "http://localhost/", true}, | |
43 }; | |
44 | |
45 for (const auto& test : cases) { | |
46 SCOPED_TRACE(::testing::Message() << "Origin: " << test.origin | |
47 << ", Target: " << test.target | |
48 << ", Expectation: " << test.expectation); | |
49 GURL originUrl(test.origin); | |
jam
2017/01/11 16:38:06
nit: here and below use chromium style for variabl
carlosk
2017/01/11 22:15:02
Done.
| |
50 GURL targetUrl(test.target); | |
51 EXPECT_EQ(test.expectation, | |
52 MixedContentNavigationThrottle::IsMixedContentForTesting( | |
53 originUrl, targetUrl)); | |
54 } | |
55 } | |
56 | |
57 } // content | |
OLD | NEW |