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

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

Issue 3834002: Make all browser code use browser::Navigate to open tabs.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/time.h" 5 #include "base/time.h"
6 #include "chrome/app/chrome_dll_resource.h" 6 #include "chrome/app/chrome_dll_resource.h"
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_navigator.h"
8 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
10 #include "chrome/browser/tab_contents/interstitial_page.h" 11 #include "chrome/browser/tab_contents/interstitial_page.h"
11 #include "chrome/browser/tab_contents/navigation_entry.h" 12 #include "chrome/browser/tab_contents/navigation_entry.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 13 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/tabs/tab_strip_model.h" 14 #include "chrome/browser/tabs/tab_strip_model.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/test/in_process_browser_test.h" 16 #include "chrome/test/in_process_browser_test.h"
16 #include "chrome/test/ui_test_utils.h" 17 #include "chrome/test/ui_test_utils.h"
17 #include "net/base/cert_status_flags.h" 18 #include "net/base/cert_status_flags.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 https_server_.GetURL("files/ssl/blank_page.html")); 448 https_server_.GetURL("files/ssl/blank_page.html"));
448 449
449 TabContents* tab1 = browser()->GetSelectedTabContents(); 450 TabContents* tab1 = browser()->GetSelectedTabContents();
450 451
451 // This tab should be fine. 452 // This tab should be fine.
452 CheckAuthenticatedState(tab1, false); 453 CheckAuthenticatedState(tab1, false);
453 454
454 // Create a new tab. 455 // Create a new tab.
455 GURL url = https_server_.GetURL( 456 GURL url = https_server_.GetURL(
456 "files/ssl/page_displays_insecure_content.html"); 457 "files/ssl/page_displays_insecure_content.html");
457 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); 458 browser::NavigateParams params(browser(), url, PageTransition::TYPED);
458 params.index = 0; 459 params.disposition = NEW_FOREGROUND_TAB;
459 params.instance = tab1->GetSiteInstance(); 460 params.tabstrip_index = 0;
460 TabContents* tab2 = browser()->AddTabWithURL(&params); 461 params.source_contents = tab1;
462 browser::Navigate(&params);
463 TabContents* tab2 = params.target_contents;
461 ui_test_utils::WaitForNavigation(&(tab2->controller())); 464 ui_test_utils::WaitForNavigation(&(tab2->controller()));
462 465
463 // The new tab has insecure content. 466 // The new tab has insecure content.
464 CheckAuthenticatedState(tab2, true); 467 CheckAuthenticatedState(tab2, true);
465 468
466 // The original tab should not be contaminated. 469 // The original tab should not be contaminated.
467 CheckAuthenticatedState(tab1, false); 470 CheckAuthenticatedState(tab1, false);
468 } 471 }
469 472
470 // Visits two pages from the same origin: one that runs insecure content and one 473 // Visits two pages from the same origin: one that runs insecure content and one
471 // that doesn't. The test checks that we propagate the insecure content state 474 // that doesn't. The test checks that we propagate the insecure content state
472 // from one to the other. 475 // from one to the other.
473 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { 476 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
474 ASSERT_TRUE(test_server()->Start()); 477 ASSERT_TRUE(test_server()->Start());
475 ASSERT_TRUE(https_server_.Start()); 478 ASSERT_TRUE(https_server_.Start());
476 479
477 ui_test_utils::NavigateToURL(browser(), 480 ui_test_utils::NavigateToURL(browser(),
478 https_server_.GetURL("files/ssl/blank_page.html")); 481 https_server_.GetURL("files/ssl/blank_page.html"));
479 482
480 TabContents* tab1 = browser()->GetSelectedTabContents(); 483 TabContents* tab1 = browser()->GetSelectedTabContents();
481 484
482 // This tab should be fine. 485 // This tab should be fine.
483 CheckAuthenticatedState(tab1, false); 486 CheckAuthenticatedState(tab1, false);
484 487
485 // Create a new tab. 488 // Create a new tab.
486 GURL url = 489 GURL url =
487 https_server_.GetURL("files/ssl/page_runs_insecure_content.html"); 490 https_server_.GetURL("files/ssl/page_runs_insecure_content.html");
488 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); 491 browser::NavigateParams params(browser(), url, PageTransition::TYPED);
489 params.instance = tab1->GetSiteInstance(); 492 params.disposition = NEW_FOREGROUND_TAB;
490 TabContents* tab2 = browser()->AddTabWithURL(&params); 493 params.source_contents = tab1;
494 browser::Navigate(&params);
495 TabContents* tab2 = params.target_contents;
491 ui_test_utils::WaitForNavigation(&(tab2->controller())); 496 ui_test_utils::WaitForNavigation(&(tab2->controller()));
492 497
493 // The new tab has insecure content. 498 // The new tab has insecure content.
494 CheckAuthenticationBrokenState(tab2, 0, true, false); 499 CheckAuthenticationBrokenState(tab2, 0, true, false);
495 500
496 // Which means the origin for the first tab has also been contaminated with 501 // Which means the origin for the first tab has also been contaminated with
497 // insecure content. 502 // insecure content.
498 CheckAuthenticationBrokenState(tab1, 0, true, false); 503 CheckAuthenticationBrokenState(tab1, 0, true, false);
499 } 504 }
500 505
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 break; 627 break;
623 MessageLoop::current()->PostDelayedTask(FROM_HERE, 628 MessageLoop::current()->PostDelayedTask(FROM_HERE,
624 new MessageLoop::QuitTask(), 1000); 629 new MessageLoop::QuitTask(), 1000);
625 ui_test_utils::RunMessageLoop(); 630 ui_test_utils::RunMessageLoop();
626 } 631 }
627 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); 632 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count()));
628 633
629 // Let's add another tab to make sure the browser does not exit when we close 634 // Let's add another tab to make sure the browser does not exit when we close
630 // the first tab. 635 // the first tab.
631 GURL url = test_server()->GetURL("files/ssl/google.html"); 636 GURL url = test_server()->GetURL("files/ssl/google.html");
632 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); 637 TabContents* tab2 =
633 TabContents* tab2 = browser()->AddTabWithURL(&params); 638 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
634 ui_test_utils::WaitForNavigation(&(tab2->controller())); 639 ui_test_utils::WaitForNavigation(&(tab2->controller()));
635 640
636 // Ensure that the tab was created in the correct browser.
637 EXPECT_EQ(browser(), params.target);
638
639 // Close the first tab. 641 // Close the first tab.
640 browser()->CloseTabContents(tab1); 642 browser()->CloseTabContents(tab1);
641 } 643 }
642 644
643 // Visit a page over bad https that is a redirect to a page with good https. 645 // Visit a page over bad https that is a redirect to a page with good https.
644 // Marked as flaky, see bug 40932. 646 // Marked as flaky, see bug 40932.
645 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectBadToGoodHTTPS) { 647 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectBadToGoodHTTPS) {
646 ASSERT_TRUE(https_server_.Start()); 648 ASSERT_TRUE(https_server_.Start());
647 ASSERT_TRUE(https_server_expired_.Start()); 649 ASSERT_TRUE(https_server_expired_.Start());
648 650
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 953
952 // Visit a page over https that contains a frame with a redirect. 954 // Visit a page over https that contains a frame with a redirect.
953 955
954 // XMLHttpRequest insecure content in synchronous mode. 956 // XMLHttpRequest insecure content in synchronous mode.
955 957
956 // XMLHttpRequest insecure content in asynchronous mode. 958 // XMLHttpRequest insecure content in asynchronous mode.
957 959
958 // XMLHttpRequest over bad ssl in synchronous mode. 960 // XMLHttpRequest over bad ssl in synchronous mode.
959 961
960 // XMLHttpRequest over OK ssl in synchronous mode. 962 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest.cc ('k') | chrome/browser/tabs/tab_strip_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698