| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 bool generate_char = false; | 1439 bool generate_char = false; |
| 1440 | 1440 |
| 1441 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when | 1441 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when |
| 1442 // Windows uses \r for "Enter". | 1442 // Windows uses \r for "Enter". |
| 1443 int code = 0; | 1443 int code = 0; |
| 1444 int text = 0; | 1444 int text = 0; |
| 1445 bool needs_shift_key_modifier = false; | 1445 bool needs_shift_key_modifier = false; |
| 1446 std::string domKeyString; | 1446 std::string domKeyString; |
| 1447 std::string domCodeString; | 1447 std::string domCodeString; |
| 1448 | 1448 |
| 1449 // TODO(dtapuska): Convert all layout tests to use the proper code_str | 1449 if ("Enter" == code_str) { |
| 1450 // values that match the DOM Code specification. crbug.com/617606 | |
| 1451 if ("\n" == code_str || | |
| 1452 "Enter" == code_str) { | |
| 1453 generate_char = true; | 1450 generate_char = true; |
| 1454 text = code = ui::VKEY_RETURN; | 1451 text = code = ui::VKEY_RETURN; |
| 1455 domKeyString.assign("Enter"); | 1452 domKeyString.assign("Enter"); |
| 1456 domCodeString.assign("Enter"); | 1453 domCodeString.assign("Enter"); |
| 1457 } else if ("rightArrow" == code_str || | 1454 } else if ("ArrowRight" == code_str) { |
| 1458 "ArrowRight" == code_str) { | |
| 1459 code = ui::VKEY_RIGHT; | 1455 code = ui::VKEY_RIGHT; |
| 1460 domKeyString.assign("ArrowRight"); | 1456 domKeyString.assign("ArrowRight"); |
| 1461 domCodeString.assign("ArrowRight"); | 1457 domCodeString.assign("ArrowRight"); |
| 1462 } else if ("downArrow" == code_str || | 1458 } else if ("ArrowDown" == code_str) { |
| 1463 "ArrowDown" == code_str) { | |
| 1464 code = ui::VKEY_DOWN; | 1459 code = ui::VKEY_DOWN; |
| 1465 domKeyString.assign("ArrowDown"); | 1460 domKeyString.assign("ArrowDown"); |
| 1466 domCodeString.assign("ArrowDown"); | 1461 domCodeString.assign("ArrowDown"); |
| 1467 } else if ("leftArrow" == code_str || | 1462 } else if ("ArrowLeft" == code_str) { |
| 1468 "ArrowLeft" == code_str) { | |
| 1469 code = ui::VKEY_LEFT; | 1463 code = ui::VKEY_LEFT; |
| 1470 domKeyString.assign("ArrowLeft"); | 1464 domKeyString.assign("ArrowLeft"); |
| 1471 domCodeString.assign("ArrowLeft"); | 1465 domCodeString.assign("ArrowLeft"); |
| 1472 } else if ("upArrow" == code_str || | 1466 } else if ("ArrowUp" == code_str) { |
| 1473 "ArrowUp" == code_str) { | |
| 1474 code = ui::VKEY_UP; | 1467 code = ui::VKEY_UP; |
| 1475 domKeyString.assign("ArrowUp"); | 1468 domKeyString.assign("ArrowUp"); |
| 1476 domCodeString.assign("ArrowUp"); | 1469 domCodeString.assign("ArrowUp"); |
| 1477 } else if ("insert" == code_str || | 1470 } else if ("Insert" == code_str) { |
| 1478 "Insert" == code_str) { | |
| 1479 code = ui::VKEY_INSERT; | 1471 code = ui::VKEY_INSERT; |
| 1480 domKeyString.assign("Insert"); | 1472 domKeyString.assign("Insert"); |
| 1481 domCodeString.assign("Insert"); | 1473 domCodeString.assign("Insert"); |
| 1482 } else if ("delete" == code_str || | 1474 } else if ("Delete" == code_str) { |
| 1483 "Delete" == code_str) { | |
| 1484 code = ui::VKEY_DELETE; | 1475 code = ui::VKEY_DELETE; |
| 1485 domKeyString.assign("Delete"); | 1476 domKeyString.assign("Delete"); |
| 1486 domCodeString.assign("Delete"); | 1477 domCodeString.assign("Delete"); |
| 1487 } else if ("pageUp" == code_str || | 1478 } else if ("PageUp" == code_str) { |
| 1488 "PageUp" == code_str) { | |
| 1489 code = ui::VKEY_PRIOR; | 1479 code = ui::VKEY_PRIOR; |
| 1490 domKeyString.assign("PageUp"); | 1480 domKeyString.assign("PageUp"); |
| 1491 domCodeString.assign("PageUp"); | 1481 domCodeString.assign("PageUp"); |
| 1492 } else if ("pageDown" == code_str || | 1482 } else if ("PageDown" == code_str) { |
| 1493 "PageDown" == code_str) { | |
| 1494 code = ui::VKEY_NEXT; | 1483 code = ui::VKEY_NEXT; |
| 1495 domKeyString.assign("PageDown"); | 1484 domKeyString.assign("PageDown"); |
| 1496 domCodeString.assign("PageDown"); | 1485 domCodeString.assign("PageDown"); |
| 1497 } else if ("home" == code_str || | 1486 } else if ("Home" == code_str) { |
| 1498 "Home" == code_str) { | |
| 1499 code = ui::VKEY_HOME; | 1487 code = ui::VKEY_HOME; |
| 1500 domKeyString.assign("Home"); | 1488 domKeyString.assign("Home"); |
| 1501 domCodeString.assign("Home"); | 1489 domCodeString.assign("Home"); |
| 1502 } else if ("end" == code_str || | 1490 } else if ("End" == code_str) { |
| 1503 "End" == code_str) { | |
| 1504 code = ui::VKEY_END; | 1491 code = ui::VKEY_END; |
| 1505 domKeyString.assign("End"); | 1492 domKeyString.assign("End"); |
| 1506 domCodeString.assign("End"); | 1493 domCodeString.assign("End"); |
| 1507 } else if ("printScreen" == code_str || | 1494 } else if ("PrintScreen" == code_str) { |
| 1508 "PrintScreen" == code_str) { | |
| 1509 code = ui::VKEY_SNAPSHOT; | 1495 code = ui::VKEY_SNAPSHOT; |
| 1510 domKeyString.assign("PrintScreen"); | 1496 domKeyString.assign("PrintScreen"); |
| 1511 domCodeString.assign("PrintScreen"); | 1497 domCodeString.assign("PrintScreen"); |
| 1512 } else if ("menu" == code_str || | 1498 } else if ("ContextMenu" == code_str) { |
| 1513 "ContextMenu" == code_str) { | |
| 1514 code = ui::VKEY_APPS; | 1499 code = ui::VKEY_APPS; |
| 1515 domKeyString.assign("ContextMenu"); | 1500 domKeyString.assign("ContextMenu"); |
| 1516 domCodeString.assign("ContextMenu"); | 1501 domCodeString.assign("ContextMenu"); |
| 1517 } else if ("leftControl" == code_str || | 1502 } else if ("ControlLeft" == code_str) { |
| 1518 "ControlLeft" == code_str) { | |
| 1519 code = ui::VKEY_CONTROL; | 1503 code = ui::VKEY_CONTROL; |
| 1520 domKeyString.assign("Control"); | 1504 domKeyString.assign("Control"); |
| 1521 domCodeString.assign("ControlLeft"); | 1505 domCodeString.assign("ControlLeft"); |
| 1522 location = DOMKeyLocationLeft; | 1506 location = DOMKeyLocationLeft; |
| 1523 } else if ("rightControl" == code_str || | 1507 } else if ("ControlRight" == code_str) { |
| 1524 "ControlRight" == code_str) { | |
| 1525 code = ui::VKEY_CONTROL; | 1508 code = ui::VKEY_CONTROL; |
| 1526 domKeyString.assign("Control"); | 1509 domKeyString.assign("Control"); |
| 1527 domCodeString.assign("ControlRight"); | 1510 domCodeString.assign("ControlRight"); |
| 1528 location = DOMKeyLocationRight; | 1511 location = DOMKeyLocationRight; |
| 1529 } else if ("leftShift" == code_str || | 1512 } else if ("ShiftLeft" == code_str) { |
| 1530 "ShiftLeft" == code_str) { | |
| 1531 code = ui::VKEY_SHIFT; | 1513 code = ui::VKEY_SHIFT; |
| 1532 domKeyString.assign("Shift"); | 1514 domKeyString.assign("Shift"); |
| 1533 domCodeString.assign("ShiftLeft"); | 1515 domCodeString.assign("ShiftLeft"); |
| 1534 location = DOMKeyLocationLeft; | 1516 location = DOMKeyLocationLeft; |
| 1535 } else if ("rightShift" == code_str || | 1517 } else if ("ShiftRight" == code_str) { |
| 1536 "ShiftRight" == code_str) { | |
| 1537 code = ui::VKEY_SHIFT; | 1518 code = ui::VKEY_SHIFT; |
| 1538 domKeyString.assign("Shift"); | 1519 domKeyString.assign("Shift"); |
| 1539 domCodeString.assign("ShiftRight"); | 1520 domCodeString.assign("ShiftRight"); |
| 1540 location = DOMKeyLocationRight; | 1521 location = DOMKeyLocationRight; |
| 1541 } else if ("leftAlt" == code_str || | 1522 } else if ("AltLeft" == code_str) { |
| 1542 "AltLeft" == code_str) { | |
| 1543 code = ui::VKEY_MENU; | 1523 code = ui::VKEY_MENU; |
| 1544 domKeyString.assign("Alt"); | 1524 domKeyString.assign("Alt"); |
| 1545 domCodeString.assign("AltLeft"); | 1525 domCodeString.assign("AltLeft"); |
| 1546 location = DOMKeyLocationLeft; | 1526 location = DOMKeyLocationLeft; |
| 1547 } else if ("rightAlt" == code_str || | 1527 } else if ("AltRight" == code_str) { |
| 1548 "AltRight" == code_str) { | |
| 1549 code = ui::VKEY_MENU; | 1528 code = ui::VKEY_MENU; |
| 1550 domKeyString.assign("Alt"); | 1529 domKeyString.assign("Alt"); |
| 1551 domCodeString.assign("AltRight"); | 1530 domCodeString.assign("AltRight"); |
| 1552 location = DOMKeyLocationRight; | 1531 location = DOMKeyLocationRight; |
| 1553 } else if ("numLock" == code_str || | 1532 } else if ("NumLock" == code_str) { |
| 1554 "NumLock" == code_str) { | |
| 1555 code = ui::VKEY_NUMLOCK; | 1533 code = ui::VKEY_NUMLOCK; |
| 1556 domKeyString.assign("NumLock"); | 1534 domKeyString.assign("NumLock"); |
| 1557 domCodeString.assign("NumLock"); | 1535 domCodeString.assign("NumLock"); |
| 1558 } else if ("backspace" == code_str || | 1536 } else if ("Backspace" == code_str) { |
| 1559 "Backspace" == code_str) { | |
| 1560 code = ui::VKEY_BACK; | 1537 code = ui::VKEY_BACK; |
| 1561 domKeyString.assign("Backspace"); | 1538 domKeyString.assign("Backspace"); |
| 1562 domCodeString.assign("Backspace"); | 1539 domCodeString.assign("Backspace"); |
| 1563 } else if ("escape" == code_str || | 1540 } else if ("Escape" == code_str) { |
| 1564 "Escape" == code_str) { | |
| 1565 code = ui::VKEY_ESCAPE; | 1541 code = ui::VKEY_ESCAPE; |
| 1566 domKeyString.assign("Escape"); | 1542 domKeyString.assign("Escape"); |
| 1567 domCodeString.assign("Escape"); | 1543 domCodeString.assign("Escape"); |
| 1568 } else if ("Tab" == code_str) { | 1544 } else if ("Tab" == code_str) { |
| 1569 code = ui::VKEY_TAB; | 1545 code = ui::VKEY_TAB; |
| 1570 domKeyString.assign("Tab"); | 1546 domKeyString.assign("Tab"); |
| 1571 domCodeString.assign("Tab"); | 1547 domCodeString.assign("Tab"); |
| 1572 } else { | 1548 } else { |
| 1573 // Compare the input string with the function-key names defined by the | 1549 // Compare the input string with the function-key names defined by the |
| 1574 // DOM spec (i.e. "F1",...,"F24"). If the input string is a function-key | 1550 // DOM spec (i.e. "F1",...,"F24"). If the input string is a function-key |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 mouse_event_queue_.push_back(saved_event); | 1950 mouse_event_queue_.push_back(saved_event); |
| 1975 } else { | 1951 } else { |
| 1976 DoLeapForward(milliseconds); | 1952 DoLeapForward(milliseconds); |
| 1977 } | 1953 } |
| 1978 } | 1954 } |
| 1979 | 1955 |
| 1980 void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) { | 1956 void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) { |
| 1981 if (!current_drag_data_.isNull()) { | 1957 if (!current_drag_data_.isNull()) { |
| 1982 // Nested dragging not supported, fuzzer code a likely culprit. | 1958 // Nested dragging not supported, fuzzer code a likely culprit. |
| 1983 // Cancel the current drag operation and throw an error. | 1959 // Cancel the current drag operation and throw an error. |
| 1984 KeyDown("escape", 0, DOMKeyLocationStandard); | 1960 KeyDown("Escape", 0, DOMKeyLocationStandard); |
| 1985 v8::Isolate* isolate = blink::mainThreadIsolate(); | 1961 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1986 isolate->ThrowException(v8::Exception::Error( | 1962 isolate->ThrowException(v8::Exception::Error( |
| 1987 gin::StringToV8(isolate, | 1963 gin::StringToV8(isolate, |
| 1988 "Nested beginDragWithFiles() not supported."))); | 1964 "Nested beginDragWithFiles() not supported."))); |
| 1989 return; | 1965 return; |
| 1990 } | 1966 } |
| 1991 current_drag_data_.initialize(); | 1967 current_drag_data_.initialize(); |
| 1992 WebVector<WebString> absolute_filenames(files.size()); | 1968 WebVector<WebString> absolute_filenames(files.size()); |
| 1993 for (size_t i = 0; i < files.size(); ++i) { | 1969 for (size_t i = 0; i < files.size(); ++i) { |
| 1994 WebDragData::Item item; | 1970 WebDragData::Item item; |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2813 | 2789 |
| 2814 const blink::WebView* EventSender::view() const { | 2790 const blink::WebView* EventSender::view() const { |
| 2815 return web_test_proxy_base_->web_view(); | 2791 return web_test_proxy_base_->web_view(); |
| 2816 } | 2792 } |
| 2817 | 2793 |
| 2818 blink::WebView* EventSender::view() { | 2794 blink::WebView* EventSender::view() { |
| 2819 return web_test_proxy_base_->web_view(); | 2795 return web_test_proxy_base_->web_view(); |
| 2820 } | 2796 } |
| 2821 | 2797 |
| 2822 } // namespace test_runner | 2798 } // namespace test_runner |
| OLD | NEW |