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

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: 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 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..f8dbee35a558834990a1a5f9b6a2bfa5811b96c3
--- /dev/null
+++ b/content/browser/frame_host/mixed_content_navigation_throttle_unittest.cc
@@ -0,0 +1,51 @@
+// 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 many cases where there is or there is not mixed content are
+// correctly detected by MixedContentNavigationThrottle.
+// 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", "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);
+ GURL targetUrl(test.target);
+ EXPECT_EQ(test.expectation,
+ MixedContentNavigationThrottle::IsMixedContentForTesting(
+ originUrl, targetUrl));
+ }
+}
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
+
+} // content

Powered by Google App Engine
This is Rietveld 408576698