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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_browsertest.cc

Issue 11728003: Change ExecuteJavaScript* helper functions in browser_test_utils.{h,cc} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding files for gpu_tests and NaCl browser tests. Created 7 years, 11 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) 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
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(), L"", L"OpenPopup();")) 72 if (!ExecuteJavaScript(render_view_host(), "", "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
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 L"", 170 "",
171 L"window.domAutomationController.send(DidSyncRequestSucceed());", 171 "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 L"", 188 "",
189 L"window.domAutomationController.send(DidSucceed());", 189 "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
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 L"", ASCIIToWide(redirect_script), &success)); 351 "",
352 redirect_script,
353 &success));
352 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); 354 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
353 } 355 }
354 356
355 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, 357 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest,
356 CrossSiteNavigationErrorPage2) { 358 CrossSiteNavigationErrorPage2) {
357 ASSERT_TRUE(test_server()->Start()); 359 ASSERT_TRUE(test_server()->Start());
358 360
359 GURL url(test_server()->GetURL("files/title2.html")); 361 GURL url(test_server()->GetURL("files/title2.html"));
360 CheckTitleTest(url, "Title Of Awesomeness"); 362 CheckTitleTest(url, "Title Of Awesomeness");
361 363
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 CrossSiteFailedRequest) { 398 CrossSiteFailedRequest) {
397 // Visit another URL first to trigger a cross-site navigation. 399 // Visit another URL first to trigger a cross-site navigation.
398 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); 400 NavigateToURL(shell(), GetTestUrl("", "simple_page.html"));
399 401
400 // Visit a URL that fails without calling ResourceDispatcherHost::Read. 402 // Visit a URL that fails without calling ResourceDispatcherHost::Read.
401 GURL broken_url("chrome://theme"); 403 GURL broken_url("chrome://theme");
402 NavigateToURL(shell(), broken_url); 404 NavigateToURL(shell(), broken_url);
403 } 405 }
404 406
405 } // namespace content 407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698