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

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

Issue 115896: Making the browser tests work on Unix (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/browser.h" 5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/profile.h" 6 #include "chrome/browser/profile.h"
7 #include "chrome/browser/tab_contents/interstitial_page.h" 7 #include "chrome/browser/tab_contents/interstitial_page.h"
8 #include "chrome/browser/tab_contents/navigation_entry.h" 8 #include "chrome/browser/tab_contents/navigation_entry.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 entry->ssl().security_style()); 66 entry->ssl().security_style());
67 EXPECT_EQ(error, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); 67 EXPECT_EQ(error, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS);
68 EXPECT_FALSE(entry->ssl().has_mixed_content()); 68 EXPECT_FALSE(entry->ssl().has_mixed_content());
69 EXPECT_FALSE(entry->ssl().has_unsafe_content()); 69 EXPECT_FALSE(entry->ssl().has_unsafe_content());
70 } 70 }
71 71
72 private: 72 private:
73 DISALLOW_COPY_AND_ASSIGN(SSLUITest); 73 DISALLOW_COPY_AND_ASSIGN(SSLUITest);
74 }; 74 };
75 75
76 #if defined(OS_WIN)
76 // Visits a regular page over http. 77 // Visits a regular page over http.
77 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { 78 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) {
78 scoped_refptr<HTTPTestServer> server = PlainServer(); 79 scoped_refptr<HTTPTestServer> server = PlainServer();
79 80
80 ui_test_utils::NavigateToURL(browser(), 81 ui_test_utils::NavigateToURL(browser(),
81 server->TestServerPageW(L"files/ssl/google.html")); 82 server->TestServerPageW(L"files/ssl/google.html"));
82 83
83 CheckUnauthenticatedState(browser()->GetSelectedTabContents()); 84 CheckUnauthenticatedState(browser()->GetSelectedTabContents());
84 } 85 }
85 86
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 TabContents* tab = browser()->GetSelectedTabContents(); 274 TabContents* tab = browser()->GetSelectedTabContents();
274 // When the bad content is filtered, the state is expected to be 275 // When the bad content is filtered, the state is expected to be
275 // authenticated. 276 // authenticated.
276 CheckAuthenticatedState(tab, false, false); 277 CheckAuthenticatedState(tab, false, false);
277 278
278 // Because of cross-frame scripting restrictions, we cannot access the iframe 279 // Because of cross-frame scripting restrictions, we cannot access the iframe
279 // content. So to know if the frame was loaded, we just check if a popup was 280 // content. So to know if the frame was loaded, we just check if a popup was
280 // opened (the iframe content opens one). 281 // opened (the iframe content opens one).
281 // Note: because of bug 1115868, no constrained window is opened right now. 282 // Note: because of bug 1115868, no constrained window is opened right now.
282 // Once the bug is fixed, this will do the real check. 283 // Once the bug is fixed, this will do the real check.
283 EXPECT_EQ(0, tab->constrained_window_count()); 284 EXPECT_EQ(0, static_cast<int>(tab->constrained_window_count()));
284 285
285 int img_width; 286 int img_width;
286 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( 287 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt(
287 tab, L"", L"window.domAutomationController.send(ImageWidth());", 288 tab, L"", L"window.domAutomationController.send(ImageWidth());",
288 &img_width)); 289 &img_width));
289 // In order to check that the image was not loaded, we check its width. 290 // In order to check that the image was not loaded, we check its width.
290 // The actual image (Google logo) is 114 pixels wide, we assume the broken 291 // The actual image (Google logo) is 114 pixels wide, we assume the broken
291 // image is less than 100. 292 // image is less than 100.
292 EXPECT_GT(100, img_width); 293 EXPECT_GT(100, img_width);
293 294
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 scoped_refptr<HTTPTestServer> http_server = PlainServer(); 459 scoped_refptr<HTTPTestServer> http_server = PlainServer();
459 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); 460 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer();
460 461
461 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW( 462 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
462 L"files/ssl/page_with_unsafe_popup.html")); 463 L"files/ssl/page_with_unsafe_popup.html"));
463 464
464 TabContents* tab1 = browser()->GetSelectedTabContents(); 465 TabContents* tab1 = browser()->GetSelectedTabContents();
465 // It is probably overkill to add a notification for a popup-opening, let's 466 // It is probably overkill to add a notification for a popup-opening, let's
466 // just poll. 467 // just poll.
467 for (int i = 0; i < 10; i++) { 468 for (int i = 0; i < 10; i++) {
468 if (tab1->constrained_window_count() > 0) 469 if (static_cast<int>(tab1->constrained_window_count()) > 0)
469 break; 470 break;
470 MessageLoop::current()->PostDelayedTask(FROM_HERE, 471 MessageLoop::current()->PostDelayedTask(FROM_HERE,
471 new MessageLoop::QuitTask(), 1000); 472 new MessageLoop::QuitTask(), 1000);
472 ui_test_utils::RunMessageLoop(); 473 ui_test_utils::RunMessageLoop();
473 } 474 }
474 ASSERT_EQ(1, tab1->constrained_window_count()); 475 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count()));
475 476
476 // Let's add another tab to make sure the browser does not exit when we close 477 // Let's add another tab to make sure the browser does not exit when we close
477 // the first tab. 478 // the first tab.
478 GURL url = http_server->TestServerPageW(L"files/ssl/google.html"); 479 GURL url = http_server->TestServerPageW(L"files/ssl/google.html");
479 TabContents* tab2 = browser()->AddTabWithURL(url, 480 TabContents* tab2 = browser()->AddTabWithURL(url,
480 GURL(), 481 GURL(),
481 PageTransition::TYPED, 482 PageTransition::TYPED,
482 true, 0, false, NULL); 483 true, 0, false, NULL);
483 ui_test_utils::WaitForNavigation(&(tab2->controller())); 484 ui_test_utils::WaitForNavigation(&(tab2->controller()));
484 485
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 ui_test_utils::NavigateToURL( 693 ui_test_utils::NavigateToURL(
693 browser(), 694 browser(),
694 bad_https_server->TestServerPageW(L"files/ssl/top_frame.html")); 695 bad_https_server->TestServerPageW(L"files/ssl/top_frame.html"));
695 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, 696 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID,
696 true); // Interstitial showing 697 true); // Interstitial showing
697 698
698 // Continue on the interstitial. 699 // Continue on the interstitial.
699 InterstitialPage* interstitial_page = tab->interstitial_page(); 700 InterstitialPage* interstitial_page = tab->interstitial_page();
700 ASSERT_TRUE(interstitial_page); 701 ASSERT_TRUE(interstitial_page);
701 interstitial_page->Proceed(); 702 interstitial_page->Proceed();
702 // Wait for the navigation to be done.
703 ui_test_utils::WaitForNavigation(&(tab->controller())); 703 ui_test_utils::WaitForNavigation(&(tab->controller()));
704 704
705 // Navigate to a good frame. 705 // Navigate to a good frame.
706 bool success = false; 706 bool success = false;
707 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(tab, 707 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(tab,
708 L"", 708 L"",
709 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 709 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
710 &success)); 710 &success));
711 EXPECT_TRUE(success); 711 EXPECT_TRUE(success);
712 ui_test_utils::WaitForNavigation(&tab->controller()); 712 ui_test_utils::WaitForNavigation(&tab->controller());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 // And the frame should have been blocked (see bug #2316). 754 // And the frame should have been blocked (see bug #2316).
755 bool is_content_evil = true; 755 bool is_content_evil = true;
756 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); 756 std::wstring content_frame_xpath(L"html/frameset/frame[2]");
757 std::wstring is_frame_evil_js( 757 std::wstring is_frame_evil_js(
758 L"window.domAutomationController" 758 L"window.domAutomationController"
759 L".send(document.getElementById('evilDiv') != null);"); 759 L".send(document.getElementById('evilDiv') != null);");
760 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(tab, 760 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(tab,
761 content_frame_xpath, is_frame_evil_js, &is_content_evil)); 761 content_frame_xpath, is_frame_evil_js, &is_content_evil));
762 EXPECT_FALSE(is_content_evil); 762 EXPECT_FALSE(is_content_evil);
763 } 763 }
764 #else
765 // TODO(port): enable the real tests.
766 IN_PROC_BROWSER_TEST_F(SSLUITest, PhonyTest1) {
767 EXPECT_TRUE(true);
768 }
769
770 IN_PROC_BROWSER_TEST_F(SSLUITest, PhonyTest2) {
771 EXPECT_TRUE(false);
772 }
773
774 IN_PROC_BROWSER_TEST_F(SSLUITest, PhonyTest3) {
775 EXPECT_TRUE(true);
776 }
777 #endif
764 778
765 // TODO(jcampan): more tests to do below. 779 // TODO(jcampan): more tests to do below.
766 780
767 // Visit a page over https that contains a frame with a redirect. 781 // Visit a page over https that contains a frame with a redirect.
768 782
769 // XMLHttpRequest mixed in synchronous mode. 783 // XMLHttpRequest mixed in synchronous mode.
770 784
771 // XMLHttpRequest mixed in asynchronous mode. 785 // XMLHttpRequest mixed in asynchronous mode.
772 786
773 // XMLHttpRequest over bad ssl in synchronous mode. 787 // XMLHttpRequest over bad ssl in synchronous mode.
774 788
775 // XMLHttpRequest over OK ssl in synchronous mode. 789 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698