Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 "content/browser/frame_host/mixed_content_navigation_throttle.h" | |
|
nasko
2017/02/15 17:41:39
nit: Why did this move here? It isn't the header f
carlosk
2017/02/15 21:46:31
This complies with the style guide [1] and pre-sub
| |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace content { | |
| 11 | |
| 12 // Tests that MixedContentNavigationThrottle correctly detects or ignores many | |
| 13 // cases where there is or there is not mixed content, respectively. | |
| 14 // Note: Browser side version of MixedContentCheckerTest.IsMixedContent. Must be | |
| 15 // kept in sync manually! | |
| 16 TEST(MixedContentNavigationThrottleTest, IsMixedContent) { | |
| 17 struct TestCase { | |
| 18 const char* origin; | |
| 19 const char* target; | |
| 20 const bool expected_mixed_content; | |
| 21 } cases[] = { | |
| 22 {"http://example.com/foo", "http://example.com/foo", false}, | |
| 23 {"http://example.com/foo", "https://example.com/foo", false}, | |
| 24 {"http://example.com/foo", "data:text/html,<p>Hi!</p>", false}, | |
| 25 {"http://example.com/foo", "about:blank", false}, | |
| 26 {"https://example.com/foo", "https://example.com/foo", false}, | |
| 27 {"https://example.com/foo", "wss://example.com/foo", false}, | |
| 28 {"https://example.com/foo", "data:text/html,<p>Hi!</p>", false}, | |
| 29 {"https://example.com/foo", "http://127.0.0.1/", false}, | |
| 30 {"https://example.com/foo", "http://[::1]/", false}, | |
| 31 {"https://example.com/foo", "blob:https://example.com/foo", false}, | |
| 32 {"https://example.com/foo", "blob:http://example.com/foo", false}, | |
| 33 {"https://example.com/foo", "blob:null/foo", false}, | |
| 34 {"https://example.com/foo", "filesystem:https://example.com/foo", false}, | |
| 35 {"https://example.com/foo", "filesystem:http://example.com/foo", false}, | |
| 36 {"https://example.com/foo", "filesystem:null/foo", false}, | |
| 37 | |
| 38 {"https://example.com/foo", "http://example.com/foo", true}, | |
| 39 {"https://example.com/foo", "http://google.com/foo", true}, | |
| 40 {"https://example.com/foo", "ws://example.com/foo", true}, | |
| 41 {"https://example.com/foo", "ws://google.com/foo", true}, | |
| 42 {"https://example.com/foo", "http://192.168.1.1/", true}, | |
| 43 {"https://example.com/foo", "http://localhost/", true}, | |
| 44 }; | |
| 45 | |
| 46 for (const auto& test : cases) { | |
| 47 SCOPED_TRACE(::testing::Message() | |
| 48 << "Origin: " << test.origin << ", Target: " << test.target | |
| 49 << ", Expectation: " << test.expected_mixed_content); | |
| 50 GURL origin_url(test.origin); | |
| 51 GURL target_url(test.target); | |
| 52 EXPECT_EQ(test.expected_mixed_content, | |
| 53 MixedContentNavigationThrottle::IsMixedContentForTesting( | |
| 54 origin_url, target_url)); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 } // content | |
| OLD | NEW |