| 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/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/browser/download/download_manager_impl.h" | 7 #include "content/browser/download/download_manager_impl.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 NavigateToURL(shell(), url); | 62 NavigateToURL(shell(), url); |
| 63 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 63 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool GetPopupTitle(const GURL& url, string16* title) { | 66 bool GetPopupTitle(const GURL& url, string16* title) { |
| 67 NavigateToURL(shell(), url); | 67 NavigateToURL(shell(), url); |
| 68 | 68 |
| 69 ShellAddedObserver new_shell_observer; | 69 ShellAddedObserver new_shell_observer; |
| 70 | 70 |
| 71 // Create dynamic popup. | 71 // Create dynamic popup. |
| 72 if (!ExecuteJavaScript(render_view_host(), "", "OpenPopup();")) | 72 if (!ExecuteJavaScript(render_view_host(), L"", L"OpenPopup();")) |
| 73 return false; | 73 return false; |
| 74 | 74 |
| 75 Shell* new_shell = new_shell_observer.GetShell(); | 75 Shell* new_shell = new_shell_observer.GetShell(); |
| 76 *title = new_shell->web_contents()->GetTitle(); | 76 *title = new_shell->web_contents()->GetTitle(); |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 std::string GetCookies(const GURL& url) { | 80 std::string GetCookies(const GURL& url) { |
| 81 return content::GetCookies( | 81 return content::GetCookies( |
| 82 shell()->web_contents()->GetBrowserContext(), url); | 82 shell()->web_contents()->GetBrowserContext(), url); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Test for bug #1091358. | 160 // Test for bug #1091358. |
| 161 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { | 161 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { |
| 162 ASSERT_TRUE(test_server()->Start()); | 162 ASSERT_TRUE(test_server()->Start()); |
| 163 NavigateToURL( | 163 NavigateToURL( |
| 164 shell(), test_server()->GetURL("files/sync_xmlhttprequest.html")); | 164 shell(), test_server()->GetURL("files/sync_xmlhttprequest.html")); |
| 165 | 165 |
| 166 // Let's check the XMLHttpRequest ran successfully. | 166 // Let's check the XMLHttpRequest ran successfully. |
| 167 bool success = false; | 167 bool success = false; |
| 168 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 168 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 169 shell()->web_contents()->GetRenderViewHost(), | 169 shell()->web_contents()->GetRenderViewHost(), |
| 170 "", | 170 L"", |
| 171 "window.domAutomationController.send(DidSyncRequestSucceed());", | 171 L"window.domAutomationController.send(DidSyncRequestSucceed());", |
| 172 &success)); | 172 &success)); |
| 173 EXPECT_TRUE(success); | 173 EXPECT_TRUE(success); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // If this flakes, use http://crbug.com/62776. | 176 // If this flakes, use http://crbug.com/62776. |
| 177 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 177 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 178 SyncXMLHttpRequest_Disallowed) { | 178 SyncXMLHttpRequest_Disallowed) { |
| 179 ASSERT_TRUE(test_server()->Start()); | 179 ASSERT_TRUE(test_server()->Start()); |
| 180 NavigateToURL( | 180 NavigateToURL( |
| 181 shell(), | 181 shell(), |
| 182 test_server()->GetURL("files/sync_xmlhttprequest_disallowed.html")); | 182 test_server()->GetURL("files/sync_xmlhttprequest_disallowed.html")); |
| 183 | 183 |
| 184 // Let's check the XMLHttpRequest ran successfully. | 184 // Let's check the XMLHttpRequest ran successfully. |
| 185 bool success = false; | 185 bool success = false; |
| 186 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 186 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 187 shell()->web_contents()->GetRenderViewHost(), | 187 shell()->web_contents()->GetRenderViewHost(), |
| 188 "", | 188 L"", |
| 189 "window.domAutomationController.send(DidSucceed());", | 189 L"window.domAutomationController.send(DidSucceed());", |
| 190 &success)); | 190 &success)); |
| 191 EXPECT_TRUE(success); | 191 EXPECT_TRUE(success); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Test for bug #1159553 -- A synchronous xhr (whose content-type is | 194 // Test for bug #1159553 -- A synchronous xhr (whose content-type is |
| 195 // downloadable) would trigger download and hang the renderer process, | 195 // downloadable) would trigger download and hang the renderer process, |
| 196 // if executed while navigating to a new page. | 196 // if executed while navigating to a new page. |
| 197 // If this flakes, use http://crbug.com/56264. | 197 // If this flakes, use http://crbug.com/56264. |
| 198 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 198 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 199 SyncXMLHttpRequest_DuringUnload) { | 199 SyncXMLHttpRequest_DuringUnload) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); | 341 string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); |
| 342 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | 342 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
| 343 | 343 |
| 344 bool success; | 344 bool success; |
| 345 GURL test_url(test_server()->GetURL("files/title2.html")); | 345 GURL test_url(test_server()->GetURL("files/title2.html")); |
| 346 std::string redirect_script = "window.location='" + | 346 std::string redirect_script = "window.location='" + |
| 347 test_url.possibly_invalid_spec() + "';" + | 347 test_url.possibly_invalid_spec() + "';" + |
| 348 "window.domAutomationController.send(true);"; | 348 "window.domAutomationController.send(true);"; |
| 349 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 349 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 350 shell()->web_contents()->GetRenderViewHost(), | 350 shell()->web_contents()->GetRenderViewHost(), |
| 351 "", | 351 L"", ASCIIToWide(redirect_script), &success)); |
| 352 redirect_script, | |
| 353 &success)); | |
| 354 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 352 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 355 } | 353 } |
| 356 | 354 |
| 357 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 355 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 358 CrossSiteNavigationErrorPage2) { | 356 CrossSiteNavigationErrorPage2) { |
| 359 ASSERT_TRUE(test_server()->Start()); | 357 ASSERT_TRUE(test_server()->Start()); |
| 360 | 358 |
| 361 GURL url(test_server()->GetURL("files/title2.html")); | 359 GURL url(test_server()->GetURL("files/title2.html")); |
| 362 CheckTitleTest(url, "Title Of Awesomeness"); | 360 CheckTitleTest(url, "Title Of Awesomeness"); |
| 363 | 361 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 CrossSiteFailedRequest) { | 396 CrossSiteFailedRequest) { |
| 399 // Visit another URL first to trigger a cross-site navigation. | 397 // Visit another URL first to trigger a cross-site navigation. |
| 400 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); | 398 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); |
| 401 | 399 |
| 402 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 400 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
| 403 GURL broken_url("chrome://theme"); | 401 GURL broken_url("chrome://theme"); |
| 404 NavigateToURL(shell(), broken_url); | 402 NavigateToURL(shell(), broken_url); |
| 405 } | 403 } |
| 406 | 404 |
| 407 } // namespace content | 405 } // namespace content |
| OLD | NEW |