OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 bool seen_; | 147 bool seen_; |
148 }; | 148 }; |
149 | 149 |
150 namespace AuthState { | 150 namespace AuthState { |
151 | 151 |
152 enum AuthStateFlags { | 152 enum AuthStateFlags { |
153 NONE = 0, | 153 NONE = 0, |
154 DISPLAYED_INSECURE_CONTENT = 1 << 0, | 154 DISPLAYED_INSECURE_CONTENT = 1 << 0, |
155 RAN_INSECURE_CONTENT = 1 << 1, | 155 RAN_INSECURE_CONTENT = 1 << 1, |
156 SHOWING_INTERSTITIAL = 1 << 2, | 156 SHOWING_INTERSTITIAL = 1 << 2, |
157 SHOWING_ERROR = 1 << 3 | 157 SHOWING_ERROR = 1 << 3, |
158 // Useful when a favicon load may or may not have finised loading, to avoid | |
estark
2016/08/04 04:31:17
nit: typo, finised -> finished
jam
2016/08/04 17:41:53
Done.
| |
159 // checking if a page displayed insecure content. | |
160 DONT_CHECK_DISPLAYED_INSECURE_CONTENT = 1 << 4, | |
estark
2016/08/04 04:31:17
Just a note for posterity, this shouldn't be neces
jam
2016/08/04 17:41:53
Done.
| |
158 }; | 161 }; |
159 | 162 |
160 void Check(const NavigationEntry& entry, int expected_authentication_state) { | 163 void Check(const NavigationEntry& entry, int expected_authentication_state) { |
161 if (expected_authentication_state == AuthState::SHOWING_ERROR) { | 164 if (expected_authentication_state == AuthState::SHOWING_ERROR) { |
162 EXPECT_EQ(content::PAGE_TYPE_ERROR, entry.GetPageType()); | 165 EXPECT_EQ(content::PAGE_TYPE_ERROR, entry.GetPageType()); |
163 } else { | 166 } else { |
164 EXPECT_EQ( | 167 EXPECT_EQ( |
165 !!(expected_authentication_state & AuthState::SHOWING_INTERSTITIAL) | 168 !!(expected_authentication_state & AuthState::SHOWING_INTERSTITIAL) |
166 ? content::PAGE_TYPE_INTERSTITIAL | 169 ? content::PAGE_TYPE_INTERSTITIAL |
167 : content::PAGE_TYPE_NORMAL, | 170 : content::PAGE_TYPE_NORMAL, |
168 entry.GetPageType()); | 171 entry.GetPageType()); |
169 } | 172 } |
170 | 173 |
171 bool displayed_insecure_content = | 174 if (!(expected_authentication_state & |
172 !!(entry.GetSSL().content_status & SSLStatus::DISPLAYED_INSECURE_CONTENT); | 175 AuthState::DONT_CHECK_DISPLAYED_INSECURE_CONTENT)) { |
173 EXPECT_EQ( | 176 bool displayed_insecure_content = |
174 !!(expected_authentication_state & AuthState::DISPLAYED_INSECURE_CONTENT), | 177 !!(entry.GetSSL().content_status & |
175 displayed_insecure_content); | 178 SSLStatus::DISPLAYED_INSECURE_CONTENT); |
179 EXPECT_EQ( | |
180 !!(expected_authentication_state & | |
181 AuthState::DISPLAYED_INSECURE_CONTENT), | |
182 displayed_insecure_content); | |
183 } | |
176 | 184 |
177 bool ran_insecure_content = | 185 bool ran_insecure_content = |
178 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT); | 186 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT); |
179 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT), | 187 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT), |
180 ran_insecure_content); | 188 ran_insecure_content); |
181 } | 189 } |
182 | 190 |
183 } // namespace AuthState | 191 } // namespace AuthState |
184 | 192 |
185 namespace SecurityStyle { | 193 namespace SecurityStyle { |
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1824 | 1832 |
1825 #if defined(OS_CHROMEOS) | 1833 #if defined(OS_CHROMEOS) |
1826 // This test seems to be flaky and hang on chromiumos. | 1834 // This test seems to be flaky and hang on chromiumos. |
1827 // http://crbug.com/84419 | 1835 // http://crbug.com/84419 |
1828 #define MAYBE_TestRefNavigation DISABLED_TestRefNavigation | 1836 #define MAYBE_TestRefNavigation DISABLED_TestRefNavigation |
1829 #else | 1837 #else |
1830 #define MAYBE_TestRefNavigation TestRefNavigation | 1838 #define MAYBE_TestRefNavigation TestRefNavigation |
1831 #endif | 1839 #endif |
1832 | 1840 |
1833 // Test that navigating to a #ref does not change a bad security state. | 1841 // Test that navigating to a #ref does not change a bad security state. |
1834 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) { | 1842 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRefNavigation) { |
estark
2016/08/04 04:31:17
That's odd -- if MAYBE_ wasn't here before, maybe
jam
2016/08/04 17:41:53
true, I should have checked flakiness results.
ht
| |
1835 ASSERT_TRUE(https_server_expired_.Start()); | 1843 ASSERT_TRUE(https_server_expired_.Start()); |
1836 | 1844 |
1837 ui_test_utils::NavigateToURL( | 1845 ui_test_utils::NavigateToURL( |
1838 browser(), https_server_expired_.GetURL("/ssl/page_with_refs.html")); | 1846 browser(), https_server_expired_.GetURL("/ssl/page_with_refs.html")); |
1839 | 1847 |
1840 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1848 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1841 CheckAuthenticationBrokenState( | 1849 CheckAuthenticationBrokenState( |
1842 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1850 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
1843 | 1851 |
1844 ProceedThroughInterstitial(tab); | 1852 ProceedThroughInterstitial(tab); |
1845 | 1853 |
1846 CheckAuthenticationBrokenState( | 1854 CheckAuthenticationBrokenState( |
1847 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1855 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
1848 // Now navigate to a ref in the page, the security state should not have | 1856 // Now navigate to a ref in the page, the security state should not have |
1849 // changed. | 1857 // changed. |
1850 ui_test_utils::NavigateToURL( | 1858 ui_test_utils::NavigateToURL( |
1851 browser(), https_server_expired_.GetURL("/ssl/page_with_refs.html#jp")); | 1859 browser(), https_server_expired_.GetURL("/ssl/page_with_refs.html#jp")); |
1852 | 1860 |
1853 CheckAuthenticationBrokenState( | 1861 CheckAuthenticationBrokenState( |
1854 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1862 tab, net::CERT_STATUS_DATE_INVALID, |
1863 AuthState::DONT_CHECK_DISPLAYED_INSECURE_CONTENT); | |
1855 } | 1864 } |
1856 | 1865 |
1857 // Tests that closing a page that opened a pop-up with an interstitial does not | 1866 // Tests that closing a page that opened a pop-up with an interstitial does not |
1858 // crash the browser (crbug.com/1966). | 1867 // crash the browser (crbug.com/1966). |
1859 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCloseTabWithUnsafePopup) { | 1868 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCloseTabWithUnsafePopup) { |
1860 ASSERT_TRUE(embedded_test_server()->Start()); | 1869 ASSERT_TRUE(embedded_test_server()->Start()); |
1861 ASSERT_TRUE(https_server_expired_.Start()); | 1870 ASSERT_TRUE(https_server_expired_.Start()); |
1862 | 1871 |
1863 // Enable popups without user gesture. | 1872 // Enable popups without user gesture. |
1864 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) | 1873 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2162 content::Source<NavigationController>(&tab->GetController())); | 2171 content::Source<NavigationController>(&tab->GetController())); |
2163 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 2172 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
2164 tab, | 2173 tab, |
2165 "window.domAutomationController.send(clickLink('goodHTTPSLink'));", | 2174 "window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
2166 &success)); | 2175 &success)); |
2167 ASSERT_TRUE(success); | 2176 ASSERT_TRUE(success); |
2168 observer.Wait(); | 2177 observer.Wait(); |
2169 | 2178 |
2170 // We should still be authentication broken. | 2179 // We should still be authentication broken. |
2171 CheckAuthenticationBrokenState( | 2180 CheckAuthenticationBrokenState( |
2172 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 2181 tab, net::CERT_STATUS_DATE_INVALID, |
2182 AuthState::DONT_CHECK_DISPLAYED_INSECURE_CONTENT); | |
2173 } | 2183 } |
2174 | 2184 |
2175 // From an HTTP top frame, navigate to good and bad HTTPS (security state should | 2185 // From an HTTP top frame, navigate to good and bad HTTPS (security state should |
2176 // stay unauthenticated). | 2186 // stay unauthenticated). |
2177 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnauthenticatedFrameNavigation) { | 2187 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnauthenticatedFrameNavigation) { |
2178 ASSERT_TRUE(embedded_test_server()->Start()); | 2188 ASSERT_TRUE(embedded_test_server()->Start()); |
2179 ASSERT_TRUE(https_server_.Start()); | 2189 ASSERT_TRUE(https_server_.Start()); |
2180 ASSERT_TRUE(https_server_expired_.Start()); | 2190 ASSERT_TRUE(https_server_expired_.Start()); |
2181 | 2191 |
2182 std::string top_frame_path; | 2192 std::string top_frame_path; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2277 | 2287 |
2278 // Navigate to safe page that has Worker loading unsafe content. | 2288 // Navigate to safe page that has Worker loading unsafe content. |
2279 // Expect content to load but be marked as auth broken due to running insecure | 2289 // Expect content to load but be marked as auth broken due to running insecure |
2280 // content. | 2290 // content. |
2281 std::string page_with_unsafe_worker_path; | 2291 std::string page_with_unsafe_worker_path; |
2282 GetPageWithUnsafeWorkerPath(https_server_mismatched_, | 2292 GetPageWithUnsafeWorkerPath(https_server_mismatched_, |
2283 &page_with_unsafe_worker_path); | 2293 &page_with_unsafe_worker_path); |
2284 ui_test_utils::NavigateToURL( | 2294 ui_test_utils::NavigateToURL( |
2285 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); | 2295 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); |
2286 CheckWorkerLoadResult(tab, true); // Worker loads insecure content | 2296 CheckWorkerLoadResult(tab, true); // Worker loads insecure content |
2287 CheckAuthenticationBrokenState(tab, CertError::NONE, | 2297 CheckAuthenticationBrokenState( |
2288 AuthState::RAN_INSECURE_CONTENT); | 2298 tab, CertError::NONE, |
2299 AuthState::RAN_INSECURE_CONTENT | | |
2300 AuthState::DONT_CHECK_DISPLAYED_INSECURE_CONTENT); | |
2289 } | 2301 } |
2290 | 2302 |
2291 // Visits a page with unsafe content and makes sure that if a user exception to | 2303 // Visits a page with unsafe content and makes sure that if a user exception to |
2292 // the certificate error is present, the image is loaded and script executes. | 2304 // the certificate error is present, the image is loaded and script executes. |
2293 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { | 2305 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { |
2294 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2306 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2295 ASSERT_NO_FATAL_FAILURE(SetUpUnsafeContentsWithUserException( | 2307 ASSERT_NO_FATAL_FAILURE(SetUpUnsafeContentsWithUserException( |
2296 "/ssl/page_with_unsafe_contents.html")); | 2308 "/ssl/page_with_unsafe_contents.html")); |
2297 CheckAuthenticationBrokenState( | 2309 CheckAuthenticationBrokenState( |
2298 tab, CertError::NONE, | 2310 tab, CertError::NONE, |
(...skipping 18 matching lines...) Expand all Loading... | |
2317 std::string replacement_path; | 2329 std::string replacement_path; |
2318 GetFilePathWithHostAndPortReplacement( | 2330 GetFilePathWithHostAndPortReplacement( |
2319 "/ssl/page_with_unsafe_contents.html", | 2331 "/ssl/page_with_unsafe_contents.html", |
2320 https_server_mismatched_.host_port_pair(), &replacement_path); | 2332 https_server_mismatched_.host_port_pair(), &replacement_path); |
2321 ui_test_utils::NavigateToURL( | 2333 ui_test_utils::NavigateToURL( |
2322 browser(), https_server_mismatched_.GetURL(replacement_path)); | 2334 browser(), https_server_mismatched_.GetURL(replacement_path)); |
2323 js_result = false; | 2335 js_result = false; |
2324 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 2336 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
2325 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); | 2337 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); |
2326 EXPECT_TRUE(js_result); | 2338 EXPECT_TRUE(js_result); |
2327 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 2339 CheckAuthenticationBrokenState( |
2328 AuthState::NONE); | 2340 tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
2341 AuthState::DONT_CHECK_DISPLAYED_INSECURE_CONTENT); | |
2329 } | 2342 } |
2330 | 2343 |
2331 // Like the test above, but only displaying inactive content (an image). | 2344 // Like the test above, but only displaying inactive content (an image). |
2332 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) { | 2345 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) { |
2333 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2346 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2334 ASSERT_NO_FATAL_FAILURE( | 2347 ASSERT_NO_FATAL_FAILURE( |
2335 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html")); | 2348 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html")); |
2336 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); | 2349 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); |
2337 | 2350 |
2338 int img_width; | 2351 int img_width; |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2997 | 3010 |
2998 // Visit a page over https that contains a frame with a redirect. | 3011 // Visit a page over https that contains a frame with a redirect. |
2999 | 3012 |
3000 // XMLHttpRequest insecure content in synchronous mode. | 3013 // XMLHttpRequest insecure content in synchronous mode. |
3001 | 3014 |
3002 // XMLHttpRequest insecure content in asynchronous mode. | 3015 // XMLHttpRequest insecure content in asynchronous mode. |
3003 | 3016 |
3004 // XMLHttpRequest over bad ssl in synchronous mode. | 3017 // XMLHttpRequest over bad ssl in synchronous mode. |
3005 | 3018 |
3006 // XMLHttpRequest over OK ssl in synchronous mode. | 3019 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |