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

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

Issue 7880003: content: Move constrained window code from TabContents to TabContentsWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix views merge part 2 Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/time.h" 6 #include "base/time.h"
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/tabs/tab_strip_model.h" 8 #include "chrome/browser/tabs/tab_strip_model.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
11 #include "chrome/browser/ui/constrained_window_tab_helper.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
17 #include "content/browser/tab_contents/interstitial_page.h" 18 #include "content/browser/tab_contents/interstitial_page.h"
18 #include "content/browser/tab_contents/navigation_entry.h" 19 #include "content/browser/tab_contents/navigation_entry.h"
19 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
20 #include "content/common/notification_service.h" 21 #include "content/common/notification_service.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void ProceedThroughInterstitial(TabContents* tab) { 119 void ProceedThroughInterstitial(TabContents* tab) {
119 InterstitialPage* interstitial_page = tab->interstitial_page(); 120 InterstitialPage* interstitial_page = tab->interstitial_page();
120 ASSERT_TRUE(interstitial_page); 121 ASSERT_TRUE(interstitial_page);
121 ui_test_utils::WindowedNotificationObserver observer( 122 ui_test_utils::WindowedNotificationObserver observer(
122 content::NOTIFICATION_LOAD_STOP, 123 content::NOTIFICATION_LOAD_STOP,
123 Source<NavigationController>(&tab->controller())); 124 Source<NavigationController>(&tab->controller()));
124 interstitial_page->Proceed(); 125 interstitial_page->Proceed();
125 observer.Wait(); 126 observer.Wait();
126 } 127 }
127 128
129 int GetConstrainedWindowCount() const {
130 return static_cast<int>(
131 browser()->GetSelectedTabContentsWrapper()->
132 constrained_window_tab_helper()->constrained_window_count());
133 }
134
128 static bool GetFilePathWithHostAndPortReplacement( 135 static bool GetFilePathWithHostAndPortReplacement(
129 const std::string& original_file_path, 136 const std::string& original_file_path,
130 const net::HostPortPair& host_port_pair, 137 const net::HostPortPair& host_port_pair,
131 std::string* replacement_path) { 138 std::string* replacement_path) {
132 std::vector<net::TestServer::StringPair> replacement_text; 139 std::vector<net::TestServer::StringPair> replacement_text;
133 replacement_text.push_back( 140 replacement_text.push_back(
134 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); 141 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString()));
135 return net::TestServer::GetFilePathWithReplacements( 142 return net::TestServer::GetFilePathWithReplacements(
136 original_file_path, replacement_text, replacement_path); 143 original_file_path, replacement_text, replacement_path);
137 } 144 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 TabContents* tab = browser()->GetSelectedTabContents(); 586 TabContents* tab = browser()->GetSelectedTabContents();
580 // When the bad content is filtered, the state is expected to be 587 // When the bad content is filtered, the state is expected to be
581 // authenticated. 588 // authenticated.
582 CheckAuthenticatedState(tab, false); 589 CheckAuthenticatedState(tab, false);
583 590
584 // Because of cross-frame scripting restrictions, we cannot access the iframe 591 // Because of cross-frame scripting restrictions, we cannot access the iframe
585 // content. So to know if the frame was loaded, we just check if a popup was 592 // content. So to know if the frame was loaded, we just check if a popup was
586 // opened (the iframe content opens one). 593 // opened (the iframe content opens one).
587 // Note: because of bug 1115868, no constrained window is opened right now. 594 // Note: because of bug 1115868, no constrained window is opened right now.
588 // Once the bug is fixed, this will do the real check. 595 // Once the bug is fixed, this will do the real check.
589 EXPECT_EQ(0, static_cast<int>(tab->constrained_window_count())); 596 EXPECT_EQ(0, GetConstrainedWindowCount());
590 597
591 int img_width; 598 int img_width;
592 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( 599 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt(
593 tab->render_view_host(), std::wstring(), 600 tab->render_view_host(), std::wstring(),
594 L"window.domAutomationController.send(ImageWidth());", &img_width)); 601 L"window.domAutomationController.send(ImageWidth());", &img_width));
595 // In order to check that the image was not loaded, we check its width. 602 // In order to check that the image was not loaded, we check its width.
596 // The actual image (Google logo) is 114 pixels wide, we assume the broken 603 // The actual image (Google logo) is 114 pixels wide, we assume the broken
597 // image is less than 100. 604 // image is less than 100.
598 EXPECT_LT(img_width, 100); 605 EXPECT_LT(img_width, 100);
599 606
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 https_server_expired_.host_port_pair(), 861 https_server_expired_.host_port_pair(),
855 &replacement_path)); 862 &replacement_path));
856 863
857 ui_test_utils::NavigateToURL(browser(), 864 ui_test_utils::NavigateToURL(browser(),
858 test_server()->GetURL(replacement_path)); 865 test_server()->GetURL(replacement_path));
859 866
860 TabContents* tab1 = browser()->GetSelectedTabContents(); 867 TabContents* tab1 = browser()->GetSelectedTabContents();
861 // It is probably overkill to add a notification for a popup-opening, let's 868 // It is probably overkill to add a notification for a popup-opening, let's
862 // just poll. 869 // just poll.
863 for (int i = 0; i < 10; i++) { 870 for (int i = 0; i < 10; i++) {
864 if (static_cast<int>(tab1->constrained_window_count()) > 0) 871 if (GetConstrainedWindowCount() > 0)
865 break; 872 break;
866 MessageLoop::current()->PostDelayedTask(FROM_HERE, 873 MessageLoop::current()->PostDelayedTask(FROM_HERE,
867 new MessageLoop::QuitTask(), 1000); 874 new MessageLoop::QuitTask(), 1000);
868 ui_test_utils::RunMessageLoop(); 875 ui_test_utils::RunMessageLoop();
869 } 876 }
870 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); 877 ASSERT_EQ(1, GetConstrainedWindowCount());
871 878
872 // Let's add another tab to make sure the browser does not exit when we close 879 // Let's add another tab to make sure the browser does not exit when we close
873 // the first tab. 880 // the first tab.
874 GURL url = test_server()->GetURL("files/ssl/google.html"); 881 GURL url = test_server()->GetURL("files/ssl/google.html");
875 ui_test_utils::WindowedNotificationObserver observer( 882 ui_test_utils::WindowedNotificationObserver observer(
876 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); 883 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
877 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); 884 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
878 observer.Wait(); 885 observer.Wait();
879 886
880 // Close the first tab. 887 // Close the first tab.
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1295
1289 // Visit a page over https that contains a frame with a redirect. 1296 // Visit a page over https that contains a frame with a redirect.
1290 1297
1291 // XMLHttpRequest insecure content in synchronous mode. 1298 // XMLHttpRequest insecure content in synchronous mode.
1292 1299
1293 // XMLHttpRequest insecure content in asynchronous mode. 1300 // XMLHttpRequest insecure content in asynchronous mode.
1294 1301
1295 // XMLHttpRequest over bad ssl in synchronous mode. 1302 // XMLHttpRequest over bad ssl in synchronous mode.
1296 1303
1297 // XMLHttpRequest over OK ssl in synchronous mode. 1304 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698