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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/time.h" 6 #include "base/time.h"
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/tabs/tab_strip_model.h" 8 #include "chrome/browser/tabs/tab_strip_model.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
11 #include "chrome/browser/ui/constrained_window_tab_helper.h" 11 #include "chrome/browser/ui/constrained_window_tab_helper.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/tab_contents/interstitial_page.h" 18 #include "content/browser/tab_contents/interstitial_page.h"
19 #include "content/browser/tab_contents/navigation_entry.h" 19 #include "content/browser/tab_contents/navigation_entry.h"
20 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
21 #include "content/common/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "net/base/cert_status_flags.h" 22 #include "net/base/cert_status_flags.h"
23 #include "net/test/test_server.h" 23 #include "net/test/test_server.h"
24 24
25 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 25 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
26 26
27 class SSLUITest : public InProcessBrowserTest { 27 class SSLUITest : public InProcessBrowserTest {
28 typedef net::TestServer::HTTPSOptions HTTPSOptions; 28 typedef net::TestServer::HTTPSOptions HTTPSOptions;
29 29
30 public: 30 public:
31 SSLUITest() 31 SSLUITest()
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 ASSERT_TRUE(entry); 360 ASSERT_TRUE(entry);
361 361
362 // Now go to a bad HTTPS page that shows an interstitial. 362 // Now go to a bad HTTPS page that shows an interstitial.
363 ui_test_utils::NavigateToURL(browser(), 363 ui_test_utils::NavigateToURL(browser(),
364 https_server_expired_.GetURL("files/ssl/google.html")); 364 https_server_expired_.GetURL("files/ssl/google.html"));
365 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 365 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
366 true); // Interstitial showing 366 true); // Interstitial showing
367 367
368 ui_test_utils::WindowedNotificationObserver load_failed_observer( 368 ui_test_utils::WindowedNotificationObserver load_failed_observer(
369 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, 369 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
370 NotificationService::AllSources()); 370 content::NotificationService::AllSources());
371 371
372 // Simulate user clicking on back button (crbug.com/39248). 372 // Simulate user clicking on back button (crbug.com/39248).
373 browser()->GoBack(CURRENT_TAB); 373 browser()->GoBack(CURRENT_TAB);
374 374
375 // Wait until we hear the load failure, and make sure we haven't swapped out 375 // Wait until we hear the load failure, and make sure we haven't swapped out
376 // the previous page. Prevents regression of http://crbug.com/82667. 376 // the previous page. Prevents regression of http://crbug.com/82667.
377 load_failed_observer.Wait(); 377 load_failed_observer.Wait();
378 EXPECT_FALSE(tab->render_view_host()->is_swapped_out()); 378 EXPECT_FALSE(tab->render_view_host()->is_swapped_out());
379 379
380 // We should be back at the original good page. 380 // We should be back at the original good page.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 GURL url_non_dangerous = test_server()->GetURL(""); 496 GURL url_non_dangerous = test_server()->GetURL("");
497 GURL url_dangerous = https_server_expired_.GetURL( 497 GURL url_dangerous = https_server_expired_.GetURL(
498 "files/downloads/dangerous/dangerous.exe"); 498 "files/downloads/dangerous/dangerous.exe");
499 499
500 // Visit a non-dangerous page. 500 // Visit a non-dangerous page.
501 ui_test_utils::NavigateToURL(browser(), url_non_dangerous); 501 ui_test_utils::NavigateToURL(browser(), url_non_dangerous);
502 502
503 // Now, start a transition to dangerous download. 503 // Now, start a transition to dangerous download.
504 { 504 {
505 ui_test_utils::WindowedNotificationObserver observer( 505 ui_test_utils::WindowedNotificationObserver observer(
506 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); 506 content::NOTIFICATION_LOAD_STOP,
507 content::NotificationService::AllSources());
507 browser::NavigateParams navigate_params(browser(), url_dangerous, 508 browser::NavigateParams navigate_params(browser(), url_dangerous,
508 content::PAGE_TRANSITION_TYPED); 509 content::PAGE_TRANSITION_TYPED);
509 browser::Navigate(&navigate_params); 510 browser::Navigate(&navigate_params);
510 observer.Wait(); 511 observer.Wait();
511 } 512 }
512 513
513 // Proceed through the SSL interstitial. This doesn't use 514 // Proceed through the SSL interstitial. This doesn't use
514 // |ProceedThroughInterstitial| since no page load will commit. 515 // |ProceedThroughInterstitial| since no page load will commit.
515 TabContents* tab = browser()->GetSelectedTabContents(); 516 TabContents* tab = browser()->GetSelectedTabContents();
516 ASSERT_TRUE(tab != NULL); 517 ASSERT_TRUE(tab != NULL);
517 ASSERT_TRUE(tab->interstitial_page() != NULL); 518 ASSERT_TRUE(tab->interstitial_page() != NULL);
518 { 519 {
519 ui_test_utils::WindowedNotificationObserver observer( 520 ui_test_utils::WindowedNotificationObserver observer(
520 chrome::NOTIFICATION_DOWNLOAD_INITIATED, 521 chrome::NOTIFICATION_DOWNLOAD_INITIATED,
521 NotificationService::AllSources()); 522 content::NotificationService::AllSources());
522 tab->interstitial_page()->Proceed(); 523 tab->interstitial_page()->Proceed();
523 observer.Wait(); 524 observer.Wait();
524 } 525 }
525 526
526 // There should still be an interstitial at this point. Press the 527 // There should still be an interstitial at this point. Press the
527 // back button on the browser. Note that this doesn't wait for a 528 // back button on the browser. Note that this doesn't wait for a
528 // NAV_ENTRY_COMMITTED notification because going back with an 529 // NAV_ENTRY_COMMITTED notification because going back with an
529 // active interstitial simply hides the interstitial. 530 // active interstitial simply hides the interstitial.
530 ASSERT_TRUE(tab->interstitial_page() != NULL); 531 ASSERT_TRUE(tab->interstitial_page() != NULL);
531 EXPECT_TRUE(browser()->CanGoBack()); 532 EXPECT_TRUE(browser()->CanGoBack());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 test_server()->host_port_pair(), 663 test_server()->host_port_pair(),
663 &replacement_path)); 664 &replacement_path));
664 665
665 GURL url = https_server_.GetURL(replacement_path); 666 GURL url = https_server_.GetURL(replacement_path);
666 browser::NavigateParams params( 667 browser::NavigateParams params(
667 browser(), url, content::PAGE_TRANSITION_TYPED); 668 browser(), url, content::PAGE_TRANSITION_TYPED);
668 params.disposition = NEW_FOREGROUND_TAB; 669 params.disposition = NEW_FOREGROUND_TAB;
669 params.tabstrip_index = 0; 670 params.tabstrip_index = 0;
670 params.source_contents = tab1; 671 params.source_contents = tab1;
671 ui_test_utils::WindowedNotificationObserver observer( 672 ui_test_utils::WindowedNotificationObserver observer(
672 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); 673 content::NOTIFICATION_LOAD_STOP,
674 content::NotificationService::AllSources());
673 browser::Navigate(&params); 675 browser::Navigate(&params);
674 TabContentsWrapper* tab2 = params.target_contents; 676 TabContentsWrapper* tab2 = params.target_contents;
675 observer.Wait(); 677 observer.Wait();
676 678
677 // The new tab has insecure content. 679 // The new tab has insecure content.
678 CheckAuthenticatedState(tab2->tab_contents(), true); 680 CheckAuthenticatedState(tab2->tab_contents(), true);
679 681
680 // The original tab should not be contaminated. 682 // The original tab should not be contaminated.
681 CheckAuthenticatedState(tab1->tab_contents(), false); 683 CheckAuthenticatedState(tab1->tab_contents(), false);
682 } 684 }
(...skipping 19 matching lines...) Expand all
702 test_server()->host_port_pair(), 704 test_server()->host_port_pair(),
703 &replacement_path)); 705 &replacement_path));
704 706
705 // Create a new tab. 707 // Create a new tab.
706 GURL url = https_server_.GetURL(replacement_path); 708 GURL url = https_server_.GetURL(replacement_path);
707 browser::NavigateParams params( 709 browser::NavigateParams params(
708 browser(), url, content::PAGE_TRANSITION_TYPED); 710 browser(), url, content::PAGE_TRANSITION_TYPED);
709 params.disposition = NEW_FOREGROUND_TAB; 711 params.disposition = NEW_FOREGROUND_TAB;
710 params.source_contents = tab1; 712 params.source_contents = tab1;
711 ui_test_utils::WindowedNotificationObserver observer( 713 ui_test_utils::WindowedNotificationObserver observer(
712 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); 714 content::NOTIFICATION_LOAD_STOP,
715 content::NotificationService::AllSources());
713 browser::Navigate(&params); 716 browser::Navigate(&params);
714 TabContentsWrapper* tab2 = params.target_contents; 717 TabContentsWrapper* tab2 = params.target_contents;
715 observer.Wait(); 718 observer.Wait();
716 719
717 // The new tab has insecure content. 720 // The new tab has insecure content.
718 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); 721 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false);
719 722
720 // Which means the origin for the first tab has also been contaminated with 723 // Which means the origin for the first tab has also been contaminated with
721 // insecure content. 724 // insecure content.
722 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false); 725 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 MessageLoop::current()->PostDelayedTask(FROM_HERE, 880 MessageLoop::current()->PostDelayedTask(FROM_HERE,
878 new MessageLoop::QuitTask(), 1000); 881 new MessageLoop::QuitTask(), 1000);
879 ui_test_utils::RunMessageLoop(); 882 ui_test_utils::RunMessageLoop();
880 } 883 }
881 ASSERT_EQ(1, GetConstrainedWindowCount()); 884 ASSERT_EQ(1, GetConstrainedWindowCount());
882 885
883 // Let's add another tab to make sure the browser does not exit when we close 886 // Let's add another tab to make sure the browser does not exit when we close
884 // the first tab. 887 // the first tab.
885 GURL url = test_server()->GetURL("files/ssl/google.html"); 888 GURL url = test_server()->GetURL("files/ssl/google.html");
886 ui_test_utils::WindowedNotificationObserver observer( 889 ui_test_utils::WindowedNotificationObserver observer(
887 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); 890 content::NOTIFICATION_LOAD_STOP,
891 content::NotificationService::AllSources());
888 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); 892 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
889 observer.Wait(); 893 observer.Wait();
890 894
891 // Close the first tab. 895 // Close the first tab.
892 browser()->CloseTabContents(tab1); 896 browser()->CloseTabContents(tab1);
893 } 897 }
894 898
895 // Visit a page over bad https that is a redirect to a page with good https. 899 // Visit a page over bad https that is a redirect to a page with good https.
896 // Crashes: http://crbug.com/77374 900 // Crashes: http://crbug.com/77374
897 // Previously marked as flaky: http://crbug.com/40932 901 // Previously marked as flaky: http://crbug.com/40932
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 1303
1300 // Visit a page over https that contains a frame with a redirect. 1304 // Visit a page over https that contains a frame with a redirect.
1301 1305
1302 // XMLHttpRequest insecure content in synchronous mode. 1306 // XMLHttpRequest insecure content in synchronous mode.
1303 1307
1304 // XMLHttpRequest insecure content in asynchronous mode. 1308 // XMLHttpRequest insecure content in asynchronous mode.
1305 1309
1306 // XMLHttpRequest over bad ssl in synchronous mode. 1310 // XMLHttpRequest over bad ssl in synchronous mode.
1307 1311
1308 // XMLHttpRequest over OK ssl in synchronous mode. 1312 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | chrome/browser/sync/backend_migrator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698