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

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 6630001: Allow webdriver users to choose between sending the key events when... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/webdriver/automation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/testing_automation_provider.cc
===================================================================
--- chrome/browser/automation/testing_automation_provider.cc (revision 76851)
+++ chrome/browser/automation/testing_automation_provider.cc (working copy)
@@ -4655,9 +4655,56 @@
event.isSystemKey = is_system_key;
event.timeStampSeconds = base::Time::Now().ToDoubleT();
event.skip_in_browser = true;
- new InputEventAckNotificationObserver(this, reply_message, event.type);
- browser->GetSelectedTabContents()->render_view_host()->
- ForwardKeyboardEvent(event);
+ bool use_native_events = false;
+ // If useNativeEvents is true, this function will call
+ // ui_controls::SendKeyPress to the native window handle of the browser,
+ // allowing events to be catched higher up; if false it will send an
+ // event directly to webkit.
+ if (args->GetBoolean("useNativeEvents", &use_native_events) &&
+ use_native_events) {
Paweł Hajdan Jr. 2011/03/08 07:53:05 Yeah, if you'd like to keep it, please extract the
timothe faudot 2011/03/08 09:08:17 I separated this into two methods and factorized t
+ // The ui_controls::SendKeyPress function will generate up and down events
+ // from one keycode for us so we only need to send one event to it.
+ // Filtering is done via the RawKeyDown type because it is the one sent by
+ // the current webdriver implementation of WebElement.SendKeys(...).
+ if (event.type != WebKit::WebInputEvent::RawKeyDown) {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendSuccess(
+ Value::CreateStringValue("Skipped non raw key down event"));
Paweł Hajdan Jr. 2011/03/08 07:53:05 Reporting this important data via String is fragil
timothe faudot 2011/03/08 09:08:17 Done.
+ return;
+ }
+ BrowserWindow* browser_window = browser->window();
+ if (!browser_window) {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendError("Could not get the browser window");
+ return;
+ }
+ gfx::NativeWindow window = browser_window->GetNativeHandle();
+ if (!window) {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendError("Could not get the browser window handle");
+ return;
+ }
+ bool control = !!(event.modifiers & WebKit::WebInputEvent::ControlKey);
+ bool shift = !!(event.modifiers & WebKit::WebInputEvent::ShiftKey);
+ bool alt = !!(event.modifiers & WebKit::WebInputEvent::AltKey);
+ bool meta = !!(event.modifiers & WebKit::WebInputEvent::MetaKey);
+ if (!ui_controls::SendKeyPress(
+ window, static_cast<ui::KeyboardCode>(event.nativeKeyCode),
+ control, shift, alt, meta)) {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendError("Could not send the native key event");
+ return;
+ } else {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendSuccess(NULL);
+ return;
+ }
+ } else {
+ new InputEventAckNotificationObserver(this, reply_message, event.type);
+ browser->GetSelectedTabContents()->render_view_host()->
+ ForwardKeyboardEvent(event);
+ return;
+ }
}
// Sample JSON input: { "command": "GetNTPThumbnailMode" }
@@ -4772,8 +4819,7 @@
section = MENU_THUMB;
} else if (section_name.compare("recently_closed") == 0) {
section = MENU_RECENT;
- }
- else {
+ } else {
reply.SendError(StringPrintf("Unexpected section name: '%s'",
section_name.c_str()));
return;
« no previous file with comments | « no previous file | chrome/test/webdriver/automation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698