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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 1259253009: Revert of Attach a SecurityStyle to each request in ResourceLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/loader/resource_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 private: 378 private:
379 content::SecurityStyle latest_security_style_; 379 content::SecurityStyle latest_security_style_;
380 content::SecurityStyleExplanations latest_explanations_; 380 content::SecurityStyleExplanations latest_explanations_;
381 381
382 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver); 382 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver);
383 }; 383 };
384 384
385 // Check that |observer|'s latest event was for an expired certificate 385 // Check that |observer|'s latest event was for an expired certificate
386 // and that it saw the proper SecurityStyle and explanations. 386 // and that it saw the proper SecurityStyle and explanations.
387 void CheckBrokenSecurityStyle(const SecurityStyleTestObserver& observer, 387 void CheckExpiredSecurityStyle(const SecurityStyleTestObserver& observer) {
388 int error) {
389 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, 388 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
390 observer.latest_security_style()); 389 observer.latest_security_style());
391 390
392 const content::SecurityStyleExplanations& expired_explanation = 391 const content::SecurityStyleExplanations& expired_explanation =
393 observer.latest_explanations(); 392 observer.latest_explanations();
394 EXPECT_EQ(0u, expired_explanation.warning_explanations.size()); 393 EXPECT_EQ(0u, expired_explanation.warning_explanations.size());
395 ASSERT_EQ(1u, expired_explanation.broken_explanations.size()); 394 ASSERT_EQ(1u, expired_explanation.broken_explanations.size());
396 395
397 // Check that the summary and description are as expected. 396 // Check that the summary and description are as expected.
398 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), 397 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
399 expired_explanation.broken_explanations[0].summary); 398 expired_explanation.broken_explanations[0].summary);
400 399
401 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString(error)); 400 base::string16 error_string =
401 base::UTF8ToUTF16(net::ErrorToString(net::ERR_CERT_DATE_INVALID));
402 EXPECT_EQ(l10n_util::GetStringFUTF8( 402 EXPECT_EQ(l10n_util::GetStringFUTF8(
403 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), 403 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
404 expired_explanation.broken_explanations[0].description); 404 expired_explanation.broken_explanations[0].description);
405 } 405 }
406 406
407 } // namespace 407 } // namespace
408 408
409 class BrowserTest : public ExtensionBrowserTest { 409 class BrowserTest : public ExtensionBrowserTest {
410 protected: 410 protected:
411 // In RTL locales wrap the page title with RTL embedding characters so that it 411 // In RTL locales wrap the page title with RTL embedding characters so that it
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); 2943 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
2944 2944
2945 // Visit a valid HTTPS url. 2945 // Visit a valid HTTPS url.
2946 GURL valid_https_url(https_test_server.GetURL(std::string())); 2946 GURL valid_https_url(https_test_server.GetURL(std::string()));
2947 ui_test_utils::NavigateToURL(browser(), valid_https_url); 2947 ui_test_utils::NavigateToURL(browser(), valid_https_url);
2948 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, 2948 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
2949 observer.latest_security_style()); 2949 observer.latest_security_style());
2950 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); 2950 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
2951 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); 2951 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
2952 2952
2953 // Navigate to a bad HTTPS page on a different host, and then click
2954 // Back to verify that the previous good security style is seen again.
2955 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1");
2956 GURL::Replacements replace_host;
2957 replace_host.SetHostStr("www.example_broken.test");
2958 GURL https_url_different_host =
2959 valid_https_url.ReplaceComponents(replace_host);
2960 ui_test_utils::NavigateToURL(browser(), https_url_different_host);
2961 CheckBrokenSecurityStyle(observer, net::ERR_CERT_COMMON_NAME_INVALID);
2962 ProceedThroughInterstitial(web_contents);
2963 CheckBrokenSecurityStyle(observer, net::ERR_CERT_COMMON_NAME_INVALID);
2964
2965 content::WindowedNotificationObserver back_nav_load_observer(
2966 content::NOTIFICATION_LOAD_STOP,
2967 content::Source<NavigationController>(&web_contents->GetController()));
2968 chrome::GoBack(browser(), CURRENT_TAB);
2969 back_nav_load_observer.Wait();
2970
2971 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
2972 observer.latest_security_style());
2973 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
2974 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
2975
2976 // Visit an (otherwise valid) HTTPS page that displays mixed content. 2953 // Visit an (otherwise valid) HTTPS page that displays mixed content.
2977 std::string replacement_path; 2954 std::string replacement_path;
2978 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 2955 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
2979 "files/ssl/page_displays_insecure_content.html", 2956 "files/ssl/page_displays_insecure_content.html",
2980 test_server()->host_port_pair(), &replacement_path)); 2957 test_server()->host_port_pair(), &replacement_path));
2981 2958
2982 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); 2959 GURL mixed_content_url(https_test_server.GetURL(replacement_path));
2983 ui_test_utils::NavigateToURL(browser(), mixed_content_url); 2960 ui_test_utils::NavigateToURL(browser(), mixed_content_url);
2984 EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style()); 2961 EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style());
2985 2962
2986 const content::SecurityStyleExplanations& mixed_content_explanation = 2963 const content::SecurityStyleExplanations& mixed_content_explanation =
2987 observer.latest_explanations(); 2964 observer.latest_explanations();
2988 ASSERT_EQ(1u, mixed_content_explanation.warning_explanations.size()); 2965 ASSERT_EQ(1u, mixed_content_explanation.warning_explanations.size());
2989 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT), 2966 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT),
2990 mixed_content_explanation.warning_explanations[0].summary); 2967 mixed_content_explanation.warning_explanations[0].summary);
2991 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT_DESCRIPTION), 2968 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT_DESCRIPTION),
2992 mixed_content_explanation.warning_explanations[0].description); 2969 mixed_content_explanation.warning_explanations[0].description);
2993 EXPECT_EQ(0u, mixed_content_explanation.broken_explanations.size()); 2970 EXPECT_EQ(0u, mixed_content_explanation.broken_explanations.size());
2994 2971
2995 // Visit a broken HTTPS url. 2972 // Visit a broken HTTPS url.
2996 GURL expired_url(https_test_server_expired.GetURL(std::string())); 2973 GURL expired_url(https_test_server_expired.GetURL(std::string()));
2997 ui_test_utils::NavigateToURL(browser(), expired_url); 2974 ui_test_utils::NavigateToURL(browser(), expired_url);
2998 2975
2999 // An interstitial should show, and an event for the lock icon on the 2976 // An interstitial should show, and an event for the lock icon on the
3000 // interstitial should fire. 2977 // interstitial should fire.
3001 content::WaitForInterstitialAttach(web_contents); 2978 content::WaitForInterstitialAttach(web_contents);
3002 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); 2979 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
3003 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID); 2980 CheckExpiredSecurityStyle(observer);
3004 2981
3005 // Before clicking through, navigate to a different page, and then go 2982 // Before clicking through, navigate to a different page, and then go
3006 // back to the interstitial. 2983 // back to the interstitial.
3007 ui_test_utils::NavigateToURL(browser(), valid_https_url); 2984 ui_test_utils::NavigateToURL(browser(), valid_https_url);
3008 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, 2985 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
3009 observer.latest_security_style()); 2986 observer.latest_security_style());
3010 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); 2987 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
3011 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); 2988 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
3012 2989
3013 // After going back to the interstitial, an event for a broken lock 2990 // After going back to the interstitial, an event for a broken lock
3014 // icon should fire again. 2991 // icon should fire again.
3015 ui_test_utils::NavigateToURL(browser(), expired_url); 2992 ui_test_utils::NavigateToURL(browser(), expired_url);
3016 content::WaitForInterstitialAttach(web_contents); 2993 content::WaitForInterstitialAttach(web_contents);
3017 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); 2994 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
3018 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID); 2995 CheckExpiredSecurityStyle(observer);
3019 2996
3020 // Since the next expected style is the same as the previous, clear 2997 // Since the next expected style is the same as the previous, clear
3021 // the observer (to make sure that the event fires twice and we don't 2998 // the observer (to make sure that the event fires twice and we don't
3022 // just see the previous event's style). 2999 // just see the previous event's style).
3023 observer.ClearLatestSecurityStyleAndExplanations(); 3000 observer.ClearLatestSecurityStyleAndExplanations();
3024 3001
3025 // Other conditions cannot be tested on this host after clicking 3002 // Other conditions cannot be tested after clicking through because
3026 // through because once the interstitial is clicked through, all URLs 3003 // once the interstitial is clicked through, all URLs for this host
3027 // for this host will remain in a broken state. 3004 // will remain in a broken state.
3028 ProceedThroughInterstitial(web_contents); 3005 ProceedThroughInterstitial(web_contents);
3029 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID); 3006 CheckExpiredSecurityStyle(observer);
3030 } 3007 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698