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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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
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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 1256
1257 void OpenDestURLViaWindowOpen() const { 1257 void OpenDestURLViaWindowOpen() const {
1258 OpenURLViaWindowOpen(dest_url_); 1258 OpenURLViaWindowOpen(dest_url_);
1259 } 1259 }
1260 1260
1261 void OpenURLViaWindowOpen(const GURL& url) const { 1261 void OpenURLViaWindowOpen(const GURL& url) const {
1262 OpenURLWithJSImpl("WindowOpen", url, GURL(), true); 1262 OpenURLWithJSImpl("WindowOpen", url, GURL(), true);
1263 } 1263 }
1264 1264
1265 void RemoveLinkElement(int i) const { 1265 void RemoveLinkElement(int i) const {
1266 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScript( 1266 GetActiveWebContents()->GetMainFrame()->ExecuteJavaScriptForTests(
1267 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); 1267 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i)));
1268 } 1268 }
1269 1269
1270 void ClickToNextPageAfterPrerender() { 1270 void ClickToNextPageAfterPrerender() {
1271 TestNavigationObserver nav_observer(GetActiveWebContents()); 1271 TestNavigationObserver nav_observer(GetActiveWebContents());
1272 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); 1272 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame();
1273 render_frame_host->ExecuteJavaScript(base::ASCIIToUTF16("ClickOpenLink()")); 1273 render_frame_host->ExecuteJavaScriptForTests(
1274 base::ASCIIToUTF16("ClickOpenLink()"));
1274 nav_observer.Wait(); 1275 nav_observer.Wait();
1275 } 1276 }
1276 1277
1277 void NavigateToNextPageAfterPrerender() const { 1278 void NavigateToNextPageAfterPrerender() const {
1278 ui_test_utils::NavigateToURL( 1279 ui_test_utils::NavigateToURL(
1279 current_browser(), 1280 current_browser(),
1280 test_server()->GetURL("files/prerender/prerender_page.html")); 1281 test_server()->GetURL("files/prerender/prerender_page.html"));
1281 } 1282 }
1282 1283
1283 // Called after the prerendered page has been navigated to and then away from. 1284 // Called after the prerendered page has been navigated to and then away from.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 1522
1522 scoped_ptr<TestPrerender> ExpectPrerender(FinalStatus expected_final_status) { 1523 scoped_ptr<TestPrerender> ExpectPrerender(FinalStatus expected_final_status) {
1523 return prerender_contents_factory_->ExpectPrerenderContents( 1524 return prerender_contents_factory_->ExpectPrerenderContents(
1524 expected_final_status); 1525 expected_final_status);
1525 } 1526 }
1526 1527
1527 void AddPrerender(const GURL& url, int index) { 1528 void AddPrerender(const GURL& url, int index) {
1528 std::string javascript = base::StringPrintf( 1529 std::string javascript = base::StringPrintf(
1529 "AddPrerender('%s', %d)", url.spec().c_str(), index); 1530 "AddPrerender('%s', %d)", url.spec().c_str(), index);
1530 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame(); 1531 RenderFrameHost* render_frame_host = GetActiveWebContents()->GetMainFrame();
1531 render_frame_host->ExecuteJavaScript(base::ASCIIToUTF16(javascript)); 1532 render_frame_host->ExecuteJavaScriptForTests(
1533 base::ASCIIToUTF16(javascript));
1532 } 1534 }
1533 1535
1534 // Returns a string for pattern-matching TaskManager tab entries. 1536 // Returns a string for pattern-matching TaskManager tab entries.
1535 base::string16 MatchTaskManagerTab(const char* page_title) { 1537 base::string16 MatchTaskManagerTab(const char* page_title) {
1536 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, 1538 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX,
1537 base::ASCIIToUTF16(page_title)); 1539 base::ASCIIToUTF16(page_title));
1538 } 1540 }
1539 1541
1540 // Returns a string for pattern-matching TaskManager prerender entries. 1542 // Returns a string for pattern-matching TaskManager prerender entries.
1541 base::string16 MatchTaskManagerPrerender(const char* page_title) { 1543 base::string16 MatchTaskManagerPrerender(const char* page_title) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 url.spec().c_str(), ping_url.spec().c_str()); 1673 url.spec().c_str(), ping_url.spec().c_str());
1672 1674
1673 if (new_web_contents) { 1675 if (new_web_contents) {
1674 NewTabNavigationOrSwapObserver observer; 1676 NewTabNavigationOrSwapObserver observer;
1675 render_frame_host->ExecuteJavaScriptWithUserGestureForTests( 1677 render_frame_host->ExecuteJavaScriptWithUserGestureForTests(
1676 base::ASCIIToUTF16(javascript)); 1678 base::ASCIIToUTF16(javascript));
1677 observer.Wait(); 1679 observer.Wait();
1678 } else { 1680 } else {
1679 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), 1681 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(),
1680 web_contents); 1682 web_contents);
1681 render_frame_host->ExecuteJavaScript(base::ASCIIToUTF16(javascript)); 1683 render_frame_host->ExecuteJavaScriptForTests(
1684 base::ASCIIToUTF16(javascript));
1682 observer.Wait(); 1685 observer.Wait();
1683 } 1686 }
1684 } 1687 }
1685 1688
1686 TestPrerenderContentsFactory* prerender_contents_factory_; 1689 TestPrerenderContentsFactory* prerender_contents_factory_;
1687 #if defined(FULL_SAFE_BROWSING) 1690 #if defined(FULL_SAFE_BROWSING)
1688 scoped_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; 1691 scoped_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_;
1689 #endif 1692 #endif
1690 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_; 1693 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_;
1691 GURL dest_url_; 1694 GURL dest_url_;
(...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 4141
4139 NavigateToDestURL(); 4142 NavigateToDestURL();
4140 EXPECT_EQ(1U, task_manager.tasks().size()); 4143 EXPECT_EQ(1U, task_manager.tasks().size());
4141 } 4144 }
4142 4145
4143 } // namespace 4146 } // namespace
4144 4147
4145 #endif // defined(ENABLE_TASK_MANAGER) 4148 #endif // defined(ENABLE_TASK_MANAGER)
4146 4149
4147 } // namespace prerender 4150 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/mouseleave_browsertest.cc ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698