| 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 "content/public/browser/resource_dispatcher_host.h" | 5 #include "content/public/browser/resource_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 NavigateToURL(shell(), url); | 75 NavigateToURL(shell(), url); |
| 76 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 76 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool GetPopupTitle(const GURL& url, base::string16* title) { | 79 bool GetPopupTitle(const GURL& url, base::string16* title) { |
| 80 NavigateToURL(shell(), url); | 80 NavigateToURL(shell(), url); |
| 81 | 81 |
| 82 ShellAddedObserver new_shell_observer; | 82 ShellAddedObserver new_shell_observer; |
| 83 | 83 |
| 84 // Create dynamic popup. | 84 // Create dynamic popup. |
| 85 if (!ExecuteScript(shell()->web_contents(), "OpenPopup();")) | 85 if (!ExecuteScript(shell(), "OpenPopup();")) |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 Shell* new_shell = new_shell_observer.GetShell(); | 88 Shell* new_shell = new_shell_observer.GetShell(); |
| 89 *title = new_shell->web_contents()->GetTitle(); | 89 *title = new_shell->web_contents()->GetTitle(); |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 | 92 |
| 93 std::string GetCookies(const GURL& url) { | 93 std::string GetCookies(const GURL& url) { |
| 94 return content::GetCookies( | 94 return content::GetCookies( |
| 95 shell()->web_contents()->GetBrowserContext(), url); | 95 shell()->web_contents()->GetBrowserContext(), url); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 // Test for bug #1091358. | 183 // Test for bug #1091358. |
| 184 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { | 184 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { |
| 185 ASSERT_TRUE(embedded_test_server()->Start()); | 185 ASSERT_TRUE(embedded_test_server()->Start()); |
| 186 NavigateToURL( | 186 NavigateToURL( |
| 187 shell(), embedded_test_server()->GetURL("/sync_xmlhttprequest.html")); | 187 shell(), embedded_test_server()->GetURL("/sync_xmlhttprequest.html")); |
| 188 | 188 |
| 189 // Let's check the XMLHttpRequest ran successfully. | 189 // Let's check the XMLHttpRequest ran successfully. |
| 190 bool success = false; | 190 bool success = false; |
| 191 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 191 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 192 shell()->web_contents(), | 192 shell(), "window.domAutomationController.send(DidSyncRequestSucceed());", |
| 193 "window.domAutomationController.send(DidSyncRequestSucceed());", | |
| 194 &success)); | 193 &success)); |
| 195 EXPECT_TRUE(success); | 194 EXPECT_TRUE(success); |
| 196 } | 195 } |
| 197 | 196 |
| 198 // If this flakes, use http://crbug.com/62776. | 197 // If this flakes, use http://crbug.com/62776. |
| 199 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 198 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 200 SyncXMLHttpRequest_Disallowed) { | 199 SyncXMLHttpRequest_Disallowed) { |
| 201 ASSERT_TRUE(embedded_test_server()->Start()); | 200 ASSERT_TRUE(embedded_test_server()->Start()); |
| 202 NavigateToURL( | 201 NavigateToURL( |
| 203 shell(), | 202 shell(), |
| 204 embedded_test_server()->GetURL("/sync_xmlhttprequest_disallowed.html")); | 203 embedded_test_server()->GetURL("/sync_xmlhttprequest_disallowed.html")); |
| 205 | 204 |
| 206 // Let's check the XMLHttpRequest ran successfully. | 205 // Let's check the XMLHttpRequest ran successfully. |
| 207 bool success = false; | 206 bool success = false; |
| 208 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 207 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 209 shell()->web_contents(), | 208 shell(), "window.domAutomationController.send(DidSucceed());", &success)); |
| 210 "window.domAutomationController.send(DidSucceed());", | |
| 211 &success)); | |
| 212 EXPECT_TRUE(success); | 209 EXPECT_TRUE(success); |
| 213 } | 210 } |
| 214 | 211 |
| 215 // Test for bug #1159553 -- A synchronous xhr (whose content-type is | 212 // Test for bug #1159553 -- A synchronous xhr (whose content-type is |
| 216 // downloadable) would trigger download and hang the renderer process, | 213 // downloadable) would trigger download and hang the renderer process, |
| 217 // if executed while navigating to a new page. | 214 // if executed while navigating to a new page. |
| 218 // Disabled on Mac: see http://crbug.com/56264 | 215 // Disabled on Mac: see http://crbug.com/56264 |
| 219 #if defined(OS_MACOSX) | 216 #if defined(OS_MACOSX) |
| 220 #define MAYBE_SyncXMLHttpRequest_DuringUnload \ | 217 #define MAYBE_SyncXMLHttpRequest_DuringUnload \ |
| 221 DISABLED_SyncXMLHttpRequest_DuringUnload | 218 DISABLED_SyncXMLHttpRequest_DuringUnload |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // pages of which the error page is one. Instead, use automation to kick | 395 // pages of which the error page is one. Instead, use automation to kick |
| 399 // off the navigation, and wait to see that the tab loads. | 396 // off the navigation, and wait to see that the tab loads. |
| 400 base::string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); | 397 base::string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); |
| 401 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | 398 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
| 402 | 399 |
| 403 bool success; | 400 bool success; |
| 404 GURL test_url(embedded_test_server()->GetURL("/title2.html")); | 401 GURL test_url(embedded_test_server()->GetURL("/title2.html")); |
| 405 std::string redirect_script = "window.location='" + | 402 std::string redirect_script = "window.location='" + |
| 406 test_url.possibly_invalid_spec() + "';" + | 403 test_url.possibly_invalid_spec() + "';" + |
| 407 "window.domAutomationController.send(true);"; | 404 "window.domAutomationController.send(true);"; |
| 408 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 405 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), redirect_script, &success)); |
| 409 shell()->web_contents(), | |
| 410 redirect_script, | |
| 411 &success)); | |
| 412 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 406 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 413 } | 407 } |
| 414 | 408 |
| 415 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 409 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 416 CrossSiteNavigationErrorPage2) { | 410 CrossSiteNavigationErrorPage2) { |
| 417 ASSERT_TRUE(embedded_test_server()->Start()); | 411 ASSERT_TRUE(embedded_test_server()->Start()); |
| 418 | 412 |
| 419 GURL url(embedded_test_server()->GetURL("/title2.html")); | 413 GURL url(embedded_test_server()->GetURL("/title2.html")); |
| 420 CheckTitleTest(url, "Title Of Awesomeness"); | 414 CheckTitleTest(url, "Title Of Awesomeness"); |
| 421 | 415 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 | 743 |
| 750 // Reload with Lo-Fi disabled. | 744 // Reload with Lo-Fi disabled. |
| 751 Reset(false); | 745 Reset(false); |
| 752 TestNavigationObserver tab_observer(shell()->web_contents(), 1); | 746 TestNavigationObserver tab_observer(shell()->web_contents(), 1); |
| 753 shell()->web_contents()->GetController().ReloadDisableLoFi(true); | 747 shell()->web_contents()->GetController().ReloadDisableLoFi(true); |
| 754 tab_observer.Wait(); | 748 tab_observer.Wait(); |
| 755 CheckResourcesRequested(false); | 749 CheckResourcesRequested(false); |
| 756 } | 750 } |
| 757 | 751 |
| 758 } // namespace content | 752 } // namespace content |
| OLD | NEW |