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

Side by Side Diff: chrome/browser/automation/automation_misc_browsertest.cc

Issue 11753009: Simplify ExecuteJavaScript* functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update prerender_browsertest.cc. 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "chrome/browser/automation/automation_provider_observers.h" 9 #include "chrome/browser/automation/automation_provider_observers.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 MockMouseEventCallback mock; 66 MockMouseEventCallback mock;
67 EXPECT_CALL(mock, 67 EXPECT_CALL(mock,
68 OnSuccess( 68 OnSuccess(
69 testing::AllOf( 69 testing::AllOf(
70 testing::Property(&gfx::Point::x, testing::Eq(5)), 70 testing::Property(&gfx::Point::x, testing::Eq(5)),
71 testing::Property(&gfx::Point::y, testing::Eq(10))))) 71 testing::Property(&gfx::Point::y, testing::Eq(10)))))
72 .Times(2); 72 .Times(2);
73 73
74 content::RenderViewHost* view = 74 content::RenderViewHost* view =
75 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 75 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
76 ASSERT_TRUE(content::ExecuteJavaScript( 76 ASSERT_TRUE(content::ExecuteScript(
77 view, 77 view,
78 "",
79 "window.didClick = false;" 78 "window.didClick = false;"
80 "document.body.innerHTML =" 79 "document.body.innerHTML ="
81 " '<a style=\\'position:absolute; left:0; top:0\\'>link</a>';" 80 " '<a style=\\'position:absolute; left:0; top:0\\'>link</a>';"
82 "document.querySelector('a').addEventListener('click', function() {" 81 "document.querySelector('a').addEventListener('click', function() {"
83 " window.didClick = true;" 82 " window.didClick = true;"
84 "}, true);")); 83 "}, true);"));
85 AutomationMouseEvent automation_event; 84 AutomationMouseEvent automation_event;
86 automation_event.location_script_chain.push_back( 85 automation_event.location_script_chain.push_back(
87 ScriptEvaluationRequest("{'x': 5, 'y': 10}", "")); 86 ScriptEvaluationRequest("{'x': 5, 'y': 10}", ""));
88 WebKit::WebMouseEvent& mouse_event = automation_event.mouse_event; 87 WebKit::WebMouseEvent& mouse_event = automation_event.mouse_event;
89 mouse_event.type = WebKit::WebInputEvent::MouseDown; 88 mouse_event.type = WebKit::WebInputEvent::MouseDown;
90 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 89 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
91 mouse_event.clickCount = 1; 90 mouse_event.clickCount = 1;
92 new AutomationMouseEventProcessor( 91 new AutomationMouseEventProcessor(
93 view, automation_event, mock.completion_callback(), 92 view, automation_event, mock.completion_callback(),
94 mock.error_callback()); 93 mock.error_callback());
95 mouse_event.type = WebKit::WebInputEvent::MouseUp; 94 mouse_event.type = WebKit::WebInputEvent::MouseUp;
96 new AutomationMouseEventProcessor( 95 new AutomationMouseEventProcessor(
97 view, automation_event, mock.completion_callback(), 96 view, automation_event, mock.completion_callback(),
98 mock.error_callback()); 97 mock.error_callback());
99 98
100 bool did_click = false; 99 bool did_click = false;
101 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 100 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
102 view, 101 view,
103 "",
104 "window.domAutomationController.send(window.didClick);", 102 "window.domAutomationController.send(window.didClick);",
105 &did_click)); 103 &did_click));
106 EXPECT_TRUE(did_click); 104 EXPECT_TRUE(did_click);
107 } 105 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_browsertest.cc ('k') | chrome/browser/automation/automation_tab_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698