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: content/browser/frame_host/mixed_content_navigation_throttle_unittest.cc

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Fixed external handling order change for request start and redirects. 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
OLDNEW
(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 many cases where there is or there is not mixed content are
12 // correctly detected by MixedContentNavigationThrottle.
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
31 {"https://example.com/foo", "http://example.com/foo", true},
32 {"https://example.com/foo", "http://google.com/foo", true},
33 {"https://example.com/foo", "ws://example.com/foo", true},
34 {"https://example.com/foo", "ws://google.com/foo", true},
35 {"https://example.com/foo", "http://192.168.1.1/", true},
36 {"https://example.com/foo", "http://localhost/", true},
37 };
38
39 for (const auto& test : cases) {
40 SCOPED_TRACE(::testing::Message() << "Origin: " << test.origin
41 << ", Target: " << test.target
42 << ", Expectation: " << test.expectation);
43 GURL originUrl(test.origin);
44 GURL targetUrl(test.target);
45 EXPECT_EQ(test.expectation,
46 MixedContentNavigationThrottle::IsMixedContentForTesting(
47 originUrl, targetUrl));
48 }
49 }
Mike West 2016/07/19 14:41:39 I think we should have more extensive tests here t
carlosk 2016/07/19 16:32:16 Noted! But layout tests are not be enough anymore
50
51 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698