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

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

Issue 10537084: TabContentsWrapper -> TabContents, part 28. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ssl/ssl_add_cert_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_navigator.h" 13 #include "chrome/browser/ui/browser_navigator.h"
14 #include "chrome/browser/ui/constrained_window_tab_helper.h" 14 #include "chrome/browser/ui/constrained_window_tab_helper.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/interstitial_page.h" 22 #include "content/public/browser/interstitial_page.h"
23 #include "content/public/browser/navigation_controller.h" 23 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 191 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
192 ASSERT_TRUE(interstitial_page); 192 ASSERT_TRUE(interstitial_page);
193 ui_test_utils::WindowedNotificationObserver observer( 193 ui_test_utils::WindowedNotificationObserver observer(
194 content::NOTIFICATION_LOAD_STOP, 194 content::NOTIFICATION_LOAD_STOP,
195 content::Source<NavigationController>(&tab->GetController())); 195 content::Source<NavigationController>(&tab->GetController()));
196 interstitial_page->Proceed(); 196 interstitial_page->Proceed();
197 observer.Wait(); 197 observer.Wait();
198 } 198 }
199 199
200 int GetConstrainedWindowCount() const { 200 int GetConstrainedWindowCount() const {
201 return static_cast<int>( 201 return static_cast<int>(browser()->GetActiveTabContents()->
202 browser()->GetSelectedTabContentsWrapper()->
203 constrained_window_tab_helper()->constrained_window_count()); 202 constrained_window_tab_helper()->constrained_window_count());
204 } 203 }
205 204
206 static bool GetFilePathWithHostAndPortReplacement( 205 static bool GetFilePathWithHostAndPortReplacement(
207 const std::string& original_file_path, 206 const std::string& original_file_path,
208 const net::HostPortPair& host_port_pair, 207 const net::HostPortPair& host_port_pair,
209 std::string* replacement_path) { 208 std::string* replacement_path) {
210 std::vector<net::TestServer::StringPair> replacement_text; 209 std::vector<net::TestServer::StringPair> replacement_text;
211 replacement_text.push_back( 210 replacement_text.push_back(
212 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); 211 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString()));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 296 }
298 }; 297 };
299 298
300 // Visits a regular page over http. 299 // Visits a regular page over http.
301 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { 300 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) {
302 ASSERT_TRUE(test_server()->Start()); 301 ASSERT_TRUE(test_server()->Start());
303 302
304 ui_test_utils::NavigateToURL(browser(), 303 ui_test_utils::NavigateToURL(browser(),
305 test_server()->GetURL("files/ssl/google.html")); 304 test_server()->GetURL("files/ssl/google.html"));
306 305
307 CheckUnauthenticatedState(browser()->GetSelectedWebContents()); 306 CheckUnauthenticatedState(browser()->GetActiveWebContents());
308 } 307 }
309 308
310 // Visits a page over http which includes broken https resources (status should 309 // Visits a page over http which includes broken https resources (status should
311 // be OK). 310 // be OK).
312 // TODO(jcampan): test that bad HTTPS content is blocked (otherwise we'll give 311 // TODO(jcampan): test that bad HTTPS content is blocked (otherwise we'll give
313 // the secure cookies away!). 312 // the secure cookies away!).
314 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) { 313 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) {
315 ASSERT_TRUE(test_server()->Start()); 314 ASSERT_TRUE(test_server()->Start());
316 ASSERT_TRUE(https_server_expired_.Start()); 315 ASSERT_TRUE(https_server_expired_.Start());
317 316
318 std::string replacement_path; 317 std::string replacement_path;
319 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 318 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
320 "files/ssl/page_with_unsafe_contents.html", 319 "files/ssl/page_with_unsafe_contents.html",
321 https_server_expired_.host_port_pair(), 320 https_server_expired_.host_port_pair(),
322 &replacement_path)); 321 &replacement_path));
323 322
324 ui_test_utils::NavigateToURL( 323 ui_test_utils::NavigateToURL(
325 browser(), test_server()->GetURL(replacement_path)); 324 browser(), test_server()->GetURL(replacement_path));
326 325
327 CheckUnauthenticatedState(browser()->GetSelectedWebContents()); 326 CheckUnauthenticatedState(browser()->GetActiveWebContents());
328 } 327 }
329 328
330 // http://crbug.com/91745 329 // http://crbug.com/91745
331 #if defined(OS_CHROMEOS) 330 #if defined(OS_CHROMEOS)
332 #define MAYBE_TestOKHTTPS DISABLED_TestOKHTTPS 331 #define MAYBE_TestOKHTTPS DISABLED_TestOKHTTPS
333 #else 332 #else
334 #define MAYBE_TestOKHTTPS TestOKHTTPS 333 #define MAYBE_TestOKHTTPS TestOKHTTPS
335 #endif 334 #endif
336 335
337 // Visits a page over OK https: 336 // Visits a page over OK https:
338 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestOKHTTPS) { 337 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestOKHTTPS) {
339 ASSERT_TRUE(https_server_.Start()); 338 ASSERT_TRUE(https_server_.Start());
340 339
341 ui_test_utils::NavigateToURL(browser(), 340 ui_test_utils::NavigateToURL(browser(),
342 https_server_.GetURL("files/ssl/google.html")); 341 https_server_.GetURL("files/ssl/google.html"));
343 342
344 CheckAuthenticatedState(browser()->GetSelectedWebContents(), false); 343 CheckAuthenticatedState(browser()->GetActiveWebContents(), false);
345 } 344 }
346 345
347 // Visits a page with https error and proceed: 346 // Visits a page with https error and proceed:
348 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndProceed) { 347 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndProceed) {
349 ASSERT_TRUE(https_server_expired_.Start()); 348 ASSERT_TRUE(https_server_expired_.Start());
350 349
351 ui_test_utils::NavigateToURL(browser(), 350 ui_test_utils::NavigateToURL(browser(),
352 https_server_expired_.GetURL("files/ssl/google.html")); 351 https_server_expired_.GetURL("files/ssl/google.html"));
353 352
354 WebContents* tab = browser()->GetSelectedWebContents(); 353 WebContents* tab = browser()->GetActiveWebContents();
355 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 354 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
356 true); // Interstitial showing 355 true); // Interstitial showing
357 356
358 ProceedThroughInterstitial(tab); 357 ProceedThroughInterstitial(tab);
359 358
360 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 359 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
361 false); // No interstitial showing 360 false); // No interstitial showing
362 } 361 }
363 362
364 // Visits a page with https error and don't proceed (and ensure we can still 363 // Visits a page with https error and don't proceed (and ensure we can still
365 // navigate at that point): 364 // navigate at that point):
366 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndDontProceed) { 365 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndDontProceed) {
367 ASSERT_TRUE(test_server()->Start()); 366 ASSERT_TRUE(test_server()->Start());
368 ASSERT_TRUE(https_server_.Start()); 367 ASSERT_TRUE(https_server_.Start());
369 ASSERT_TRUE(https_server_expired_.Start()); 368 ASSERT_TRUE(https_server_expired_.Start());
370 369
371 // First navigate to an OK page. 370 // First navigate to an OK page.
372 ui_test_utils::NavigateToURL(browser(), 371 ui_test_utils::NavigateToURL(browser(),
373 https_server_.GetURL("files/ssl/google.html")); 372 https_server_.GetURL("files/ssl/google.html"));
374 373
375 WebContents* tab = browser()->GetSelectedWebContents(); 374 WebContents* tab = browser()->GetActiveWebContents();
376 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 375 NavigationEntry* entry = tab->GetController().GetActiveEntry();
377 ASSERT_TRUE(entry); 376 ASSERT_TRUE(entry);
378 377
379 GURL cross_site_url = 378 GURL cross_site_url =
380 https_server_expired_.GetURL("files/ssl/google.html"); 379 https_server_expired_.GetURL("files/ssl/google.html");
381 // Change the host name from 127.0.0.1 to localhost so it triggers a 380 // Change the host name from 127.0.0.1 to localhost so it triggers a
382 // cross-site navigation so we can test http://crbug.com/5800 is gone. 381 // cross-site navigation so we can test http://crbug.com/5800 is gone.
383 ASSERT_EQ("127.0.0.1", cross_site_url.host()); 382 ASSERT_EQ("127.0.0.1", cross_site_url.host());
384 GURL::Replacements replacements; 383 GURL::Replacements replacements;
385 std::string new_host("localhost"); 384 std::string new_host("localhost");
(...skipping 23 matching lines...) Expand all
409 408
410 // Visits a page with https error and then goes back using Browser::GoBack. 409 // Visits a page with https error and then goes back using Browser::GoBack.
411 IN_PROC_BROWSER_TEST_F(SSLUITest, 410 IN_PROC_BROWSER_TEST_F(SSLUITest,
412 TestHTTPSExpiredCertAndGoBackViaButton) { 411 TestHTTPSExpiredCertAndGoBackViaButton) {
413 ASSERT_TRUE(test_server()->Start()); 412 ASSERT_TRUE(test_server()->Start());
414 ASSERT_TRUE(https_server_expired_.Start()); 413 ASSERT_TRUE(https_server_expired_.Start());
415 414
416 // First navigate to an HTTP page. 415 // First navigate to an HTTP page.
417 ui_test_utils::NavigateToURL(browser(), 416 ui_test_utils::NavigateToURL(browser(),
418 test_server()->GetURL("files/ssl/google.html")); 417 test_server()->GetURL("files/ssl/google.html"));
419 WebContents* tab = browser()->GetSelectedWebContents(); 418 WebContents* tab = browser()->GetActiveWebContents();
420 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 419 NavigationEntry* entry = tab->GetController().GetActiveEntry();
421 ASSERT_TRUE(entry); 420 ASSERT_TRUE(entry);
422 421
423 // Now go to a bad HTTPS page that shows an interstitial. 422 // Now go to a bad HTTPS page that shows an interstitial.
424 ui_test_utils::NavigateToURL(browser(), 423 ui_test_utils::NavigateToURL(browser(),
425 https_server_expired_.GetURL("files/ssl/google.html")); 424 https_server_expired_.GetURL("files/ssl/google.html"));
426 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 425 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
427 true); // Interstitial showing 426 true); // Interstitial showing
428 427
429 ProvisionalLoadWaiter load_failed_observer(tab); 428 ProvisionalLoadWaiter load_failed_observer(tab);
430 429
431 // Simulate user clicking on back button (crbug.com/39248). 430 // Simulate user clicking on back button (crbug.com/39248).
432 browser()->GoBack(CURRENT_TAB); 431 browser()->GoBack(CURRENT_TAB);
433 432
434 // Wait until we hear the load failure, and make sure we haven't swapped out 433 // Wait until we hear the load failure, and make sure we haven't swapped out
435 // the previous page. Prevents regression of http://crbug.com/82667. 434 // the previous page. Prevents regression of http://crbug.com/82667.
436 load_failed_observer.Wait(); 435 load_failed_observer.Wait();
437 EXPECT_FALSE(content::RenderViewHostTester::IsRenderViewHostSwappedOut( 436 EXPECT_FALSE(content::RenderViewHostTester::IsRenderViewHostSwappedOut(
438 tab->GetRenderViewHost())); 437 tab->GetRenderViewHost()));
439 438
440 // We should be back at the original good page. 439 // We should be back at the original good page.
441 EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage()); 440 EXPECT_FALSE(browser()->GetActiveWebContents()->GetInterstitialPage());
442 CheckUnauthenticatedState(tab); 441 CheckUnauthenticatedState(tab);
443 } 442 }
444 443
445 // Visits a page with https error and then goes back using GoToOffset. 444 // Visits a page with https error and then goes back using GoToOffset.
446 // Disabled because its flaky: http://crbug.com/40932, http://crbug.com/43575. 445 // Disabled because its flaky: http://crbug.com/40932, http://crbug.com/43575.
447 IN_PROC_BROWSER_TEST_F(SSLUITest, 446 IN_PROC_BROWSER_TEST_F(SSLUITest,
448 TestHTTPSExpiredCertAndGoBackViaMenu) { 447 TestHTTPSExpiredCertAndGoBackViaMenu) {
449 ASSERT_TRUE(test_server()->Start()); 448 ASSERT_TRUE(test_server()->Start());
450 ASSERT_TRUE(https_server_expired_.Start()); 449 ASSERT_TRUE(https_server_expired_.Start());
451 450
452 // First navigate to an HTTP page. 451 // First navigate to an HTTP page.
453 ui_test_utils::NavigateToURL(browser(), 452 ui_test_utils::NavigateToURL(browser(),
454 test_server()->GetURL("files/ssl/google.html")); 453 test_server()->GetURL("files/ssl/google.html"));
455 WebContents* tab = browser()->GetSelectedWebContents(); 454 WebContents* tab = browser()->GetActiveWebContents();
456 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 455 NavigationEntry* entry = tab->GetController().GetActiveEntry();
457 ASSERT_TRUE(entry); 456 ASSERT_TRUE(entry);
458 457
459 // Now go to a bad HTTPS page that shows an interstitial. 458 // Now go to a bad HTTPS page that shows an interstitial.
460 ui_test_utils::NavigateToURL(browser(), 459 ui_test_utils::NavigateToURL(browser(),
461 https_server_expired_.GetURL("files/ssl/google.html")); 460 https_server_expired_.GetURL("files/ssl/google.html"));
462 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 461 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
463 true); // Interstitial showing 462 true); // Interstitial showing
464 463
465 // Simulate user clicking and holding on back button (crbug.com/37215). 464 // Simulate user clicking and holding on back button (crbug.com/37215).
466 tab->GetController().GoToOffset(-1); 465 tab->GetController().GoToOffset(-1);
467 466
468 // We should be back at the original good page. 467 // We should be back at the original good page.
469 EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage()); 468 EXPECT_FALSE(browser()->GetActiveWebContents()->GetInterstitialPage());
470 CheckUnauthenticatedState(tab); 469 CheckUnauthenticatedState(tab);
471 } 470 }
472 471
473 // Visits a page with https error and then goes forward using GoToOffset. 472 // Visits a page with https error and then goes forward using GoToOffset.
474 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) { 473 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) {
475 ASSERT_TRUE(test_server()->Start()); 474 ASSERT_TRUE(test_server()->Start());
476 ASSERT_TRUE(https_server_expired_.Start()); 475 ASSERT_TRUE(https_server_expired_.Start());
477 476
478 // First navigate to two HTTP pages. 477 // First navigate to two HTTP pages.
479 ui_test_utils::NavigateToURL(browser(), 478 ui_test_utils::NavigateToURL(browser(),
480 test_server()->GetURL("files/ssl/google.html")); 479 test_server()->GetURL("files/ssl/google.html"));
481 WebContents* tab = browser()->GetSelectedWebContents(); 480 WebContents* tab = browser()->GetActiveWebContents();
482 NavigationEntry* entry1 = tab->GetController().GetActiveEntry(); 481 NavigationEntry* entry1 = tab->GetController().GetActiveEntry();
483 ASSERT_TRUE(entry1); 482 ASSERT_TRUE(entry1);
484 ui_test_utils::NavigateToURL(browser(), 483 ui_test_utils::NavigateToURL(browser(),
485 test_server()->GetURL("files/ssl/blank_page.html")); 484 test_server()->GetURL("files/ssl/blank_page.html"));
486 NavigationEntry* entry2 = tab->GetController().GetActiveEntry(); 485 NavigationEntry* entry2 = tab->GetController().GetActiveEntry();
487 ASSERT_TRUE(entry2); 486 ASSERT_TRUE(entry2);
488 487
489 // Now go back so that a page is in the forward history. 488 // Now go back so that a page is in the forward history.
490 { 489 {
491 ui_test_utils::WindowedNotificationObserver observer( 490 ui_test_utils::WindowedNotificationObserver observer(
(...skipping 15 matching lines...) Expand all
507 // Simulate user clicking and holding on forward button. 506 // Simulate user clicking and holding on forward button.
508 { 507 {
509 ui_test_utils::WindowedNotificationObserver observer( 508 ui_test_utils::WindowedNotificationObserver observer(
510 content::NOTIFICATION_LOAD_STOP, 509 content::NOTIFICATION_LOAD_STOP,
511 content::Source<NavigationController>(&tab->GetController())); 510 content::Source<NavigationController>(&tab->GetController()));
512 tab->GetController().GoToOffset(1); 511 tab->GetController().GoToOffset(1);
513 observer.Wait(); 512 observer.Wait();
514 } 513 }
515 514
516 // We should be showing the second good page. 515 // We should be showing the second good page.
517 EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage()); 516 EXPECT_FALSE(browser()->GetActiveWebContents()->GetInterstitialPage());
518 CheckUnauthenticatedState(tab); 517 CheckUnauthenticatedState(tab);
519 EXPECT_FALSE(tab->GetController().CanGoForward()); 518 EXPECT_FALSE(tab->GetController().CanGoForward());
520 NavigationEntry* entry4 = tab->GetController().GetActiveEntry(); 519 NavigationEntry* entry4 = tab->GetController().GetActiveEntry();
521 EXPECT_TRUE(entry2 == entry4); 520 EXPECT_TRUE(entry2 == entry4);
522 } 521 }
523 522
524 // Visit a HTTP page which request WSS connection to a server providing invalid 523 // Visit a HTTP page which request WSS connection to a server providing invalid
525 // certificate. Close the page while WSS connection waits for SSLManager's 524 // certificate. Close the page while WSS connection waits for SSLManager's
526 // response from UI thread. 525 // response from UI thread.
527 IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) { 526 IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
528 ASSERT_TRUE(test_server()->Start()); 527 ASSERT_TRUE(test_server()->Start());
529 ASSERT_TRUE(https_server_expired_.Start()); 528 ASSERT_TRUE(https_server_expired_.Start());
530 529
531 // Setup page title observer. 530 // Setup page title observer.
532 WebContents* tab = browser()->GetSelectedWebContents(); 531 WebContents* tab = browser()->GetActiveWebContents();
533 ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); 532 ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
534 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 533 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
535 534
536 // Create GURLs to test pages. 535 // Create GURLs to test pages.
537 std::string masterUrlPath = StringPrintf("%s?%d", 536 std::string masterUrlPath = StringPrintf("%s?%d",
538 test_server()->GetURL("files/ssl/wss_close.html").spec().c_str(), 537 test_server()->GetURL("files/ssl/wss_close.html").spec().c_str(),
539 https_server_expired_.host_port_pair().port()); 538 https_server_expired_.host_port_pair().port());
540 GURL masterUrl(masterUrlPath); 539 GURL masterUrl(masterUrlPath);
541 std::string slaveUrlPath = StringPrintf("%s?%d", 540 std::string slaveUrlPath = StringPrintf("%s?%d",
542 test_server()->GetURL("files/ssl/wss_close_slave.html").spec().c_str(), 541 test_server()->GetURL("files/ssl/wss_close_slave.html").spec().c_str(),
543 https_server_expired_.host_port_pair().port()); 542 https_server_expired_.host_port_pair().port());
544 GURL slaveUrl(slaveUrlPath); 543 GURL slaveUrl(slaveUrlPath);
545 544
546 // Create tabs and visit pages which keep on creating wss connections. 545 // Create tabs and visit pages which keep on creating wss connections.
547 TabContentsWrapper* tabs[16]; 546 TabContents* tabs[16];
548 for (int i = 0; i < 16; ++i) { 547 for (int i = 0; i < 16; ++i) {
549 tabs[i] = browser()->AddSelectedTabWithURL( 548 tabs[i] = browser()->AddSelectedTabWithURL(
550 slaveUrl, content::PAGE_TRANSITION_LINK); 549 slaveUrl, content::PAGE_TRANSITION_LINK);
551 } 550 }
552 browser()->SelectNextTab(); 551 browser()->SelectNextTab();
553 552
554 // Visit a page which waits for one TLS handshake failure. 553 // Visit a page which waits for one TLS handshake failure.
555 // The title will be changed to 'PASS'. 554 // The title will be changed to 'PASS'.
556 ui_test_utils::NavigateToURL(browser(), masterUrl); 555 ui_test_utils::NavigateToURL(browser(), masterUrl);
557 const string16 result = watcher.WaitAndGetTitle(); 556 const string16 result = watcher.WaitAndGetTitle();
(...skipping 14 matching lines...) Expand all
572 571
573 // Start pywebsocket with TLS. 572 // Start pywebsocket with TLS.
574 ui_test_utils::TestWebSocketServer wss_server; 573 ui_test_utils::TestWebSocketServer wss_server;
575 int port = wss_server.UseRandomPort(); 574 int port = wss_server.UseRandomPort();
576 wss_server.UseTLS(); 575 wss_server.UseTLS();
577 FilePath wss_root_dir; 576 FilePath wss_root_dir;
578 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &wss_root_dir)); 577 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &wss_root_dir));
579 ASSERT_TRUE(wss_server.Start(wss_root_dir)); 578 ASSERT_TRUE(wss_server.Start(wss_root_dir));
580 579
581 // Setup page title observer. 580 // Setup page title observer.
582 WebContents* tab = browser()->GetSelectedWebContents(); 581 WebContents* tab = browser()->GetActiveWebContents();
583 ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); 582 ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
584 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 583 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
585 584
586 // Visit bad HTTPS page. 585 // Visit bad HTTPS page.
587 std::string urlPath = 586 std::string urlPath =
588 StringPrintf("%s%d%s", "https://localhost:", port, "/wss.html"); 587 StringPrintf("%s%d%s", "https://localhost:", port, "/wss.html");
589 ui_test_utils::NavigateToURL(browser(), GURL(urlPath)); 588 ui_test_utils::NavigateToURL(browser(), GURL(urlPath));
590 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 589 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
591 false, true); // Interstitial showing 590 false, true); // Interstitial showing
592 591
(...skipping 15 matching lines...) Expand all
608 #endif // defined(OS_CHROMEOS) 607 #endif // defined(OS_CHROMEOS)
609 608
610 // Open a page with a HTTPS error in a tab with no prior navigation (through a 609 // Open a page with a HTTPS error in a tab with no prior navigation (through a
611 // link with a blank target). This is to test that the lack of navigation entry 610 // link with a blank target). This is to test that the lack of navigation entry
612 // does not cause any problems (it was causing a crasher, see 611 // does not cause any problems (it was causing a crasher, see
613 // http://crbug.com/19941). 612 // http://crbug.com/19941).
614 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSErrorWithNoNavEntry) { 613 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSErrorWithNoNavEntry) {
615 ASSERT_TRUE(https_server_expired_.Start()); 614 ASSERT_TRUE(https_server_expired_.Start());
616 615
617 GURL url = https_server_expired_.GetURL("files/ssl/google.htm"); 616 GURL url = https_server_expired_.GetURL("files/ssl/google.htm");
618 TabContentsWrapper* tab2 = 617 TabContents* tab2 =
619 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); 618 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
620 ui_test_utils::WaitForLoadStop(tab2->web_contents()); 619 ui_test_utils::WaitForLoadStop(tab2->web_contents());
621 620
622 // Verify our assumption that there was no prior navigation. 621 // Verify our assumption that there was no prior navigation.
623 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_BACK)); 622 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_BACK));
624 623
625 // We should have an interstitial page showing. 624 // We should have an interstitial page showing.
626 ASSERT_TRUE(tab2->web_contents()->GetInterstitialPage()); 625 ASSERT_TRUE(tab2->web_contents()->GetInterstitialPage());
627 } 626 }
628 627
(...skipping 15 matching lines...) Expand all
644 content::NOTIFICATION_LOAD_STOP, 643 content::NOTIFICATION_LOAD_STOP,
645 content::NotificationService::AllSources()); 644 content::NotificationService::AllSources());
646 browser::NavigateParams navigate_params(browser(), url_dangerous, 645 browser::NavigateParams navigate_params(browser(), url_dangerous,
647 content::PAGE_TRANSITION_TYPED); 646 content::PAGE_TRANSITION_TYPED);
648 browser::Navigate(&navigate_params); 647 browser::Navigate(&navigate_params);
649 observer.Wait(); 648 observer.Wait();
650 } 649 }
651 650
652 // Proceed through the SSL interstitial. This doesn't use 651 // Proceed through the SSL interstitial. This doesn't use
653 // |ProceedThroughInterstitial| since no page load will commit. 652 // |ProceedThroughInterstitial| since no page load will commit.
654 WebContents* tab = browser()->GetSelectedWebContents(); 653 WebContents* tab = browser()->GetActiveWebContents();
655 ASSERT_TRUE(tab != NULL); 654 ASSERT_TRUE(tab != NULL);
656 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); 655 ASSERT_TRUE(tab->GetInterstitialPage() != NULL);
657 { 656 {
658 ui_test_utils::WindowedNotificationObserver observer( 657 ui_test_utils::WindowedNotificationObserver observer(
659 chrome::NOTIFICATION_DOWNLOAD_INITIATED, 658 chrome::NOTIFICATION_DOWNLOAD_INITIATED,
660 content::NotificationService::AllSources()); 659 content::NotificationService::AllSources());
661 tab->GetInterstitialPage()->Proceed(); 660 tab->GetInterstitialPage()->Proceed();
662 observer.Wait(); 661 observer.Wait();
663 } 662 }
664 663
(...skipping 18 matching lines...) Expand all
683 std::string replacement_path; 682 std::string replacement_path;
684 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 683 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
685 "files/ssl/page_displays_insecure_content.html", 684 "files/ssl/page_displays_insecure_content.html",
686 test_server()->host_port_pair(), 685 test_server()->host_port_pair(),
687 &replacement_path)); 686 &replacement_path));
688 687
689 // Load a page that displays insecure content. 688 // Load a page that displays insecure content.
690 ui_test_utils::NavigateToURL(browser(), 689 ui_test_utils::NavigateToURL(browser(),
691 https_server_.GetURL(replacement_path)); 690 https_server_.GetURL(replacement_path));
692 691
693 CheckAuthenticatedState(browser()->GetSelectedWebContents(), true); 692 CheckAuthenticatedState(browser()->GetActiveWebContents(), true);
694 } 693 }
695 694
696 // Visits a page that runs insecure content and tries to suppress the insecure 695 // Visits a page that runs insecure content and tries to suppress the insecure
697 // content warnings by randomizing location.hash. 696 // content warnings by randomizing location.hash.
698 // Based on http://crbug.com/8706 697 // Based on http://crbug.com/8706
699 IN_PROC_BROWSER_TEST_F(SSLUITest, 698 IN_PROC_BROWSER_TEST_F(SSLUITest,
700 TestRunsInsecuredContentRandomizeHash) { 699 TestRunsInsecuredContentRandomizeHash) {
701 ASSERT_TRUE(test_server()->Start()); 700 ASSERT_TRUE(test_server()->Start());
702 ASSERT_TRUE(https_server_.Start()); 701 ASSERT_TRUE(https_server_.Start());
703 702
704 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( 703 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL(
705 "files/ssl/page_runs_insecure_content.html")); 704 "files/ssl/page_runs_insecure_content.html"));
706 705
707 CheckAuthenticationBrokenState(browser()->GetSelectedWebContents(), 0, true, 706 CheckAuthenticationBrokenState(browser()->GetActiveWebContents(), 0, true,
708 false); 707 false);
709 } 708 }
710 709
711 // Visits a page with unsafe content and make sure that: 710 // Visits a page with unsafe content and make sure that:
712 // - frames content is replaced with warning 711 // - frames content is replaced with warning
713 // - images and scripts are filtered out entirely 712 // - images and scripts are filtered out entirely
714 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContents) { 713 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContents) {
715 ASSERT_TRUE(https_server_.Start()); 714 ASSERT_TRUE(https_server_.Start());
716 ASSERT_TRUE(https_server_expired_.Start()); 715 ASSERT_TRUE(https_server_expired_.Start());
717 716
718 std::string replacement_path; 717 std::string replacement_path;
719 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 718 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
720 "files/ssl/page_with_unsafe_contents.html", 719 "files/ssl/page_with_unsafe_contents.html",
721 https_server_expired_.host_port_pair(), 720 https_server_expired_.host_port_pair(),
722 &replacement_path)); 721 &replacement_path));
723 ui_test_utils::NavigateToURL(browser(), 722 ui_test_utils::NavigateToURL(browser(),
724 https_server_.GetURL(replacement_path)); 723 https_server_.GetURL(replacement_path));
725 724
726 WebContents* tab = browser()->GetSelectedWebContents(); 725 WebContents* tab = browser()->GetActiveWebContents();
727 // When the bad content is filtered, the state is expected to be 726 // When the bad content is filtered, the state is expected to be
728 // authenticated. 727 // authenticated.
729 CheckAuthenticatedState(tab, false); 728 CheckAuthenticatedState(tab, false);
730 729
731 // Because of cross-frame scripting restrictions, we cannot access the iframe 730 // Because of cross-frame scripting restrictions, we cannot access the iframe
732 // content. So to know if the frame was loaded, we just check if a popup was 731 // content. So to know if the frame was loaded, we just check if a popup was
733 // opened (the iframe content opens one). 732 // opened (the iframe content opens one).
734 // Note: because of bug 1115868, no constrained window is opened right now. 733 // Note: because of bug 1115868, no constrained window is opened right now.
735 // Once the bug is fixed, this will do the real check. 734 // Once the bug is fixed, this will do the real check.
736 EXPECT_EQ(0, GetConstrainedWindowCount()); 735 EXPECT_EQ(0, GetConstrainedWindowCount());
(...skipping 21 matching lines...) Expand all
758 ASSERT_TRUE(https_server_.Start()); 757 ASSERT_TRUE(https_server_.Start());
759 758
760 std::string replacement_path; 759 std::string replacement_path;
761 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 760 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
762 "files/ssl/page_with_dynamic_insecure_content.html", 761 "files/ssl/page_with_dynamic_insecure_content.html",
763 test_server()->host_port_pair(), 762 test_server()->host_port_pair(),
764 &replacement_path)); 763 &replacement_path));
765 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( 764 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL(
766 replacement_path)); 765 replacement_path));
767 766
768 WebContents* tab = browser()->GetSelectedWebContents(); 767 WebContents* tab = browser()->GetActiveWebContents();
769 CheckAuthenticatedState(tab, false); 768 CheckAuthenticatedState(tab, false);
770 769
771 // Load the insecure image. 770 // Load the insecure image.
772 bool js_result = false; 771 bool js_result = false;
773 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 772 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
774 tab->GetRenderViewHost(), std::wstring(), L"loadBadImage();", 773 tab->GetRenderViewHost(), std::wstring(), L"loadBadImage();",
775 &js_result)); 774 &js_result));
776 EXPECT_TRUE(js_result); 775 EXPECT_TRUE(js_result);
777 776
778 // We should now have insecure content. 777 // We should now have insecure content.
779 CheckAuthenticatedState(tab, true); 778 CheckAuthenticatedState(tab, true);
780 } 779 }
781 780
782 // Visits two pages from the same origin: one that displays insecure content and 781 // Visits two pages from the same origin: one that displays insecure content and
783 // one that doesn't. The test checks that we do not propagate the insecure 782 // one that doesn't. The test checks that we do not propagate the insecure
784 // content state from one to the other. 783 // content state from one to the other.
785 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) { 784 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) {
786 ASSERT_TRUE(test_server()->Start()); 785 ASSERT_TRUE(test_server()->Start());
787 ASSERT_TRUE(https_server_.Start()); 786 ASSERT_TRUE(https_server_.Start());
788 787
789 ui_test_utils::NavigateToURL(browser(), 788 ui_test_utils::NavigateToURL(browser(),
790 https_server_.GetURL("files/ssl/blank_page.html")); 789 https_server_.GetURL("files/ssl/blank_page.html"));
791 790
792 TabContentsWrapper* tab1 = browser()->GetSelectedTabContentsWrapper(); 791 TabContents* tab1 = browser()->GetActiveTabContents();
793 792
794 // This tab should be fine. 793 // This tab should be fine.
795 CheckAuthenticatedState(tab1->web_contents(), false); 794 CheckAuthenticatedState(tab1->web_contents(), false);
796 795
797 // Create a new tab. 796 // Create a new tab.
798 std::string replacement_path; 797 std::string replacement_path;
799 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 798 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
800 "files/ssl/page_displays_insecure_content.html", 799 "files/ssl/page_displays_insecure_content.html",
801 test_server()->host_port_pair(), 800 test_server()->host_port_pair(),
802 &replacement_path)); 801 &replacement_path));
803 802
804 GURL url = https_server_.GetURL(replacement_path); 803 GURL url = https_server_.GetURL(replacement_path);
805 browser::NavigateParams params( 804 browser::NavigateParams params(
806 browser(), url, content::PAGE_TRANSITION_TYPED); 805 browser(), url, content::PAGE_TRANSITION_TYPED);
807 params.disposition = NEW_FOREGROUND_TAB; 806 params.disposition = NEW_FOREGROUND_TAB;
808 params.tabstrip_index = 0; 807 params.tabstrip_index = 0;
809 params.source_contents = tab1; 808 params.source_contents = tab1;
810 ui_test_utils::WindowedNotificationObserver observer( 809 ui_test_utils::WindowedNotificationObserver observer(
811 content::NOTIFICATION_LOAD_STOP, 810 content::NOTIFICATION_LOAD_STOP,
812 content::NotificationService::AllSources()); 811 content::NotificationService::AllSources());
813 browser::Navigate(&params); 812 browser::Navigate(&params);
814 TabContentsWrapper* tab2 = params.target_contents; 813 TabContents* tab2 = params.target_contents;
815 observer.Wait(); 814 observer.Wait();
816 815
817 // The new tab has insecure content. 816 // The new tab has insecure content.
818 CheckAuthenticatedState(tab2->web_contents(), true); 817 CheckAuthenticatedState(tab2->web_contents(), true);
819 818
820 // The original tab should not be contaminated. 819 // The original tab should not be contaminated.
821 CheckAuthenticatedState(tab1->web_contents(), false); 820 CheckAuthenticatedState(tab1->web_contents(), false);
822 } 821 }
823 822
824 // Visits two pages from the same origin: one that runs insecure content and one 823 // Visits two pages from the same origin: one that runs insecure content and one
825 // that doesn't. The test checks that we propagate the insecure content state 824 // that doesn't. The test checks that we propagate the insecure content state
826 // from one to the other. 825 // from one to the other.
827 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { 826 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
828 ASSERT_TRUE(test_server()->Start()); 827 ASSERT_TRUE(test_server()->Start());
829 ASSERT_TRUE(https_server_.Start()); 828 ASSERT_TRUE(https_server_.Start());
830 829
831 ui_test_utils::NavigateToURL(browser(), 830 ui_test_utils::NavigateToURL(browser(),
832 https_server_.GetURL("files/ssl/blank_page.html")); 831 https_server_.GetURL("files/ssl/blank_page.html"));
833 832
834 TabContentsWrapper* tab1 = browser()->GetSelectedTabContentsWrapper(); 833 TabContents* tab1 = browser()->GetActiveTabContents();
835 834
836 // This tab should be fine. 835 // This tab should be fine.
837 CheckAuthenticatedState(tab1->web_contents(), false); 836 CheckAuthenticatedState(tab1->web_contents(), false);
838 837
839 std::string replacement_path; 838 std::string replacement_path;
840 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 839 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
841 "files/ssl/page_runs_insecure_content.html", 840 "files/ssl/page_runs_insecure_content.html",
842 test_server()->host_port_pair(), 841 test_server()->host_port_pair(),
843 &replacement_path)); 842 &replacement_path));
844 843
845 // Create a new tab in the same process. 844 // Create a new tab in the same process.
846 GURL url = https_server_.GetURL(replacement_path); 845 GURL url = https_server_.GetURL(replacement_path);
847 browser::NavigateParams params( 846 browser::NavigateParams params(
848 browser(), url, content::PAGE_TRANSITION_TYPED); 847 browser(), url, content::PAGE_TRANSITION_TYPED);
849 params.disposition = NEW_FOREGROUND_TAB; 848 params.disposition = NEW_FOREGROUND_TAB;
850 params.source_contents = tab1; 849 params.source_contents = tab1;
851 ui_test_utils::WindowedNotificationObserver observer( 850 ui_test_utils::WindowedNotificationObserver observer(
852 content::NOTIFICATION_LOAD_STOP, 851 content::NOTIFICATION_LOAD_STOP,
853 content::NotificationService::AllSources()); 852 content::NotificationService::AllSources());
854 browser::Navigate(&params); 853 browser::Navigate(&params);
855 TabContentsWrapper* tab2 = params.target_contents; 854 TabContents* tab2 = params.target_contents;
856 observer.Wait(); 855 observer.Wait();
857 856
858 // The new tab has insecure content. 857 // The new tab has insecure content.
859 CheckAuthenticationBrokenState(tab2->web_contents(), 0, true, false); 858 CheckAuthenticationBrokenState(tab2->web_contents(), 0, true, false);
860 859
861 // Which means the origin for the first tab has also been contaminated with 860 // Which means the origin for the first tab has also been contaminated with
862 // insecure content. 861 // insecure content.
863 CheckAuthenticationBrokenState(tab1->web_contents(), 0, true, false); 862 CheckAuthenticationBrokenState(tab1->web_contents(), 0, true, false);
864 } 863 }
865 864
866 // Visits a page with an image over http. Visits another page over https 865 // Visits a page with an image over http. Visits another page over https
867 // referencing that same image over http (hoping it is coming from the webcore 866 // referencing that same image over http (hoping it is coming from the webcore
868 // memory cache). 867 // memory cache).
869 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysCachedInsecureContent) { 868 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysCachedInsecureContent) {
870 ASSERT_TRUE(test_server()->Start()); 869 ASSERT_TRUE(test_server()->Start());
871 ASSERT_TRUE(https_server_.Start()); 870 ASSERT_TRUE(https_server_.Start());
872 871
873 std::string replacement_path; 872 std::string replacement_path;
874 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 873 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
875 "files/ssl/page_displays_insecure_content.html", 874 "files/ssl/page_displays_insecure_content.html",
876 test_server()->host_port_pair(), 875 test_server()->host_port_pair(),
877 &replacement_path)); 876 &replacement_path));
878 877
879 // Load original page over HTTP. 878 // Load original page over HTTP.
880 const GURL url_http = test_server()->GetURL(replacement_path); 879 const GURL url_http = test_server()->GetURL(replacement_path);
881 ui_test_utils::NavigateToURL(browser(), url_http); 880 ui_test_utils::NavigateToURL(browser(), url_http);
882 WebContents* tab = browser()->GetSelectedWebContents(); 881 WebContents* tab = browser()->GetActiveWebContents();
883 CheckUnauthenticatedState(tab); 882 CheckUnauthenticatedState(tab);
884 883
885 // Load again but over SSL. It should be marked as displaying insecure 884 // Load again but over SSL. It should be marked as displaying insecure
886 // content (even though the image comes from the WebCore memory cache). 885 // content (even though the image comes from the WebCore memory cache).
887 const GURL url_https = https_server_.GetURL(replacement_path); 886 const GURL url_https = https_server_.GetURL(replacement_path);
888 ui_test_utils::NavigateToURL(browser(), url_https); 887 ui_test_utils::NavigateToURL(browser(), url_https);
889 CheckAuthenticatedState(tab, true); 888 CheckAuthenticatedState(tab, true);
890 } 889 }
891 890
892 // http://crbug.com/84729 891 // http://crbug.com/84729
(...skipping 13 matching lines...) Expand all
906 905
907 std::string replacement_path; 906 std::string replacement_path;
908 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 907 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
909 "files/ssl/page_runs_insecure_content.html", 908 "files/ssl/page_runs_insecure_content.html",
910 test_server()->host_port_pair(), 909 test_server()->host_port_pair(),
911 &replacement_path)); 910 &replacement_path));
912 911
913 // Load original page over HTTP. 912 // Load original page over HTTP.
914 const GURL url_http = test_server()->GetURL(replacement_path); 913 const GURL url_http = test_server()->GetURL(replacement_path);
915 ui_test_utils::NavigateToURL(browser(), url_http); 914 ui_test_utils::NavigateToURL(browser(), url_http);
916 WebContents* tab = browser()->GetSelectedWebContents(); 915 WebContents* tab = browser()->GetActiveWebContents();
917 CheckUnauthenticatedState(tab); 916 CheckUnauthenticatedState(tab);
918 917
919 // Load again but over SSL. It should be marked as displaying insecure 918 // Load again but over SSL. It should be marked as displaying insecure
920 // content (even though the image comes from the WebCore memory cache). 919 // content (even though the image comes from the WebCore memory cache).
921 const GURL url_https = https_server_.GetURL(replacement_path); 920 const GURL url_https = https_server_.GetURL(replacement_path);
922 ui_test_utils::NavigateToURL(browser(), url_https); 921 ui_test_utils::NavigateToURL(browser(), url_https);
923 CheckAuthenticationBrokenState(tab, 0, true, false); 922 CheckAuthenticationBrokenState(tab, 0, true, false);
924 } 923 }
925 924
926 // This test ensures the CN invalid status does not 'stick' to a certificate 925 // This test ensures the CN invalid status does not 'stick' to a certificate
927 // (see bug #1044942) and that it depends on the host-name. 926 // (see bug #1044942) and that it depends on the host-name.
928 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCNInvalidStickiness) { 927 IN_PROC_BROWSER_TEST_F(SSLUITest, TestCNInvalidStickiness) {
929 ASSERT_TRUE(https_server_.Start()); 928 ASSERT_TRUE(https_server_.Start());
930 ASSERT_TRUE(https_server_mismatched_.Start()); 929 ASSERT_TRUE(https_server_mismatched_.Start());
931 930
932 // First we hit the server with hostname, this generates an invalid policy 931 // First we hit the server with hostname, this generates an invalid policy
933 // error. 932 // error.
934 ui_test_utils::NavigateToURL(browser(), 933 ui_test_utils::NavigateToURL(browser(),
935 https_server_mismatched_.GetURL("files/ssl/google.html")); 934 https_server_mismatched_.GetURL("files/ssl/google.html"));
936 935
937 // We get an interstitial page as a result. 936 // We get an interstitial page as a result.
938 WebContents* tab = browser()->GetSelectedWebContents(); 937 WebContents* tab = browser()->GetActiveWebContents();
939 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 938 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
940 false, true); // Interstitial showing. 939 false, true); // Interstitial showing.
941 ProceedThroughInterstitial(tab); 940 ProceedThroughInterstitial(tab);
942 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 941 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
943 false, false); // No interstitial showing. 942 false, false); // No interstitial showing.
944 943
945 // Now we try again with the right host name this time. 944 // Now we try again with the right host name this time.
946 GURL url(https_server_.GetURL("files/ssl/google.html")); 945 GURL url(https_server_.GetURL("files/ssl/google.html"));
947 ui_test_utils::NavigateToURL(browser(), url); 946 ui_test_utils::NavigateToURL(browser(), url);
948 947
(...skipping 17 matching lines...) Expand all
966 #define MAYBE_TestRefNavigation TestRefNavigation 965 #define MAYBE_TestRefNavigation TestRefNavigation
967 #endif 966 #endif
968 967
969 // Test that navigating to a #ref does not change a bad security state. 968 // Test that navigating to a #ref does not change a bad security state.
970 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) { 969 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) {
971 ASSERT_TRUE(https_server_expired_.Start()); 970 ASSERT_TRUE(https_server_expired_.Start());
972 971
973 ui_test_utils::NavigateToURL(browser(), 972 ui_test_utils::NavigateToURL(browser(),
974 https_server_expired_.GetURL("files/ssl/page_with_refs.html")); 973 https_server_expired_.GetURL("files/ssl/page_with_refs.html"));
975 974
976 WebContents* tab = browser()->GetSelectedWebContents(); 975 WebContents* tab = browser()->GetActiveWebContents();
977 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 976 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
978 true); // Interstitial showing. 977 true); // Interstitial showing.
979 978
980 ProceedThroughInterstitial(tab); 979 ProceedThroughInterstitial(tab);
981 980
982 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 981 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
983 false); // No interstitial showing. 982 false); // No interstitial showing.
984 983
985 // Now navigate to a ref in the page, the security state should not have 984 // Now navigate to a ref in the page, the security state should not have
986 // changed. 985 // changed.
(...skipping 14 matching lines...) Expand all
1001 1000
1002 std::string replacement_path; 1001 std::string replacement_path;
1003 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 1002 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
1004 "files/ssl/page_with_unsafe_popup.html", 1003 "files/ssl/page_with_unsafe_popup.html",
1005 https_server_expired_.host_port_pair(), 1004 https_server_expired_.host_port_pair(),
1006 &replacement_path)); 1005 &replacement_path));
1007 1006
1008 ui_test_utils::NavigateToURL(browser(), 1007 ui_test_utils::NavigateToURL(browser(),
1009 test_server()->GetURL(replacement_path)); 1008 test_server()->GetURL(replacement_path));
1010 1009
1011 WebContents* tab1 = browser()->GetSelectedWebContents(); 1010 WebContents* tab1 = browser()->GetActiveWebContents();
1012 // It is probably overkill to add a notification for a popup-opening, let's 1011 // It is probably overkill to add a notification for a popup-opening, let's
1013 // just poll. 1012 // just poll.
1014 for (int i = 0; i < 10; i++) { 1013 for (int i = 0; i < 10; i++) {
1015 if (GetConstrainedWindowCount() > 0) 1014 if (GetConstrainedWindowCount() > 0)
1016 break; 1015 break;
1017 MessageLoop::current()->PostDelayedTask( 1016 MessageLoop::current()->PostDelayedTask(
1018 FROM_HERE, MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1)); 1017 FROM_HERE, MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1));
1019 ui_test_utils::RunMessageLoop(); 1018 ui_test_utils::RunMessageLoop();
1020 } 1019 }
1021 ASSERT_EQ(1, GetConstrainedWindowCount()); 1020 ASSERT_EQ(1, GetConstrainedWindowCount());
(...skipping 14 matching lines...) Expand all
1036 // Visit a page over bad https that is a redirect to a page with good https. 1035 // Visit a page over bad https that is a redirect to a page with good https.
1037 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectBadToGoodHTTPS) { 1036 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectBadToGoodHTTPS) {
1038 ASSERT_TRUE(https_server_.Start()); 1037 ASSERT_TRUE(https_server_.Start());
1039 ASSERT_TRUE(https_server_expired_.Start()); 1038 ASSERT_TRUE(https_server_expired_.Start());
1040 1039
1041 GURL url1 = https_server_expired_.GetURL("server-redirect?"); 1040 GURL url1 = https_server_expired_.GetURL("server-redirect?");
1042 GURL url2 = https_server_.GetURL("files/ssl/google.html"); 1041 GURL url2 = https_server_.GetURL("files/ssl/google.html");
1043 1042
1044 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); 1043 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec()));
1045 1044
1046 WebContents* tab = browser()->GetSelectedWebContents(); 1045 WebContents* tab = browser()->GetActiveWebContents();
1047 1046
1048 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1047 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1049 true); // Interstitial showing. 1048 true); // Interstitial showing.
1050 1049
1051 ProceedThroughInterstitial(tab); 1050 ProceedThroughInterstitial(tab);
1052 1051
1053 // We have been redirected to the good page. 1052 // We have been redirected to the good page.
1054 CheckAuthenticatedState(tab, false); 1053 CheckAuthenticatedState(tab, false);
1055 } 1054 }
1056 1055
1057 // Visit a page over good https that is a redirect to a page with bad https. 1056 // Visit a page over good https that is a redirect to a page with bad https.
1058 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectGoodToBadHTTPS) { 1057 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectGoodToBadHTTPS) {
1059 ASSERT_TRUE(https_server_.Start()); 1058 ASSERT_TRUE(https_server_.Start());
1060 ASSERT_TRUE(https_server_expired_.Start()); 1059 ASSERT_TRUE(https_server_expired_.Start());
1061 1060
1062 GURL url1 = https_server_.GetURL("server-redirect?"); 1061 GURL url1 = https_server_.GetURL("server-redirect?");
1063 GURL url2 = https_server_expired_.GetURL("files/ssl/google.html"); 1062 GURL url2 = https_server_expired_.GetURL("files/ssl/google.html");
1064 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); 1063 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec()));
1065 1064
1066 WebContents* tab = browser()->GetSelectedWebContents(); 1065 WebContents* tab = browser()->GetActiveWebContents();
1067 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1066 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1068 true); // Interstitial showing. 1067 true); // Interstitial showing.
1069 1068
1070 ProceedThroughInterstitial(tab); 1069 ProceedThroughInterstitial(tab);
1071 1070
1072 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1071 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1073 false); // No interstitial showing. 1072 false); // No interstitial showing.
1074 } 1073 }
1075 1074
1076 // Visit a page over http that is a redirect to a page with good HTTPS. 1075 // Visit a page over http that is a redirect to a page with good HTTPS.
1077 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToGoodHTTPS) { 1076 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToGoodHTTPS) {
1078 ASSERT_TRUE(test_server()->Start()); 1077 ASSERT_TRUE(test_server()->Start());
1079 ASSERT_TRUE(https_server_.Start()); 1078 ASSERT_TRUE(https_server_.Start());
1080 1079
1081 WebContents* tab = browser()->GetSelectedWebContents(); 1080 WebContents* tab = browser()->GetActiveWebContents();
1082 1081
1083 // HTTP redirects to good HTTPS. 1082 // HTTP redirects to good HTTPS.
1084 GURL http_url = test_server()->GetURL("server-redirect?"); 1083 GURL http_url = test_server()->GetURL("server-redirect?");
1085 GURL good_https_url = 1084 GURL good_https_url =
1086 https_server_.GetURL("files/ssl/google.html"); 1085 https_server_.GetURL("files/ssl/google.html");
1087 1086
1088 ui_test_utils::NavigateToURL(browser(), 1087 ui_test_utils::NavigateToURL(browser(),
1089 GURL(http_url.spec() + good_https_url.spec())); 1088 GURL(http_url.spec() + good_https_url.spec()));
1090 CheckAuthenticatedState(tab, false); 1089 CheckAuthenticatedState(tab, false);
1091 } 1090 }
1092 1091
1093 // Visit a page over http that is a redirect to a page with bad HTTPS. 1092 // Visit a page over http that is a redirect to a page with bad HTTPS.
1094 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToBadHTTPS) { 1093 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToBadHTTPS) {
1095 ASSERT_TRUE(test_server()->Start()); 1094 ASSERT_TRUE(test_server()->Start());
1096 ASSERT_TRUE(https_server_expired_.Start()); 1095 ASSERT_TRUE(https_server_expired_.Start());
1097 1096
1098 WebContents* tab = browser()->GetSelectedWebContents(); 1097 WebContents* tab = browser()->GetActiveWebContents();
1099 1098
1100 GURL http_url = test_server()->GetURL("server-redirect?"); 1099 GURL http_url = test_server()->GetURL("server-redirect?");
1101 GURL bad_https_url = 1100 GURL bad_https_url =
1102 https_server_expired_.GetURL("files/ssl/google.html"); 1101 https_server_expired_.GetURL("files/ssl/google.html");
1103 ui_test_utils::NavigateToURL(browser(), 1102 ui_test_utils::NavigateToURL(browser(),
1104 GURL(http_url.spec() + bad_https_url.spec())); 1103 GURL(http_url.spec() + bad_https_url.spec()));
1105 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1104 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1106 true); // Interstitial showing. 1105 true); // Interstitial showing.
1107 1106
1108 ProceedThroughInterstitial(tab); 1107 ProceedThroughInterstitial(tab);
1109 1108
1110 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1109 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1111 false); // No interstitial showing. 1110 false); // No interstitial showing.
1112 } 1111 }
1113 1112
1114 // Visit a page over https that is a redirect to a page with http (to make sure 1113 // Visit a page over https that is a redirect to a page with http (to make sure
1115 // we don't keep the secure state). 1114 // we don't keep the secure state).
1116 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) { 1115 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) {
1117 ASSERT_TRUE(test_server()->Start()); 1116 ASSERT_TRUE(test_server()->Start());
1118 ASSERT_TRUE(https_server_.Start()); 1117 ASSERT_TRUE(https_server_.Start());
1119 1118
1120 GURL https_url = https_server_.GetURL("server-redirect?"); 1119 GURL https_url = https_server_.GetURL("server-redirect?");
1121 GURL http_url = test_server()->GetURL("files/ssl/google.html"); 1120 GURL http_url = test_server()->GetURL("files/ssl/google.html");
1122 1121
1123 ui_test_utils::NavigateToURL(browser(), 1122 ui_test_utils::NavigateToURL(browser(),
1124 GURL(https_url.spec() + http_url.spec())); 1123 GURL(https_url.spec() + http_url.spec()));
1125 CheckUnauthenticatedState(browser()->GetSelectedWebContents()); 1124 CheckUnauthenticatedState(browser()->GetActiveWebContents());
1126 } 1125 }
1127 1126
1128 // Visits a page to which we could not connect (bad port) over http and https 1127 // Visits a page to which we could not connect (bad port) over http and https
1129 // and make sure the security style is correct. 1128 // and make sure the security style is correct.
1130 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { 1129 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) {
1131 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17")); 1130 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17"));
1132 CheckUnauthenticatedState(browser()->GetSelectedWebContents()); 1131 CheckUnauthenticatedState(browser()->GetActiveWebContents());
1133 1132
1134 // Same thing over HTTPS. 1133 // Same thing over HTTPS.
1135 ui_test_utils::NavigateToURL(browser(), GURL("https://localhost:17")); 1134 ui_test_utils::NavigateToURL(browser(), GURL("https://localhost:17"));
1136 CheckUnauthenticatedState(browser()->GetSelectedWebContents()); 1135 CheckUnauthenticatedState(browser()->GetActiveWebContents());
1137 } 1136 }
1138 1137
1139 // 1138 //
1140 // Frame navigation 1139 // Frame navigation
1141 // 1140 //
1142 1141
1143 // From a good HTTPS top frame: 1142 // From a good HTTPS top frame:
1144 // - navigate to an OK HTTPS frame 1143 // - navigate to an OK HTTPS frame
1145 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then 1144 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then
1146 // back 1145 // back
1147 // - navigate to HTTP (expect insecure content), then back 1146 // - navigate to HTTP (expect insecure content), then back
1148 IN_PROC_BROWSER_TEST_F(SSLUITest, TestGoodFrameNavigation) { 1147 IN_PROC_BROWSER_TEST_F(SSLUITest, TestGoodFrameNavigation) {
1149 ASSERT_TRUE(test_server()->Start()); 1148 ASSERT_TRUE(test_server()->Start());
1150 ASSERT_TRUE(https_server_.Start()); 1149 ASSERT_TRUE(https_server_.Start());
1151 ASSERT_TRUE(https_server_expired_.Start()); 1150 ASSERT_TRUE(https_server_expired_.Start());
1152 1151
1153 std::string top_frame_path; 1152 std::string top_frame_path;
1154 ASSERT_TRUE(GetTopFramePath(*test_server(), 1153 ASSERT_TRUE(GetTopFramePath(*test_server(),
1155 https_server_, 1154 https_server_,
1156 https_server_expired_, 1155 https_server_expired_,
1157 &top_frame_path)); 1156 &top_frame_path));
1158 1157
1159 WebContents* tab = browser()->GetSelectedWebContents(); 1158 WebContents* tab = browser()->GetActiveWebContents();
1160 ui_test_utils::NavigateToURL(browser(), 1159 ui_test_utils::NavigateToURL(browser(),
1161 https_server_.GetURL(top_frame_path)); 1160 https_server_.GetURL(top_frame_path));
1162 1161
1163 CheckAuthenticatedState(tab, false); 1162 CheckAuthenticatedState(tab, false);
1164 1163
1165 bool success = false; 1164 bool success = false;
1166 // Now navigate inside the frame. 1165 // Now navigate inside the frame.
1167 { 1166 {
1168 ui_test_utils::WindowedNotificationObserver observer( 1167 ui_test_utils::WindowedNotificationObserver observer(
1169 content::NOTIFICATION_LOAD_STOP, 1168 content::NOTIFICATION_LOAD_STOP,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadFrameNavigation) { 1246 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadFrameNavigation) {
1248 ASSERT_TRUE(https_server_.Start()); 1247 ASSERT_TRUE(https_server_.Start());
1249 ASSERT_TRUE(https_server_expired_.Start()); 1248 ASSERT_TRUE(https_server_expired_.Start());
1250 1249
1251 std::string top_frame_path; 1250 std::string top_frame_path;
1252 ASSERT_TRUE(GetTopFramePath(*test_server(), 1251 ASSERT_TRUE(GetTopFramePath(*test_server(),
1253 https_server_, 1252 https_server_,
1254 https_server_expired_, 1253 https_server_expired_,
1255 &top_frame_path)); 1254 &top_frame_path));
1256 1255
1257 WebContents* tab = browser()->GetSelectedWebContents(); 1256 WebContents* tab = browser()->GetActiveWebContents();
1258 ui_test_utils::NavigateToURL(browser(), 1257 ui_test_utils::NavigateToURL(browser(),
1259 https_server_expired_.GetURL(top_frame_path)); 1258 https_server_expired_.GetURL(top_frame_path));
1260 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1259 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1261 true); // Interstitial showing 1260 true); // Interstitial showing
1262 1261
1263 ProceedThroughInterstitial(tab); 1262 ProceedThroughInterstitial(tab);
1264 1263
1265 // Navigate to a good frame. 1264 // Navigate to a good frame.
1266 bool success = false; 1265 bool success = false;
1267 ui_test_utils::WindowedNotificationObserver observer( 1266 ui_test_utils::WindowedNotificationObserver observer(
(...skipping 18 matching lines...) Expand all
1286 ASSERT_TRUE(test_server()->Start()); 1285 ASSERT_TRUE(test_server()->Start());
1287 ASSERT_TRUE(https_server_.Start()); 1286 ASSERT_TRUE(https_server_.Start());
1288 ASSERT_TRUE(https_server_expired_.Start()); 1287 ASSERT_TRUE(https_server_expired_.Start());
1289 1288
1290 std::string top_frame_path; 1289 std::string top_frame_path;
1291 ASSERT_TRUE(GetTopFramePath(*test_server(), 1290 ASSERT_TRUE(GetTopFramePath(*test_server(),
1292 https_server_, 1291 https_server_,
1293 https_server_expired_, 1292 https_server_expired_,
1294 &top_frame_path)); 1293 &top_frame_path));
1295 1294
1296 WebContents* tab = browser()->GetSelectedWebContents(); 1295 WebContents* tab = browser()->GetActiveWebContents();
1297 ui_test_utils::NavigateToURL(browser(), 1296 ui_test_utils::NavigateToURL(browser(),
1298 test_server()->GetURL(top_frame_path)); 1297 test_server()->GetURL(top_frame_path));
1299 CheckUnauthenticatedState(tab); 1298 CheckUnauthenticatedState(tab);
1300 1299
1301 // Now navigate inside the frame to a secure HTTPS frame. 1300 // Now navigate inside the frame to a secure HTTPS frame.
1302 { 1301 {
1303 bool success = false; 1302 bool success = false;
1304 ui_test_utils::WindowedNotificationObserver observer( 1303 ui_test_utils::WindowedNotificationObserver observer(
1305 content::NOTIFICATION_LOAD_STOP, 1304 content::NOTIFICATION_LOAD_STOP,
1306 content::Source<NavigationController>(&tab->GetController())); 1305 content::Source<NavigationController>(&tab->GetController()));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 ASSERT_TRUE(https_server_.Start()); 1346 ASSERT_TRUE(https_server_.Start());
1348 ASSERT_TRUE(https_server_expired_.Start()); 1347 ASSERT_TRUE(https_server_expired_.Start());
1349 1348
1350 // This page will spawn a Worker which will try to load content from 1349 // This page will spawn a Worker which will try to load content from
1351 // BadCertServer. 1350 // BadCertServer.
1352 std::string page_with_unsafe_worker_path; 1351 std::string page_with_unsafe_worker_path;
1353 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_expired_, 1352 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_expired_,
1354 &page_with_unsafe_worker_path)); 1353 &page_with_unsafe_worker_path));
1355 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( 1354 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL(
1356 page_with_unsafe_worker_path)); 1355 page_with_unsafe_worker_path));
1357 WebContents* tab = browser()->GetSelectedWebContents(); 1356 WebContents* tab = browser()->GetActiveWebContents();
1358 // Expect Worker not to load insecure content. 1357 // Expect Worker not to load insecure content.
1359 CheckWorkerLoadResult(tab, false); 1358 CheckWorkerLoadResult(tab, false);
1360 // The bad content is filtered, expect the state to be authenticated. 1359 // The bad content is filtered, expect the state to be authenticated.
1361 CheckAuthenticatedState(tab, false); 1360 CheckAuthenticatedState(tab, false);
1362 } 1361 }
1363 1362
1364 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorker) { 1363 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorker) {
1365 ASSERT_TRUE(https_server_.Start()); 1364 ASSERT_TRUE(https_server_.Start());
1366 ASSERT_TRUE(https_server_expired_.Start()); 1365 ASSERT_TRUE(https_server_expired_.Start());
1367 1366
1368 // Navigate to an unsafe site. Proceed with interstitial page to indicate 1367 // Navigate to an unsafe site. Proceed with interstitial page to indicate
1369 // the user approves the bad certificate. 1368 // the user approves the bad certificate.
1370 ui_test_utils::NavigateToURL(browser(), 1369 ui_test_utils::NavigateToURL(browser(),
1371 https_server_expired_.GetURL("files/ssl/blank_page.html")); 1370 https_server_expired_.GetURL("files/ssl/blank_page.html"));
1372 WebContents* tab = browser()->GetSelectedWebContents(); 1371 WebContents* tab = browser()->GetActiveWebContents();
1373 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1372 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1374 true); // Interstitial showing 1373 true); // Interstitial showing
1375 ProceedThroughInterstitial(tab); 1374 ProceedThroughInterstitial(tab);
1376 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1375 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1377 false); // No Interstitial 1376 false); // No Interstitial
1378 1377
1379 // Navigate to safe page that has Worker loading unsafe content. 1378 // Navigate to safe page that has Worker loading unsafe content.
1380 // Expect content to load but be marked as auth broken due to running insecure 1379 // Expect content to load but be marked as auth broken due to running insecure
1381 // content. 1380 // content.
1382 std::string page_with_unsafe_worker_path; 1381 std::string page_with_unsafe_worker_path;
(...skipping 14 matching lines...) Expand all
1397 1396
1398 std::string replacement_path; 1397 std::string replacement_path;
1399 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 1398 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
1400 "files/ssl/page_displays_insecure_content.html", 1399 "files/ssl/page_displays_insecure_content.html",
1401 test_server()->host_port_pair(), 1400 test_server()->host_port_pair(),
1402 &replacement_path)); 1401 &replacement_path));
1403 1402
1404 ui_test_utils::NavigateToURL(browser(), 1403 ui_test_utils::NavigateToURL(browser(),
1405 https_server_.GetURL(replacement_path)); 1404 https_server_.GetURL(replacement_path));
1406 1405
1407 CheckAuthenticatedState(browser()->GetSelectedWebContents(), false); 1406 CheckAuthenticatedState(browser()->GetActiveWebContents(), false);
1408 } 1407 }
1409 1408
1410 // Test that when the browser blocks displaying insecure content (iframes), the 1409 // Test that when the browser blocks displaying insecure content (iframes), the
1411 // indicator shows a secure page, because the blocking made the otherwise 1410 // indicator shows a secure page, because the blocking made the otherwise
1412 // unsafe page safe (the notification of this state is handled by other means) 1411 // unsafe page safe (the notification of this state is handled by other means)
1413 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureIframe) { 1412 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureIframe) {
1414 ASSERT_TRUE(test_server()->Start()); 1413 ASSERT_TRUE(test_server()->Start());
1415 ASSERT_TRUE(https_server_.Start()); 1414 ASSERT_TRUE(https_server_.Start());
1416 1415
1417 std::string replacement_path; 1416 std::string replacement_path;
1418 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 1417 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
1419 "files/ssl/page_displays_insecure_iframe.html", 1418 "files/ssl/page_displays_insecure_iframe.html",
1420 test_server()->host_port_pair(), 1419 test_server()->host_port_pair(),
1421 &replacement_path)); 1420 &replacement_path));
1422 1421
1423 ui_test_utils::NavigateToURL(browser(), 1422 ui_test_utils::NavigateToURL(browser(),
1424 https_server_.GetURL(replacement_path)); 1423 https_server_.GetURL(replacement_path));
1425 1424
1426 CheckAuthenticatedState(browser()->GetSelectedWebContents(), false); 1425 CheckAuthenticatedState(browser()->GetActiveWebContents(), false);
1427 } 1426 }
1428 1427
1429 1428
1430 // Test that when the browser blocks running insecure content, the 1429 // Test that when the browser blocks running insecure content, the
1431 // indicator shows a secure page, because the blocking made the otherwise 1430 // indicator shows a secure page, because the blocking made the otherwise
1432 // unsafe page safe (the notification of this state is handled by other means). 1431 // unsafe page safe (the notification of this state is handled by other means).
1433 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockRunningInsecureContent) { 1432 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockRunningInsecureContent) {
1434 ASSERT_TRUE(test_server()->Start()); 1433 ASSERT_TRUE(test_server()->Start());
1435 ASSERT_TRUE(https_server_.Start()); 1434 ASSERT_TRUE(https_server_.Start());
1436 1435
1437 std::string replacement_path; 1436 std::string replacement_path;
1438 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 1437 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
1439 "files/ssl/page_runs_insecure_content.html", 1438 "files/ssl/page_runs_insecure_content.html",
1440 test_server()->host_port_pair(), 1439 test_server()->host_port_pair(),
1441 &replacement_path)); 1440 &replacement_path));
1442 1441
1443 ui_test_utils::NavigateToURL(browser(), 1442 ui_test_utils::NavigateToURL(browser(),
1444 https_server_.GetURL(replacement_path)); 1443 https_server_.GetURL(replacement_path));
1445 1444
1446 CheckAuthenticatedState(browser()->GetSelectedWebContents(), false); 1445 CheckAuthenticatedState(browser()->GetActiveWebContents(), false);
1447 } 1446 }
1448 1447
1449 1448
1450 // TODO(jcampan): more tests to do below. 1449 // TODO(jcampan): more tests to do below.
1451 1450
1452 // Visit a page over https that contains a frame with a redirect. 1451 // Visit a page over https that contains a frame with a redirect.
1453 1452
1454 // XMLHttpRequest insecure content in synchronous mode. 1453 // XMLHttpRequest insecure content in synchronous mode.
1455 1454
1456 // XMLHttpRequest insecure content in asynchronous mode. 1455 // XMLHttpRequest insecure content in asynchronous mode.
1457 1456
1458 // XMLHttpRequest over bad ssl in synchronous mode. 1457 // XMLHttpRequest over bad ssl in synchronous mode.
1459 1458
1460 // XMLHttpRequest over OK ssl in synchronous mode. 1459 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_add_cert_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698