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

Unified 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: Moved methods from ContentBrowserClient to WebContentsDelegate; all caps constant names. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/mixed_content_navigation_throttle_unittest.cc
diff --git a/content/browser/frame_host/mixed_content_navigation_throttle_unittest.cc b/content/browser/frame_host/mixed_content_navigation_throttle_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..129de5d465725e3537c4d34708c4fa9fc513fcfb
--- /dev/null
+++ b/content/browser/frame_host/mixed_content_navigation_throttle_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/macros.h"
+#include "content/browser/frame_host/mixed_content_navigation_throttle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+// Tests that MixedContentNavigationThrottle correctly detects or ignores many
+// cases where there is or there is not mixed content, respectively.
+// Note: Browser side version of MixedContentCheckerTest.IsMixedContent. Must be
+// kept in sync manually!
+TEST(MixedContentNavigationThrottleTest, IsMixedContent) {
+ struct TestCase {
+ const char* origin;
+ const char* target;
+ const bool expectation;
+ } cases[] = {
+ {"http://example.com/foo", "http://example.com/foo", false},
+ {"http://example.com/foo", "https://example.com/foo", false},
+ {"http://example.com/foo", "data:text/html,<p>Hi!</p>", false},
+ {"http://example.com/foo", "about:blank", false},
+ {"https://example.com/foo", "https://example.com/foo", false},
+ {"https://example.com/foo", "wss://example.com/foo", false},
+ {"https://example.com/foo", "data:text/html,<p>Hi!</p>", false},
+ {"https://example.com/foo", "http://127.0.0.1/", false},
+ {"https://example.com/foo", "http://[::1]/", false},
+ {"https://example.com/foo", "blob:https://example.com/foo", false},
+ {"https://example.com/foo", "blob:http://example.com/foo", false},
+ {"https://example.com/foo", "blob:null/foo", false},
+ {"https://example.com/foo", "filesystem:https://example.com/foo", false},
+ {"https://example.com/foo", "filesystem:http://example.com/foo", false},
+ {"https://example.com/foo", "filesystem:null/foo", false},
+
+ {"https://example.com/foo", "http://example.com/foo", true},
+ {"https://example.com/foo", "http://google.com/foo", true},
+ {"https://example.com/foo", "ws://example.com/foo", true},
+ {"https://example.com/foo", "ws://google.com/foo", true},
+ {"https://example.com/foo", "http://192.168.1.1/", true},
+ {"https://example.com/foo", "http://localhost/", true},
+ };
+
+ for (const auto& test : cases) {
+ SCOPED_TRACE(::testing::Message() << "Origin: " << test.origin
+ << ", Target: " << test.target
+ << ", Expectation: " << test.expectation);
+ 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.
+ GURL targetUrl(test.target);
+ EXPECT_EQ(test.expectation,
+ MixedContentNavigationThrottle::IsMixedContentForTesting(
+ originUrl, targetUrl));
+ }
+}
+
+} // content

Powered by Google App Engine
This is Rietveld 408576698