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

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

Issue 962413002: Add type for testing to interstitials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bauerb comments 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 253 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
254 tab, 254 tab,
255 "window.domAutomationController.send(IsContentLoaded());", 255 "window.domAutomationController.send(IsContentLoaded());",
256 &actually_loaded_content)); 256 &actually_loaded_content));
257 EXPECT_EQ(expected_load, actually_loaded_content); 257 EXPECT_EQ(expected_load, actually_loaded_content);
258 } 258 }
259 259
260 void ProceedThroughInterstitial(WebContents* tab) { 260 void ProceedThroughInterstitial(WebContents* tab) {
261 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 261 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
262 ASSERT_TRUE(interstitial_page); 262 ASSERT_TRUE(interstitial_page);
263 ASSERT_EQ(SSLBlockingPage::kTypeForTesting,
264 interstitial_page->GetDelegateForTesting()->GetTypeForTesting());
263 content::WindowedNotificationObserver observer( 265 content::WindowedNotificationObserver observer(
264 content::NOTIFICATION_LOAD_STOP, 266 content::NOTIFICATION_LOAD_STOP,
265 content::Source<NavigationController>(&tab->GetController())); 267 content::Source<NavigationController>(&tab->GetController()));
266 interstitial_page->Proceed(); 268 interstitial_page->Proceed();
267 observer.Wait(); 269 observer.Wait();
268 } 270 }
269 271
270 bool IsShowingWebContentsModalDialog() const { 272 bool IsShowingWebContentsModalDialog() const {
271 return WebContentsModalDialogManager::FromWebContents( 273 return WebContentsModalDialogManager::FromWebContents(
272 browser()->tab_strip_model()->GetActiveWebContents())-> 274 browser()->tab_strip_model()->GetActiveWebContents())->
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 ui_test_utils::NavigateToURL(browser(), cross_site_url); 527 ui_test_utils::NavigateToURL(browser(), cross_site_url);
526 528
527 // An interstitial should be showing. 529 // An interstitial should be showing.
528 CheckAuthenticationBrokenState(tab, 530 CheckAuthenticationBrokenState(tab,
529 net::CERT_STATUS_COMMON_NAME_INVALID, 531 net::CERT_STATUS_COMMON_NAME_INVALID,
530 AuthState::SHOWING_INTERSTITIAL); 532 AuthState::SHOWING_INTERSTITIAL);
531 533
532 // Simulate user clicking "Take me back". 534 // Simulate user clicking "Take me back".
533 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 535 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
534 ASSERT_TRUE(interstitial_page); 536 ASSERT_TRUE(interstitial_page);
537 ASSERT_EQ(SSLBlockingPage::kTypeForTesting,
538 interstitial_page->GetDelegateForTesting()->GetTypeForTesting());
535 interstitial_page->DontProceed(); 539 interstitial_page->DontProceed();
536 540
537 // We should be back to the original good page. 541 // We should be back to the original good page.
538 CheckAuthenticatedState(tab, AuthState::NONE); 542 CheckAuthenticatedState(tab, AuthState::NONE);
539 543
540 // Try to navigate to a new page. (to make sure bug 5800 is fixed). 544 // Try to navigate to a new page. (to make sure bug 5800 is fixed).
541 ui_test_utils::NavigateToURL(browser(), 545 ui_test_utils::NavigateToURL(browser(),
542 test_server()->GetURL("files/ssl/google.html")); 546 test_server()->GetURL("files/ssl/google.html"));
543 CheckUnauthenticatedState(tab, AuthState::NONE); 547 CheckUnauthenticatedState(tab, AuthState::NONE);
544 } 548 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 GURL url = https_server_expired_.GetURL("files/ssl/google.htm"); 880 GURL url = https_server_expired_.GetURL("files/ssl/google.htm");
877 WebContents* tab2 = chrome::AddSelectedTabWithURL( 881 WebContents* tab2 = chrome::AddSelectedTabWithURL(
878 browser(), url, ui::PAGE_TRANSITION_TYPED); 882 browser(), url, ui::PAGE_TRANSITION_TYPED);
879 content::WaitForLoadStop(tab2); 883 content::WaitForLoadStop(tab2);
880 884
881 // Verify our assumption that there was no prior navigation. 885 // Verify our assumption that there was no prior navigation.
882 EXPECT_FALSE(chrome::CanGoBack(browser())); 886 EXPECT_FALSE(chrome::CanGoBack(browser()));
883 887
884 // We should have an interstitial page showing. 888 // We should have an interstitial page showing.
885 ASSERT_TRUE(tab2->GetInterstitialPage()); 889 ASSERT_TRUE(tab2->GetInterstitialPage());
890 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, tab2->GetInterstitialPage()
891 ->GetDelegateForTesting()
892 ->GetTypeForTesting());
886 } 893 }
887 894
888 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadHTTPSDownload) { 895 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadHTTPSDownload) {
889 ASSERT_TRUE(test_server()->Start()); 896 ASSERT_TRUE(test_server()->Start());
890 ASSERT_TRUE(https_server_expired_.Start()); 897 ASSERT_TRUE(https_server_expired_.Start());
891 GURL url_non_dangerous = test_server()->GetURL(std::string()); 898 GURL url_non_dangerous = test_server()->GetURL(std::string());
892 GURL url_dangerous = 899 GURL url_dangerous =
893 https_server_expired_.GetURL("files/downloads/dangerous/dangerous.exe"); 900 https_server_expired_.GetURL("files/downloads/dangerous/dangerous.exe");
894 base::ScopedTempDir downloads_directory_; 901 base::ScopedTempDir downloads_directory_;
895 902
(...skipping 24 matching lines...) Expand all
920 content::DownloadTestObserverTerminal dangerous_download_observer( 927 content::DownloadTestObserverTerminal dangerous_download_observer(
921 content::BrowserContext::GetDownloadManager(browser()->profile()), 928 content::BrowserContext::GetDownloadManager(browser()->profile()),
922 1, 929 1,
923 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT); 930 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT);
924 931
925 // Proceed through the SSL interstitial. This doesn't use 932 // Proceed through the SSL interstitial. This doesn't use
926 // |ProceedThroughInterstitial| since no page load will commit. 933 // |ProceedThroughInterstitial| since no page load will commit.
927 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 934 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
928 ASSERT_TRUE(tab != NULL); 935 ASSERT_TRUE(tab != NULL);
929 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); 936 ASSERT_TRUE(tab->GetInterstitialPage() != NULL);
937 ASSERT_EQ(
938 SSLBlockingPage::kTypeForTesting,
939 tab->GetInterstitialPage()->GetDelegateForTesting()->GetTypeForTesting());
930 { 940 {
931 content::WindowedNotificationObserver observer( 941 content::WindowedNotificationObserver observer(
932 chrome::NOTIFICATION_DOWNLOAD_INITIATED, 942 chrome::NOTIFICATION_DOWNLOAD_INITIATED,
933 content::NotificationService::AllSources()); 943 content::NotificationService::AllSources());
934 tab->GetInterstitialPage()->Proceed(); 944 tab->GetInterstitialPage()->Proceed();
935 observer.Wait(); 945 observer.Wait();
936 } 946 }
937 947
938 // There should still be an interstitial at this point. Press the 948 // There should still be an interstitial at this point. Press the
939 // back button on the browser. Note that this doesn't wait for a 949 // back button on the browser. Note that this doesn't wait for a
940 // NAV_ENTRY_COMMITTED notification because going back with an 950 // NAV_ENTRY_COMMITTED notification because going back with an
941 // active interstitial simply hides the interstitial. 951 // active interstitial simply hides the interstitial.
942 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); 952 ASSERT_TRUE(tab->GetInterstitialPage() != NULL);
953 ASSERT_EQ(
954 SSLBlockingPage::kTypeForTesting,
955 tab->GetInterstitialPage()->GetDelegateForTesting()->GetTypeForTesting());
943 EXPECT_TRUE(chrome::CanGoBack(browser())); 956 EXPECT_TRUE(chrome::CanGoBack(browser()));
944 chrome::GoBack(browser(), CURRENT_TAB); 957 chrome::GoBack(browser(), CURRENT_TAB);
945 958
946 dangerous_download_observer.WaitForFinished(); 959 dangerous_download_observer.WaitForFinished();
947 } 960 }
948 961
949 // 962 //
950 // Insecure content 963 // Insecure content
951 // 964 //
952 965
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1846 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1834 ui_test_utils::NavigateToURL(browser(), 1847 ui_test_utils::NavigateToURL(browser(),
1835 https_server_expired_.GetURL("files/ssl/google.html")); 1848 https_server_expired_.GetURL("files/ssl/google.html"));
1836 CheckAuthenticationBrokenState( 1849 CheckAuthenticationBrokenState(
1837 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); 1850 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL);
1838 1851
1839 content::WindowedNotificationObserver observer( 1852 content::WindowedNotificationObserver observer(
1840 content::NOTIFICATION_LOAD_STOP, 1853 content::NOTIFICATION_LOAD_STOP,
1841 content::Source<NavigationController>(&tab->GetController())); 1854 content::Source<NavigationController>(&tab->GetController()));
1842 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 1855 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
1856 ASSERT_EQ(SSLBlockingPage::kTypeForTesting,
1857 interstitial_page->GetDelegateForTesting()->GetTypeForTesting());
1843 content::RenderViewHost* interstitial_rvh = 1858 content::RenderViewHost* interstitial_rvh =
1844 interstitial_page->GetMainFrame()->GetRenderViewHost(); 1859 interstitial_page->GetMainFrame()->GetRenderViewHost();
1845 int result = -1; 1860 int result = -1;
1846 std::string javascript = base::StringPrintf( 1861 std::string javascript = base::StringPrintf(
1847 "window.domAutomationController.send(%d);", 1862 "window.domAutomationController.send(%d);",
1848 SSLBlockingPage::CMD_PROCEED); 1863 SSLBlockingPage::CMD_PROCEED);
1849 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 1864 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
1850 interstitial_rvh, javascript, &result)); 1865 interstitial_rvh, javascript, &result));
1851 // The above will hang without the fix. 1866 // The above will hang without the fix.
1852 EXPECT_EQ(1, result); 1867 EXPECT_EQ(1, result);
(...skipping 12 matching lines...) Expand all
1865 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1880 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1866 ui_test_utils::NavigateToURL(browser(), 1881 ui_test_utils::NavigateToURL(browser(),
1867 https_server_expired_.GetURL("files/ssl/google.html")); 1882 https_server_expired_.GetURL("files/ssl/google.html"));
1868 CheckAuthenticationBrokenState( 1883 CheckAuthenticationBrokenState(
1869 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); 1884 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL);
1870 1885
1871 content::WindowedNotificationObserver observer( 1886 content::WindowedNotificationObserver observer(
1872 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 1887 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
1873 content::NotificationService::AllSources()); 1888 content::NotificationService::AllSources());
1874 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 1889 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
1890 ASSERT_EQ(SSLBlockingPage::kTypeForTesting,
1891 interstitial_page->GetDelegateForTesting()->GetTypeForTesting());
1875 content::RenderViewHost* interstitial_rvh = 1892 content::RenderViewHost* interstitial_rvh =
1876 interstitial_page->GetMainFrame()->GetRenderViewHost(); 1893 interstitial_page->GetMainFrame()->GetRenderViewHost();
1877 int result = -1; 1894 int result = -1;
1878 std::string javascript = base::StringPrintf( 1895 std::string javascript = base::StringPrintf(
1879 "window.domAutomationController.send(%d);", 1896 "window.domAutomationController.send(%d);",
1880 SSLBlockingPage::CMD_DONT_PROCEED); 1897 SSLBlockingPage::CMD_DONT_PROCEED);
1881 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 1898 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
1882 interstitial_rvh, javascript, &result)); 1899 interstitial_rvh, javascript, &result));
1883 // The above will hang without the fix. 1900 // The above will hang without the fix.
1884 EXPECT_EQ(0, result); 1901 EXPECT_EQ(0, result);
(...skipping 30 matching lines...) Expand all
1915 1932
1916 // Visit a page over https that contains a frame with a redirect. 1933 // Visit a page over https that contains a frame with a redirect.
1917 1934
1918 // XMLHttpRequest insecure content in synchronous mode. 1935 // XMLHttpRequest insecure content in synchronous mode.
1919 1936
1920 // XMLHttpRequest insecure content in asynchronous mode. 1937 // XMLHttpRequest insecure content in asynchronous mode.
1921 1938
1922 // XMLHttpRequest over bad ssl in synchronous mode. 1939 // XMLHttpRequest over bad ssl in synchronous mode.
1923 1940
1924 // XMLHttpRequest over OK ssl in synchronous mode. 1941 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | chrome/browser/supervised_user/supervised_user_interstitial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698