| OLD | NEW |
| 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url, | 119 bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url, |
| 120 string16* title) { | 120 string16* title) { |
| 121 ui_test_utils::NavigateToURL(browser(), url); | 121 ui_test_utils::NavigateToURL(browser(), url); |
| 122 | 122 |
| 123 ui_test_utils::WindowedTabAddedNotificationObserver observer( | 123 ui_test_utils::WindowedTabAddedNotificationObserver observer( |
| 124 content::NotificationService::AllSources()); | 124 content::NotificationService::AllSources()); |
| 125 | 125 |
| 126 // Create dynamic popup. | 126 // Create dynamic popup. |
| 127 if (!ui_test_utils::ExecuteJavaScript( | 127 if (!content::ExecuteJavaScript(render_view_host(), L"", L"OpenPopup();")) |
| 128 render_view_host(), L"", L"OpenPopup();")) | |
| 129 return false; | 128 return false; |
| 130 | 129 |
| 131 observer.Wait(); | 130 observer.Wait(); |
| 132 | 131 |
| 133 std::set<Browser*> excluded; | 132 std::set<Browser*> excluded; |
| 134 excluded.insert(browser()); | 133 excluded.insert(browser()); |
| 135 Browser* popup = ui_test_utils::GetBrowserNotInSet(excluded); | 134 Browser* popup = ui_test_utils::GetBrowserNotInSet(excluded); |
| 136 if (!popup) | 135 if (!popup) |
| 137 return false; | 136 return false; |
| 138 | 137 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 208 } |
| 210 | 209 |
| 211 // Test for bug #1091358. | 210 // Test for bug #1091358. |
| 212 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { | 211 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { |
| 213 ASSERT_TRUE(test_server()->Start()); | 212 ASSERT_TRUE(test_server()->Start()); |
| 214 ui_test_utils::NavigateToURL( | 213 ui_test_utils::NavigateToURL( |
| 215 browser(), test_server()->GetURL("files/sync_xmlhttprequest.html")); | 214 browser(), test_server()->GetURL("files/sync_xmlhttprequest.html")); |
| 216 | 215 |
| 217 // Let's check the XMLHttpRequest ran successfully. | 216 // Let's check the XMLHttpRequest ran successfully. |
| 218 bool success = false; | 217 bool success = false; |
| 219 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 218 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 220 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 219 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 221 L"", | 220 L"", |
| 222 L"window.domAutomationController.send(DidSyncRequestSucceed());", | 221 L"window.domAutomationController.send(DidSyncRequestSucceed());", |
| 223 &success)); | 222 &success)); |
| 224 EXPECT_TRUE(success); | 223 EXPECT_TRUE(success); |
| 225 } | 224 } |
| 226 | 225 |
| 227 // If this flakes, use http://crbug.com/62776. | 226 // If this flakes, use http://crbug.com/62776. |
| 228 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 227 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 229 SyncXMLHttpRequest_Disallowed) { | 228 SyncXMLHttpRequest_Disallowed) { |
| 230 ASSERT_TRUE(test_server()->Start()); | 229 ASSERT_TRUE(test_server()->Start()); |
| 231 ui_test_utils::NavigateToURL( | 230 ui_test_utils::NavigateToURL( |
| 232 browser(), | 231 browser(), |
| 233 test_server()->GetURL("files/sync_xmlhttprequest_disallowed.html")); | 232 test_server()->GetURL("files/sync_xmlhttprequest_disallowed.html")); |
| 234 | 233 |
| 235 // Let's check the XMLHttpRequest ran successfully. | 234 // Let's check the XMLHttpRequest ran successfully. |
| 236 bool success = false; | 235 bool success = false; |
| 237 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 236 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 238 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 237 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 239 L"", | 238 L"", |
| 240 L"window.domAutomationController.send(DidSucceed());", | 239 L"window.domAutomationController.send(DidSucceed());", |
| 241 &success)); | 240 &success)); |
| 242 EXPECT_TRUE(success); | 241 EXPECT_TRUE(success); |
| 243 } | 242 } |
| 244 | 243 |
| 245 // Test for bug #1159553 -- A synchronous xhr (whose content-type is | 244 // Test for bug #1159553 -- A synchronous xhr (whose content-type is |
| 246 // downloadable) would trigger download and hang the renderer process, | 245 // downloadable) would trigger download and hang the renderer process, |
| 247 // if executed while navigating to a new page. | 246 // if executed while navigating to a new page. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // off the navigation, and wait to see that the tab loads. | 401 // off the navigation, and wait to see that the tab loads. |
| 403 string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); | 402 string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); |
| 404 content::TitleWatcher title_watcher( | 403 content::TitleWatcher title_watcher( |
| 405 chrome::GetActiveWebContents(browser()), expected_title16); | 404 chrome::GetActiveWebContents(browser()), expected_title16); |
| 406 | 405 |
| 407 bool success; | 406 bool success; |
| 408 GURL test_url(test_server()->GetURL("files/title2.html")); | 407 GURL test_url(test_server()->GetURL("files/title2.html")); |
| 409 std::string redirect_script = "window.location='" + | 408 std::string redirect_script = "window.location='" + |
| 410 test_url.possibly_invalid_spec() + "';" + | 409 test_url.possibly_invalid_spec() + "';" + |
| 411 "window.domAutomationController.send(true);"; | 410 "window.domAutomationController.send(true);"; |
| 412 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 411 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 413 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 412 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 414 L"", ASCIIToWide(redirect_script), &success)); | 413 L"", ASCIIToWide(redirect_script), &success)); |
| 415 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 414 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 416 } | 415 } |
| 417 | 416 |
| 418 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 417 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 419 CrossSiteNavigationErrorPage2) { | 418 CrossSiteNavigationErrorPage2) { |
| 420 ASSERT_TRUE(test_server()->Start()); | 419 ASSERT_TRUE(test_server()->Start()); |
| 421 | 420 |
| 422 GURL url(test_server()->GetURL("files/title2.html")); | 421 GURL url(test_server()->GetURL("files/title2.html")); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 459 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 461 CrossSiteFailedRequest) { | 460 CrossSiteFailedRequest) { |
| 462 // Visit another URL first to trigger a cross-site navigation. | 461 // Visit another URL first to trigger a cross-site navigation. |
| 463 GURL url(content::kTestNewTabURL); | 462 GURL url(content::kTestNewTabURL); |
| 464 ui_test_utils::NavigateToURL(browser(), url); | 463 ui_test_utils::NavigateToURL(browser(), url); |
| 465 | 464 |
| 466 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 465 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
| 467 GURL broken_url("chrome://theme"); | 466 GURL broken_url("chrome://theme"); |
| 468 CheckTitleTest(broken_url, "chrome://theme/ is not available", 1); | 467 CheckTitleTest(broken_url, "chrome://theme/ is not available", 1); |
| 469 } | 468 } |
| OLD | NEW |