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

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 1000333003: Properly decode IDN in interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forward-declare GURL Created 5 years, 9 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
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/callback.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
15 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ssl/ssl_blocking_page.h" 18 #include "chrome/browser/ssl/ssl_blocking_page.h"
17 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_commands.h" 20 #include "chrome/browser/ui/browser_commands.h"
19 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
20 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
(...skipping 12 matching lines...) Expand all
37 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
38 #include "content/public/browser/web_contents_observer.h" 40 #include "content/public/browser/web_contents_observer.h"
39 #include "content/public/common/security_style.h" 41 #include "content/public/common/security_style.h"
40 #include "content/public/common/ssl_status.h" 42 #include "content/public/common/ssl_status.h"
41 #include "content/public/test/browser_test_utils.h" 43 #include "content/public/test/browser_test_utils.h"
42 #include "content/public/test/download_test_observer.h" 44 #include "content/public/test/download_test_observer.h"
43 #include "content/public/test/test_renderer_host.h" 45 #include "content/public/test/test_renderer_host.h"
44 #include "net/base/net_errors.h" 46 #include "net/base/net_errors.h"
45 #include "net/base/test_data_directory.h" 47 #include "net/base/test_data_directory.h"
46 #include "net/cert/cert_status_flags.h" 48 #include "net/cert/cert_status_flags.h"
49 #include "net/cert/x509_certificate.h"
50 #include "net/ssl/ssl_info.h"
47 #include "net/test/spawned_test_server/spawned_test_server.h" 51 #include "net/test/spawned_test_server/spawned_test_server.h"
48 52
49 #if defined(USE_NSS) 53 #if defined(USE_NSS)
50 #include "chrome/browser/net/nss_context.h" 54 #include "chrome/browser/net/nss_context.h"
51 #include "net/base/crypto_module.h" 55 #include "net/base/crypto_module.h"
52 #include "net/cert/nss_cert_database.h" 56 #include "net/cert/nss_cert_database.h"
53 #endif // defined(USE_NSS) 57 #endif // defined(USE_NSS)
54 58
55 using base::ASCIIToUTF16; 59 using base::ASCIIToUTF16;
60 using chrome_browser_interstitials::SecurityInterstitialIDNTest;
56 using content::InterstitialPage; 61 using content::InterstitialPage;
57 using content::NavigationController; 62 using content::NavigationController;
58 using content::NavigationEntry; 63 using content::NavigationEntry;
59 using content::SSLStatus; 64 using content::SSLStatus;
60 using content::WebContents; 65 using content::WebContents;
61 using web_modal::WebContentsModalDialogManager; 66 using web_modal::WebContentsModalDialogManager;
62 67
63 const base::FilePath::CharType kDocRoot[] = 68 const base::FilePath::CharType kDocRoot[] =
64 FILE_PATH_LITERAL("chrome/test/data"); 69 FILE_PATH_LITERAL("chrome/test/data");
65 70
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 ui::PAGE_TRANSITION_TYPED); 1926 ui::PAGE_TRANSITION_TYPED);
1922 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 1927 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1923 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 1928 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
1924 EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1)); 1929 EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1));
1925 EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing()); 1930 EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing());
1926 1931
1927 browser()->tab_strip_model()->ActivateTabAt(1, true); 1932 browser()->tab_strip_model()->ActivateTabAt(1, true);
1928 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); 1933 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing());
1929 } 1934 }
1930 1935
1936 void DoNothing(bool arg) {
1937 }
1938
1939 class SSLBlockingPageIDNTest : public SecurityInterstitialIDNTest {
1940 protected:
1941 // SecurityInterstitialIDNTest implementation
1942 SecurityInterstitialPage* CreateInterstitial(
1943 content::WebContents* contents,
1944 const GURL& request_url) override {
1945 net::SSLInfo ssl_info;
1946 ssl_info.cert = new net::X509Certificate(
1947 request_url.host(), "CA", base::Time::Max(), base::Time::Max());
1948 SSLBlockingPage* blocking_page = new SSLBlockingPage(
1949 contents, net::ERR_CERT_CONTAINS_ERRORS, ssl_info, request_url, 0,
1950 base::Time::NowFromSystemTime(), base::Bind(&DoNothing));
1951 return blocking_page;
meacer 2015/03/24 23:17:00 nit: directly |return new SSLBlockingPage...| inst
estark 2015/03/25 00:45:25 Done.
1952 }
1953 };
1954
1955 IN_PROC_BROWSER_TEST_F(SSLBlockingPageIDNTest, SSLBlockingPageDecodesIDN) {
1956 TestIDN();
1957 }
1958
1931 // TODO(jcampan): more tests to do below. 1959 // TODO(jcampan): more tests to do below.
1932 1960
1933 // Visit a page over https that contains a frame with a redirect. 1961 // Visit a page over https that contains a frame with a redirect.
1934 1962
1935 // XMLHttpRequest insecure content in synchronous mode. 1963 // XMLHttpRequest insecure content in synchronous mode.
1936 1964
1937 // XMLHttpRequest insecure content in asynchronous mode. 1965 // XMLHttpRequest insecure content in asynchronous mode.
1938 1966
1939 // XMLHttpRequest over bad ssl in synchronous mode. 1967 // XMLHttpRequest over bad ssl in synchronous mode.
1940 1968
1941 // XMLHttpRequest over OK ssl in synchronous mode. 1969 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698