| 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 "base/base_switches.h" | 5 #include "base/base_switches.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "chrome/browser/ui/browser_navigator.h" | 39 #include "chrome/browser/ui/browser_navigator.h" |
| 40 #include "chrome/browser/ui/browser_navigator_params.h" | 40 #include "chrome/browser/ui/browser_navigator_params.h" |
| 41 #include "chrome/browser/ui/browser_tabstrip.h" | 41 #include "chrome/browser/ui/browser_tabstrip.h" |
| 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 43 #include "chrome/common/chrome_paths.h" | 43 #include "chrome/common/chrome_paths.h" |
| 44 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/test/base/in_process_browser_test.h" | 46 #include "chrome/test/base/in_process_browser_test.h" |
| 47 #include "chrome/test/base/ui_test_utils.h" | 47 #include "chrome/test/base/ui_test_utils.h" |
| 48 #include "components/content_settings/core/browser/host_content_settings_map.h" | 48 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 49 #include "components/security_interstitials/core/controller_client.h" |
| 49 #include "components/security_interstitials/core/metrics_helper.h" | 50 #include "components/security_interstitials/core/metrics_helper.h" |
| 50 #include "components/ssl_errors/error_classification.h" | 51 #include "components/ssl_errors/error_classification.h" |
| 51 #include "components/variations/variations_associated_data.h" | 52 #include "components/variations/variations_associated_data.h" |
| 52 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 53 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 53 #include "content/public/browser/browser_context.h" | 54 #include "content/public/browser/browser_context.h" |
| 54 #include "content/public/browser/cert_store.h" | 55 #include "content/public/browser/cert_store.h" |
| 55 #include "content/public/browser/interstitial_page.h" | 56 #include "content/public/browser/interstitial_page.h" |
| 56 #include "content/public/browser/navigation_controller.h" | 57 #include "content/public/browser/navigation_controller.h" |
| 57 #include "content/public/browser/navigation_entry.h" | 58 #include "content/public/browser/navigation_entry.h" |
| 58 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 89 #include "net/cert/nss_cert_database.h" | 90 #include "net/cert/nss_cert_database.h" |
| 90 #endif // defined(USE_NSS_CERTS) | 91 #endif // defined(USE_NSS_CERTS) |
| 91 | 92 |
| 92 using base::ASCIIToUTF16; | 93 using base::ASCIIToUTF16; |
| 93 using chrome_browser_interstitials::SecurityInterstitialIDNTest; | 94 using chrome_browser_interstitials::SecurityInterstitialIDNTest; |
| 94 using content::InterstitialPage; | 95 using content::InterstitialPage; |
| 95 using content::NavigationController; | 96 using content::NavigationController; |
| 96 using content::NavigationEntry; | 97 using content::NavigationEntry; |
| 97 using content::SSLStatus; | 98 using content::SSLStatus; |
| 98 using content::WebContents; | 99 using content::WebContents; |
| 100 using security_interstitials::ControllerClient; |
| 99 using web_modal::WebContentsModalDialogManager; | 101 using web_modal::WebContentsModalDialogManager; |
| 100 | 102 |
| 101 const base::FilePath::CharType kDocRoot[] = | 103 const base::FilePath::CharType kDocRoot[] = |
| 102 FILE_PATH_LITERAL("chrome/test/data"); | 104 FILE_PATH_LITERAL("chrome/test/data"); |
| 103 | 105 |
| 104 namespace { | 106 namespace { |
| 105 | 107 |
| 106 enum ProceedDecision { | 108 enum ProceedDecision { |
| 107 SSL_INTERSTITIAL_PROCEED, | 109 SSL_INTERSTITIAL_PROCEED, |
| 108 SSL_INTERSTITIAL_DO_NOT_PROCEED | 110 SSL_INTERSTITIAL_DO_NOT_PROCEED |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 | 2314 |
| 2313 content::WindowedNotificationObserver observer( | 2315 content::WindowedNotificationObserver observer( |
| 2314 content::NOTIFICATION_LOAD_STOP, | 2316 content::NOTIFICATION_LOAD_STOP, |
| 2315 content::Source<NavigationController>(&tab->GetController())); | 2317 content::Source<NavigationController>(&tab->GetController())); |
| 2316 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 2318 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
| 2317 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 2319 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
| 2318 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 2320 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
| 2319 content::RenderViewHost* interstitial_rvh = | 2321 content::RenderViewHost* interstitial_rvh = |
| 2320 interstitial_page->GetMainFrame()->GetRenderViewHost(); | 2322 interstitial_page->GetMainFrame()->GetRenderViewHost(); |
| 2321 int result = -1; | 2323 int result = -1; |
| 2322 std::string javascript = base::StringPrintf( | 2324 std::string javascript = |
| 2323 "window.domAutomationController.send(%d);", | 2325 base::StringPrintf("window.domAutomationController.send(%d);", |
| 2324 SecurityInterstitialPage::CMD_PROCEED); | 2326 ControllerClient::CMD_PROCEED); |
| 2325 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 2327 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 2326 interstitial_rvh, javascript, &result)); | 2328 interstitial_rvh, javascript, &result)); |
| 2327 // The above will hang without the fix. | 2329 // The above will hang without the fix. |
| 2328 EXPECT_EQ(1, result); | 2330 EXPECT_EQ(1, result); |
| 2329 observer.Wait(); | 2331 observer.Wait(); |
| 2330 CheckAuthenticationBrokenState( | 2332 CheckAuthenticationBrokenState( |
| 2331 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 2333 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
| 2332 } | 2334 } |
| 2333 | 2335 |
| 2334 // Verifies that the interstitial can go back, even if JavaScript is disabled. | 2336 // Verifies that the interstitial can go back, even if JavaScript is disabled. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2347 | 2349 |
| 2348 content::WindowedNotificationObserver observer( | 2350 content::WindowedNotificationObserver observer( |
| 2349 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 2351 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 2350 content::NotificationService::AllSources()); | 2352 content::NotificationService::AllSources()); |
| 2351 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 2353 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
| 2352 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 2354 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
| 2353 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 2355 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
| 2354 content::RenderViewHost* interstitial_rvh = | 2356 content::RenderViewHost* interstitial_rvh = |
| 2355 interstitial_page->GetMainFrame()->GetRenderViewHost(); | 2357 interstitial_page->GetMainFrame()->GetRenderViewHost(); |
| 2356 int result = -1; | 2358 int result = -1; |
| 2357 std::string javascript = base::StringPrintf( | 2359 std::string javascript = |
| 2358 "window.domAutomationController.send(%d);", | 2360 base::StringPrintf("window.domAutomationController.send(%d);", |
| 2359 SecurityInterstitialPage::CMD_DONT_PROCEED); | 2361 ControllerClient::CMD_DONT_PROCEED); |
| 2360 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 2362 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 2361 interstitial_rvh, javascript, &result)); | 2363 interstitial_rvh, javascript, &result)); |
| 2362 // The above will hang without the fix. | 2364 // The above will hang without the fix. |
| 2363 EXPECT_EQ(0, result); | 2365 EXPECT_EQ(0, result); |
| 2364 observer.Wait(); | 2366 observer.Wait(); |
| 2365 EXPECT_EQ("about:blank", tab->GetVisibleURL().spec()); | 2367 EXPECT_EQ("about:blank", tab->GetVisibleURL().spec()); |
| 2366 } | 2368 } |
| 2367 | 2369 |
| 2368 // Verifies that switching tabs, while showing interstitial page, will not | 2370 // Verifies that switching tabs, while showing interstitial page, will not |
| 2369 // affect the visibility of the interestitial. | 2371 // affect the visibility of the interestitial. |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2876 | 2878 |
| 2877 // Visit a page over https that contains a frame with a redirect. | 2879 // Visit a page over https that contains a frame with a redirect. |
| 2878 | 2880 |
| 2879 // XMLHttpRequest insecure content in synchronous mode. | 2881 // XMLHttpRequest insecure content in synchronous mode. |
| 2880 | 2882 |
| 2881 // XMLHttpRequest insecure content in asynchronous mode. | 2883 // XMLHttpRequest insecure content in asynchronous mode. |
| 2882 | 2884 |
| 2883 // XMLHttpRequest over bad ssl in synchronous mode. | 2885 // XMLHttpRequest over bad ssl in synchronous mode. |
| 2884 | 2886 |
| 2885 // XMLHttpRequest over OK ssl in synchronous mode. | 2887 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |