| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // Check that |observer|'s latest event was for an expired certificate | 388 // Check that |observer|'s latest event was for an expired certificate |
| 389 // and that it saw the proper SecurityStyle and explanations. | 389 // and that it saw the proper SecurityStyle and explanations. |
| 390 void CheckBrokenSecurityStyle(const SecurityStyleTestObserver& observer, | 390 void CheckBrokenSecurityStyle(const SecurityStyleTestObserver& observer, |
| 391 int error, | 391 int error, |
| 392 Browser* browser) { | 392 Browser* browser) { |
| 393 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 393 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
| 394 observer.latest_security_style()); | 394 observer.latest_security_style()); |
| 395 | 395 |
| 396 const content::SecurityStyleExplanations& expired_explanation = | 396 const content::SecurityStyleExplanations& expired_explanation = |
| 397 observer.latest_explanations(); | 397 observer.latest_explanations(); |
| 398 EXPECT_EQ(0u, expired_explanation.warning_explanations.size()); | 398 EXPECT_EQ(0u, expired_explanation.unauthenticated_explanations.size()); |
| 399 ASSERT_EQ(1u, expired_explanation.broken_explanations.size()); | 399 ASSERT_EQ(1u, expired_explanation.broken_explanations.size()); |
| 400 | 400 |
| 401 // Check that the summary and description are as expected. | 401 // Check that the summary and description are as expected. |
| 402 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), | 402 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), |
| 403 expired_explanation.broken_explanations[0].summary); | 403 expired_explanation.broken_explanations[0].summary); |
| 404 | 404 |
| 405 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString(error)); | 405 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString(error)); |
| 406 EXPECT_EQ(l10n_util::GetStringFUTF8( | 406 EXPECT_EQ(l10n_util::GetStringFUTF8( |
| 407 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), | 407 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), |
| 408 expired_explanation.broken_explanations[0].description); | 408 expired_explanation.broken_explanations[0].description); |
| (...skipping 2546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2955 | 2955 |
| 2956 content::WebContents* web_contents = | 2956 content::WebContents* web_contents = |
| 2957 browser()->tab_strip_model()->GetActiveWebContents(); | 2957 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2958 SecurityStyleTestObserver observer(web_contents); | 2958 SecurityStyleTestObserver observer(web_contents); |
| 2959 | 2959 |
| 2960 // Visit an HTTP url. | 2960 // Visit an HTTP url. |
| 2961 GURL http_url(test_server()->GetURL(std::string())); | 2961 GURL http_url(test_server()->GetURL(std::string())); |
| 2962 ui_test_utils::NavigateToURL(browser(), http_url); | 2962 ui_test_utils::NavigateToURL(browser(), http_url); |
| 2963 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2963 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 2964 observer.latest_security_style()); | 2964 observer.latest_security_style()); |
| 2965 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 2965 EXPECT_EQ(0u, |
| 2966 observer.latest_explanations().unauthenticated_explanations.size()); |
| 2966 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 2967 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 2967 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); | 2968 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); |
| 2968 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); | 2969 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); |
| 2969 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 2970 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 2970 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 2971 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 2971 | 2972 |
| 2972 // Visit an (otherwise valid) HTTPS page that displays mixed content. | 2973 // Visit an (otherwise valid) HTTPS page that displays mixed content. |
| 2973 std::string replacement_path; | 2974 std::string replacement_path; |
| 2974 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2975 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
| 2975 "files/ssl/page_displays_insecure_content.html", | 2976 "files/ssl/page_displays_insecure_content.html", |
| 2976 test_server()->host_port_pair(), &replacement_path)); | 2977 test_server()->host_port_pair(), &replacement_path)); |
| 2977 | 2978 |
| 2978 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); | 2979 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); |
| 2979 ui_test_utils::NavigateToURL(browser(), mixed_content_url); | 2980 ui_test_utils::NavigateToURL(browser(), mixed_content_url); |
| 2980 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2981 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 2981 observer.latest_security_style()); | 2982 observer.latest_security_style()); |
| 2982 | 2983 |
| 2983 const content::SecurityStyleExplanations& mixed_content_explanation = | 2984 const content::SecurityStyleExplanations& mixed_content_explanation = |
| 2984 observer.latest_explanations(); | 2985 observer.latest_explanations(); |
| 2985 ASSERT_EQ(0u, mixed_content_explanation.warning_explanations.size()); | 2986 ASSERT_EQ(0u, mixed_content_explanation.unauthenticated_explanations.size()); |
| 2986 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); | 2987 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); |
| 2987 CheckSecureExplanations(mixed_content_explanation.secure_explanations, | 2988 CheckSecureExplanations(mixed_content_explanation.secure_explanations, |
| 2988 VALID_CERTIFICATE, browser()); | 2989 VALID_CERTIFICATE, browser()); |
| 2989 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); | 2990 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); |
| 2990 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); | 2991 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); |
| 2991 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); | 2992 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); |
| 2992 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2993 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 2993 mixed_content_explanation.displayed_insecure_content_style); | 2994 mixed_content_explanation.displayed_insecure_content_style); |
| 2994 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 2995 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
| 2995 mixed_content_explanation.ran_insecure_content_style); | 2996 mixed_content_explanation.ran_insecure_content_style); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3008 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3009 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3009 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3010 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3010 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3011 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3011 | 3012 |
| 3012 // Before clicking through, navigate to a different page, and then go | 3013 // Before clicking through, navigate to a different page, and then go |
| 3013 // back to the interstitial. | 3014 // back to the interstitial. |
| 3014 GURL valid_https_url(https_test_server.GetURL(std::string())); | 3015 GURL valid_https_url(https_test_server.GetURL(std::string())); |
| 3015 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 3016 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
| 3016 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3017 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 3017 observer.latest_security_style()); | 3018 observer.latest_security_style()); |
| 3018 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3019 EXPECT_EQ(0u, |
| 3020 observer.latest_explanations().unauthenticated_explanations.size()); |
| 3019 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3021 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 3020 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3022 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3021 VALID_CERTIFICATE, browser()); | 3023 VALID_CERTIFICATE, browser()); |
| 3022 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3024 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3023 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3025 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3024 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3026 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3025 | 3027 |
| 3026 // After going back to the interstitial, an event for a broken lock | 3028 // After going back to the interstitial, an event for a broken lock |
| 3027 // icon should fire again. | 3029 // icon should fire again. |
| 3028 ui_test_utils::NavigateToURL(browser(), expired_url); | 3030 ui_test_utils::NavigateToURL(browser(), expired_url); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3073 | 3075 |
| 3074 content::WebContents* web_contents = | 3076 content::WebContents* web_contents = |
| 3075 browser()->tab_strip_model()->GetActiveWebContents(); | 3077 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3076 SecurityStyleTestObserver observer(web_contents); | 3078 SecurityStyleTestObserver observer(web_contents); |
| 3077 | 3079 |
| 3078 // Visit a valid HTTPS url. | 3080 // Visit a valid HTTPS url. |
| 3079 GURL valid_https_url(https_test_server.GetURL(std::string())); | 3081 GURL valid_https_url(https_test_server.GetURL(std::string())); |
| 3080 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 3082 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
| 3081 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3083 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 3082 observer.latest_security_style()); | 3084 observer.latest_security_style()); |
| 3083 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3085 EXPECT_EQ(0u, |
| 3086 observer.latest_explanations().unauthenticated_explanations.size()); |
| 3084 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3087 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 3085 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3088 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3086 VALID_CERTIFICATE, browser()); | 3089 VALID_CERTIFICATE, browser()); |
| 3087 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3090 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3088 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3091 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3089 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3092 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3090 | 3093 |
| 3091 // Navigate to a bad HTTPS page on a different host, and then click | 3094 // Navigate to a bad HTTPS page on a different host, and then click |
| 3092 // Back to verify that the previous good security style is seen again. | 3095 // Back to verify that the previous good security style is seen again. |
| 3093 GURL expired_https_url(https_test_server_expired.GetURL(std::string())); | 3096 GURL expired_https_url(https_test_server_expired.GetURL(std::string())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3113 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3116 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3114 | 3117 |
| 3115 content::WindowedNotificationObserver back_nav_load_observer( | 3118 content::WindowedNotificationObserver back_nav_load_observer( |
| 3116 content::NOTIFICATION_LOAD_STOP, | 3119 content::NOTIFICATION_LOAD_STOP, |
| 3117 content::Source<NavigationController>(&web_contents->GetController())); | 3120 content::Source<NavigationController>(&web_contents->GetController())); |
| 3118 chrome::GoBack(browser(), CURRENT_TAB); | 3121 chrome::GoBack(browser(), CURRENT_TAB); |
| 3119 back_nav_load_observer.Wait(); | 3122 back_nav_load_observer.Wait(); |
| 3120 | 3123 |
| 3121 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3124 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 3122 observer.latest_security_style()); | 3125 observer.latest_security_style()); |
| 3123 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3126 EXPECT_EQ(0u, |
| 3127 observer.latest_explanations().unauthenticated_explanations.size()); |
| 3124 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3128 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 3125 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3129 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3126 VALID_CERTIFICATE, browser()); | 3130 VALID_CERTIFICATE, browser()); |
| 3127 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3131 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3128 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3132 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3129 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3133 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3130 } | 3134 } |
| 3131 | 3135 |
| 3132 namespace { | 3136 namespace { |
| 3133 class JSBooleanResultGetter { | 3137 class JSBooleanResultGetter { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3186 | 3190 |
| 3187 // Sync navigation just to make sure IPC has passed (updated | 3191 // Sync navigation just to make sure IPC has passed (updated |
| 3188 // display mode is delivered to RP). | 3192 // display mode is delivered to RP). |
| 3189 content::TestNavigationObserver observer(app_contents, 1); | 3193 content::TestNavigationObserver observer(app_contents, 1); |
| 3190 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); | 3194 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); |
| 3191 observer.Wait(); | 3195 observer.Wait(); |
| 3192 | 3196 |
| 3193 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); | 3197 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); |
| 3194 } | 3198 } |
| 3195 | 3199 |
| OLD | NEW |