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

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

Issue 1207943002: Trigger DidChangeVisisbleSSLState() after OverrideEntry() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fixes Created 5 years, 6 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/frame_host/interstitial_page_impl.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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 362 }
363 363
364 content::SecurityStyle latest_security_style() const { 364 content::SecurityStyle latest_security_style() const {
365 return latest_security_style_; 365 return latest_security_style_;
366 } 366 }
367 367
368 const content::SecurityStyleExplanations& latest_explanations() const { 368 const content::SecurityStyleExplanations& latest_explanations() const {
369 return latest_explanations_; 369 return latest_explanations_;
370 } 370 }
371 371
372 void ClearLatestSecurityStyleAndExplanations() {
373 latest_security_style_ = content::SECURITY_STYLE_UNKNOWN;
374 latest_explanations_.warning_explanations.clear();
msw 2015/06/29 20:02:07 nit: maybe just do latest_explanations_ = Security
375 latest_explanations_.broken_explanations.clear();
376 }
377
372 private: 378 private:
373 content::SecurityStyle latest_security_style_; 379 content::SecurityStyle latest_security_style_;
374 content::SecurityStyleExplanations latest_explanations_; 380 content::SecurityStyleExplanations latest_explanations_;
375 381
376 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver); 382 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver);
377 }; 383 };
378 384
385 // Check that |observer|'s latest event was for an expired certificate
386 // and that it saw the proper SecurityStyle and explanations.
387 void CheckExpiredSecurityStyle(const SecurityStyleTestObserver& observer) {
388 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
389 observer.latest_security_style());
390
391 const content::SecurityStyleExplanations& expired_explanation =
392 observer.latest_explanations();
393 EXPECT_EQ(0u, expired_explanation.warning_explanations.size());
394 ASSERT_EQ(1u, expired_explanation.broken_explanations.size());
395
396 // Check that the summary and description are as expected.
397 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
398 expired_explanation.broken_explanations[0].summary);
399
400 base::string16 error_string =
401 base::UTF8ToUTF16(net::ErrorToString(net::ERR_CERT_DATE_INVALID));
402 EXPECT_EQ(l10n_util::GetStringFUTF8(
403 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
404 expired_explanation.broken_explanations[0].description);
405 }
406
379 } // namespace 407 } // namespace
380 408
381 class BrowserTest : public ExtensionBrowserTest { 409 class BrowserTest : public ExtensionBrowserTest {
382 protected: 410 protected:
383 // 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
384 // matches the value returned by GetWindowTitle(). 412 // matches the value returned by GetWindowTitle().
385 base::string16 LocaleWindowCaptionFromPageTitle( 413 base::string16 LocaleWindowCaptionFromPageTitle(
386 const base::string16& expected_title) { 414 const base::string16& expected_title) {
387 base::string16 page_title = WindowCaptionFromPageTitle(expected_title); 415 base::string16 page_title = WindowCaptionFromPageTitle(expected_title);
388 #if defined(OS_WIN) 416 #if defined(OS_WIN)
(...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 2881
2854 content::WebContents* web_contents = 2882 content::WebContents* web_contents =
2855 browser()->tab_strip_model()->GetActiveWebContents(); 2883 browser()->tab_strip_model()->GetActiveWebContents();
2856 SecurityStyleTestObserver observer(web_contents); 2884 SecurityStyleTestObserver observer(web_contents);
2857 2885
2858 // Visit an HTTP url. 2886 // Visit an HTTP url.
2859 GURL http_url(test_server()->GetURL(std::string())); 2887 GURL http_url(test_server()->GetURL(std::string()));
2860 ui_test_utils::NavigateToURL(browser(), http_url); 2888 ui_test_utils::NavigateToURL(browser(), http_url);
2861 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, 2889 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED,
2862 observer.latest_security_style()); 2890 observer.latest_security_style());
2891 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
2892 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
2863 2893
2864 // Visit a valid HTTPS url. 2894 // Visit a valid HTTPS url.
2865 GURL valid_https_url(https_test_server.GetURL(std::string())); 2895 GURL valid_https_url(https_test_server.GetURL(std::string()));
2866 ui_test_utils::NavigateToURL(browser(), valid_https_url); 2896 ui_test_utils::NavigateToURL(browser(), valid_https_url);
2867 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, 2897 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
2868 observer.latest_security_style()); 2898 observer.latest_security_style());
2899 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
2900 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
2869 2901
2870 // Visit an (otherwise valid) HTTPS page that displays mixed content. 2902 // Visit an (otherwise valid) HTTPS page that displays mixed content.
2871 std::string replacement_path; 2903 std::string replacement_path;
2872 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 2904 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
2873 "files/ssl/page_displays_insecure_content.html", 2905 "files/ssl/page_displays_insecure_content.html",
2874 test_server()->host_port_pair(), &replacement_path)); 2906 test_server()->host_port_pair(), &replacement_path));
2875 2907
2876 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); 2908 GURL mixed_content_url(https_test_server.GetURL(replacement_path));
2877 ui_test_utils::NavigateToURL(browser(), mixed_content_url); 2909 ui_test_utils::NavigateToURL(browser(), mixed_content_url);
2878 EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style()); 2910 EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style());
2879 2911
2880 const content::SecurityStyleExplanations& mixed_content_explanation = 2912 const content::SecurityStyleExplanations& mixed_content_explanation =
2881 observer.latest_explanations(); 2913 observer.latest_explanations();
2882 ASSERT_EQ(1u, mixed_content_explanation.warning_explanations.size()); 2914 ASSERT_EQ(1u, mixed_content_explanation.warning_explanations.size());
2883 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT), 2915 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT),
2884 mixed_content_explanation.warning_explanations[0].summary); 2916 mixed_content_explanation.warning_explanations[0].summary);
2885 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT_DESCRIPTION), 2917 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT_DESCRIPTION),
2886 mixed_content_explanation.warning_explanations[0].description); 2918 mixed_content_explanation.warning_explanations[0].description);
2887 EXPECT_EQ(0u, mixed_content_explanation.broken_explanations.size()); 2919 EXPECT_EQ(0u, mixed_content_explanation.broken_explanations.size());
2888 2920
2889 // Visit a broken HTTPS url. Other conditions cannot be tested after 2921 // Visit a broken HTTPS url.
2890 // this one because once the interstitial is clicked through, all URLs
2891 // for this host will remain in a broken state.
2892 GURL expired_url(https_test_server_expired.GetURL(std::string())); 2922 GURL expired_url(https_test_server_expired.GetURL(std::string()));
2893 ui_test_utils::NavigateToURL(browser(), expired_url); 2923 ui_test_utils::NavigateToURL(browser(), expired_url);
2894 2924
2925 // An interstitial should show, and an event for the lock icon on the
2926 // interstitial should fire.
2927 content::WaitForInterstitialAttach(web_contents);
2928 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
2929 CheckExpiredSecurityStyle(observer);
2930
2931 // Before clicking through, navigate to a different page, and then go
2932 // back to the interstitial.
2933 ui_test_utils::NavigateToURL(browser(), valid_https_url);
2934 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
2935 observer.latest_security_style());
2936 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
2937 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
2938
2939 // After going back to the interstitial, an event for a broken lock
2940 // icon should fire again.
2941 ui_test_utils::NavigateToURL(browser(), expired_url);
2942 content::WaitForInterstitialAttach(web_contents);
2943 EXPECT_TRUE(web_contents->ShowingInterstitialPage());
2944 CheckExpiredSecurityStyle(observer);
2945
2946 // Since the next expected style is the same as the previous, clear
2947 // the observer (to make sure that the event fires twice and we don't
2948 // just see the previous event's style).
2949 observer.ClearLatestSecurityStyleAndExplanations();
2950
2951 // Other conditions cannot be tested after clicking through because
2952 // once the interstitial is clicked through, all URLs for this host
2953 // will remain in a broken state.
2895 ProceedThroughInterstitial(web_contents); 2954 ProceedThroughInterstitial(web_contents);
2896 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, 2955 CheckExpiredSecurityStyle(observer);
2897 observer.latest_security_style());
2898
2899 const content::SecurityStyleExplanations& expired_explanation =
2900 observer.latest_explanations();
2901 EXPECT_EQ(0u, expired_explanation.warning_explanations.size());
2902 ASSERT_EQ(1u, expired_explanation.broken_explanations.size());
2903 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
2904 expired_explanation.broken_explanations[0].summary);
2905 base::string16 error_string =
2906 base::UTF8ToUTF16(net::ErrorToString(net::ERR_CERT_DATE_INVALID));
2907 EXPECT_EQ(l10n_util::GetStringFUTF8(
2908 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
2909 expired_explanation.broken_explanations[0].description);
2910 } 2956 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/interstitial_page_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698