OLD | NEW |
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 Loading... |
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 TabContents* tab = browser()->GetSelectedTabContents(); | 583 TabContents* tab = browser()->GetSelectedTabContents(); |
577 // When the bad content is filtered, the state is expected to be | 584 // When the bad content is filtered, the state is expected to be |
578 // authenticated. | 585 // authenticated. |
579 CheckAuthenticatedState(tab, false); | 586 CheckAuthenticatedState(tab, false); |
580 | 587 |
581 // Because of cross-frame scripting restrictions, we cannot access the iframe | 588 // Because of cross-frame scripting restrictions, we cannot access the iframe |
582 // content. So to know if the frame was loaded, we just check if a popup was | 589 // content. So to know if the frame was loaded, we just check if a popup was |
583 // opened (the iframe content opens one). | 590 // opened (the iframe content opens one). |
584 // Note: because of bug 1115868, no constrained window is opened right now. | 591 // Note: because of bug 1115868, no constrained window is opened right now. |
585 // Once the bug is fixed, this will do the real check. | 592 // Once the bug is fixed, this will do the real check. |
586 EXPECT_EQ(0, static_cast<int>(tab->constrained_window_count())); | 593 EXPECT_EQ(0, GetConstrainedWindowCount()); |
587 | 594 |
588 int img_width; | 595 int img_width; |
589 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 596 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
590 tab->render_view_host(), std::wstring(), | 597 tab->render_view_host(), std::wstring(), |
591 L"window.domAutomationController.send(ImageWidth());", &img_width)); | 598 L"window.domAutomationController.send(ImageWidth());", &img_width)); |
592 // In order to check that the image was not loaded, we check its width. | 599 // In order to check that the image was not loaded, we check its width. |
593 // The actual image (Google logo) is 114 pixels wide, we assume the broken | 600 // The actual image (Google logo) is 114 pixels wide, we assume the broken |
594 // image is less than 100. | 601 // image is less than 100. |
595 EXPECT_LT(img_width, 100); | 602 EXPECT_LT(img_width, 100); |
596 | 603 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 https_server_expired_.host_port_pair(), | 858 https_server_expired_.host_port_pair(), |
852 &replacement_path)); | 859 &replacement_path)); |
853 | 860 |
854 ui_test_utils::NavigateToURL(browser(), | 861 ui_test_utils::NavigateToURL(browser(), |
855 test_server()->GetURL(replacement_path)); | 862 test_server()->GetURL(replacement_path)); |
856 | 863 |
857 TabContents* tab1 = browser()->GetSelectedTabContents(); | 864 TabContents* tab1 = browser()->GetSelectedTabContents(); |
858 // It is probably overkill to add a notification for a popup-opening, let's | 865 // It is probably overkill to add a notification for a popup-opening, let's |
859 // just poll. | 866 // just poll. |
860 for (int i = 0; i < 10; i++) { | 867 for (int i = 0; i < 10; i++) { |
861 if (static_cast<int>(tab1->constrained_window_count()) > 0) | 868 if (GetConstrainedWindowCount() > 0) |
862 break; | 869 break; |
863 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 870 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
864 new MessageLoop::QuitTask(), 1000); | 871 new MessageLoop::QuitTask(), 1000); |
865 ui_test_utils::RunMessageLoop(); | 872 ui_test_utils::RunMessageLoop(); |
866 } | 873 } |
867 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); | 874 ASSERT_EQ(1, GetConstrainedWindowCount()); |
868 | 875 |
869 // Let's add another tab to make sure the browser does not exit when we close | 876 // Let's add another tab to make sure the browser does not exit when we close |
870 // the first tab. | 877 // the first tab. |
871 GURL url = test_server()->GetURL("files/ssl/google.html"); | 878 GURL url = test_server()->GetURL("files/ssl/google.html"); |
872 ui_test_utils::WindowedNotificationObserver observer( | 879 ui_test_utils::WindowedNotificationObserver observer( |
873 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 880 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
874 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); | 881 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
875 observer.Wait(); | 882 observer.Wait(); |
876 | 883 |
877 // Close the first tab. | 884 // Close the first tab. |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 | 1292 |
1286 // Visit a page over https that contains a frame with a redirect. | 1293 // Visit a page over https that contains a frame with a redirect. |
1287 | 1294 |
1288 // XMLHttpRequest insecure content in synchronous mode. | 1295 // XMLHttpRequest insecure content in synchronous mode. |
1289 | 1296 |
1290 // XMLHttpRequest insecure content in asynchronous mode. | 1297 // XMLHttpRequest insecure content in asynchronous mode. |
1291 | 1298 |
1292 // XMLHttpRequest over bad ssl in synchronous mode. | 1299 // XMLHttpRequest over bad ssl in synchronous mode. |
1293 | 1300 |
1294 // XMLHttpRequest over OK ssl in synchronous mode. | 1301 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |