| Index: content/shell/renderer/test_runner/event_sender.cc
|
| diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc
|
| index e54a95872fe3f239c7419605f20afb26038ba3c8..06bf22fa2f68d41d62336c788da22c13d769483b 100644
|
| --- a/content/shell/renderer/test_runner/event_sender.cc
|
| +++ b/content/shell/renderer/test_runner/event_sender.cc
|
| @@ -1289,78 +1289,86 @@ void EventSender::KeyDown(const std::string& code_str,
|
|
|
| // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when
|
| // Windows uses \r for "Enter".
|
| - int code = 0;
|
| + int keyCode = 0;
|
| int text = 0;
|
| bool needs_shift_key_modifier = false;
|
| - std::string domString;
|
| + std::string domCode;
|
| + std::string domKey;
|
|
|
| if ("\n" == code_str) {
|
| generate_char = true;
|
| - text = code = ui::VKEY_RETURN;
|
| - domString.assign("Enter");
|
| + text = keyCode = ui::VKEY_RETURN;
|
| + domCode.assign("Enter");
|
| } else if ("rightArrow" == code_str) {
|
| - code = ui::VKEY_RIGHT;
|
| - domString.assign("ArrowRight");
|
| + keyCode = ui::VKEY_RIGHT;
|
| + domCode.assign("ArrowRight");
|
| } else if ("downArrow" == code_str) {
|
| - code = ui::VKEY_DOWN;
|
| - domString.assign("ArrowDown");
|
| + keyCode = ui::VKEY_DOWN;
|
| + domCode.assign("ArrowDown");
|
| } else if ("leftArrow" == code_str) {
|
| - code = ui::VKEY_LEFT;
|
| - domString.assign("ArrowLeft");
|
| + keyCode = ui::VKEY_LEFT;
|
| + domCode.assign("ArrowLeft");
|
| } else if ("upArrow" == code_str) {
|
| - code = ui::VKEY_UP;
|
| - domString.assign("ArrowUp");
|
| + keyCode = ui::VKEY_UP;
|
| + domCode.assign("ArrowUp");
|
| } else if ("insert" == code_str) {
|
| - code = ui::VKEY_INSERT;
|
| - domString.assign("Insert");
|
| + keyCode = ui::VKEY_INSERT;
|
| + domCode.assign("Insert");
|
| } else if ("delete" == code_str) {
|
| - code = ui::VKEY_DELETE;
|
| - domString.assign("Delete");
|
| + keyCode = ui::VKEY_DELETE;
|
| + domCode.assign("Delete");
|
| } else if ("pageUp" == code_str) {
|
| - code = ui::VKEY_PRIOR;
|
| - domString.assign("PageUp");
|
| + keyCode = ui::VKEY_PRIOR;
|
| + domCode.assign("PageUp");
|
| } else if ("pageDown" == code_str) {
|
| - code = ui::VKEY_NEXT;
|
| - domString.assign("PageDown");
|
| + keyCode = ui::VKEY_NEXT;
|
| + domCode.assign("PageDown");
|
| } else if ("home" == code_str) {
|
| - code = ui::VKEY_HOME;
|
| - domString.assign("Home");
|
| + keyCode = ui::VKEY_HOME;
|
| + domCode.assign("Home");
|
| } else if ("end" == code_str) {
|
| - code = ui::VKEY_END;
|
| - domString.assign("End");
|
| + keyCode = ui::VKEY_END;
|
| + domCode.assign("End");
|
| } else if ("printScreen" == code_str) {
|
| - code = ui::VKEY_SNAPSHOT;
|
| - domString.assign("PrintScreen");
|
| + keyCode = ui::VKEY_SNAPSHOT;
|
| + domCode.assign("PrintScreen");
|
| } else if ("menu" == code_str) {
|
| - code = ui::VKEY_APPS;
|
| - domString.assign("ContextMenu");
|
| + keyCode = ui::VKEY_APPS;
|
| + domCode.assign("ContextMenu");
|
| + domKey.assign("MediaApps");
|
| } else if ("leftControl" == code_str) {
|
| - code = ui::VKEY_LCONTROL;
|
| - domString.assign("ControlLeft");
|
| + keyCode = ui::VKEY_LCONTROL;
|
| + domCode.assign("ControlLeft");
|
| + domKey.assign("Control");
|
| } else if ("rightControl" == code_str) {
|
| - code = ui::VKEY_RCONTROL;
|
| - domString.assign("ControlRight");
|
| + keyCode = ui::VKEY_RCONTROL;
|
| + domCode.assign("ControlRight");
|
| + domKey.assign("Control");
|
| } else if ("leftShift" == code_str) {
|
| - code = ui::VKEY_LSHIFT;
|
| - domString.assign("ShiftLeft");
|
| + keyCode = ui::VKEY_LSHIFT;
|
| + domCode.assign("ShiftLeft");
|
| + domKey.assign("Shift");
|
| } else if ("rightShift" == code_str) {
|
| - code = ui::VKEY_RSHIFT;
|
| - domString.assign("ShiftRight");
|
| + keyCode = ui::VKEY_RSHIFT;
|
| + domCode.assign("ShiftRight");
|
| + domKey.assign("Shift");
|
| } else if ("leftAlt" == code_str) {
|
| - code = ui::VKEY_LMENU;
|
| - domString.assign("AltLeft");
|
| + keyCode = ui::VKEY_LMENU;
|
| + domCode.assign("AltLeft");
|
| + domKey.assign("Alt");
|
| } else if ("rightAlt" == code_str) {
|
| - code = ui::VKEY_RMENU;
|
| - domString.assign("AltRight");
|
| + keyCode = ui::VKEY_RMENU;
|
| + domCode.assign("AltRight");
|
| + domKey.assign("AltGraph");
|
| } else if ("numLock" == code_str) {
|
| - code = ui::VKEY_NUMLOCK;
|
| - domString.assign("NumLock");
|
| + keyCode = ui::VKEY_NUMLOCK;
|
| + domCode.assign("NumLock");
|
| } else if ("backspace" == code_str) {
|
| - code = ui::VKEY_BACK;
|
| - domString.assign("Backspace");
|
| + keyCode = ui::VKEY_BACK;
|
| + domCode.assign("Backspace");
|
| } else if ("escape" == code_str) {
|
| - code = ui::VKEY_ESCAPE;
|
| - domString.assign("Escape");
|
| + keyCode = ui::VKEY_ESCAPE;
|
| + domCode.assign("Escape");
|
| } else {
|
| // Compare the input string with the function-key names defined by the
|
| // DOM spec (i.e. "F1",...,"F24"). If the input string is a function-key
|
| @@ -1368,35 +1376,36 @@ void EventSender::KeyDown(const std::string& code_str,
|
| for (int i = 1; i <= 24; ++i) {
|
| std::string function_key_name = base::StringPrintf("F%d", i);
|
| if (function_key_name == code_str) {
|
| - code = ui::VKEY_F1 + (i - 1);
|
| - domString = function_key_name;
|
| + keyCode = ui::VKEY_F1 + (i - 1);
|
| + domCode = function_key_name;
|
| break;
|
| }
|
| }
|
| - if (!code) {
|
| + if (!keyCode) {
|
| WebString web_code_str =
|
| WebString::fromUTF8(code_str.data(), code_str.size());
|
| DCHECK_EQ(1u, web_code_str.length());
|
| - text = code = web_code_str.at(0);
|
| - needs_shift_key_modifier = NeedsShiftModifier(code);
|
| - if ((code & 0xFF) >= 'a' && (code & 0xFF) <= 'z')
|
| - code -= 'a' - 'A';
|
| - if ((code >= 'A' && code <= 'Z') || (code >= 'a' && code <= 'z')) {
|
| - domString.assign("Key");
|
| - domString.push_back(base::ToUpperASCII(code));
|
| - } else if (code >= '0' && code <= '9') {
|
| - domString.assign("Digit");
|
| - domString.push_back(code);
|
| - } else if (code == ' ') {
|
| - domString.assign("Space");
|
| - } else if (code == 9) {
|
| - domString.assign("Tab");
|
| + text = keyCode = web_code_str.at(0);
|
| + needs_shift_key_modifier = NeedsShiftModifier(keyCode);
|
| + if ((keyCode & 0xFF) >= 'a' && (keyCode & 0xFF) <= 'z')
|
| + keyCode -= 'a' - 'A';
|
| + if ((keyCode >= 'A' && keyCode <= 'Z') ||
|
| + (keyCode >= 'a' && keyCode <= 'z')) {
|
| + domCode.assign("Key");
|
| + domCode.push_back(base::ToUpperASCII(keyCode));
|
| + } else if (keyCode >= '0' && keyCode <= '9') {
|
| + domCode.assign("Digit");
|
| + domCode.push_back(keyCode);
|
| + } else if (keyCode == ' ') {
|
| + domCode.assign("Space");
|
| + } else if (keyCode == 9) {
|
| + domCode.assign("Tab");
|
| }
|
| generate_char = true;
|
| }
|
|
|
| if ("(" == code_str) {
|
| - code = '9';
|
| + keyCode = '9';
|
| needs_shift_key_modifier = true;
|
| }
|
| }
|
| @@ -1409,9 +1418,13 @@ void EventSender::KeyDown(const std::string& code_str,
|
| WebKeyboardEvent event_down;
|
| event_down.type = WebInputEvent::RawKeyDown;
|
| event_down.modifiers = modifiers;
|
| - event_down.windowsKeyCode = code;
|
| + event_down.windowsKeyCode = keyCode;
|
| event_down.domCode = static_cast<int>(
|
| - ui::KeycodeConverter::CodeStringToDomCode(domString.c_str()));
|
| + ui::KeycodeConverter::CodeStringToDomCode(domCode.c_str()));
|
| + if (domKey.empty())
|
| + domKey = domCode;
|
| + event_down.domKey = static_cast<int>(
|
| + ui::KeycodeConverter::KeyStringToDomKey(domKey.c_str()));
|
|
|
| if (generate_char) {
|
| event_down.text[0] = text;
|
| @@ -1449,7 +1462,7 @@ void EventSender::KeyDown(const std::string& code_str,
|
|
|
| HandleInputEventOnViewOrPopup(event_down);
|
|
|
| - if (code == ui::VKEY_ESCAPE && !current_drag_data_.isNull()) {
|
| + if (keyCode == ui::VKEY_ESCAPE && !current_drag_data_.isNull()) {
|
| WebMouseEvent event;
|
| InitMouseEvent(WebInputEvent::MouseDown,
|
| pressed_button_,
|
| @@ -1469,7 +1482,7 @@ void EventSender::KeyDown(const std::string& code_str,
|
| // keyIdentifier is an empty string, unless the Enter key was pressed.
|
| // This behavior is not standard (keyIdentifier itself is not even a
|
| // standard any more), but it matches the actual behavior in Blink.
|
| - if (code != ui::VKEY_RETURN)
|
| + if (keyCode != ui::VKEY_RETURN)
|
| event_char.keyIdentifier[0] = '\0';
|
| HandleInputEventOnViewOrPopup(event_char);
|
| }
|
|
|