1 function runFocusTestWithEventGenerator(generateEvent, expectedFiresTouchEvents) {
2 // TODO(lanwei): The select drop-down menu on Linux works differently from how it behaves on ChromeOS. On ChromeOS,
3 // the second tap will defocus both the popup menu and select element, will correct this behavior first and then
4 // add select to this test, see https://crbug.com/510950.
5 var testElement = function(ele) {
6 var focusEventHandler = function(event) {
8 shouldBeNonNull("event.sourceCapabilities");
9 shouldBe("event.sourceCapabilities.firesTouchEvents", expectedFiresTouchEvents);
12 var e = document.createElement(ele);
19 e.style.width = "100px";
20 e.style.height = "100px";
21 e.style.display = "block";
22 for (var evt of ['focus', 'focusin', 'blur', 'focusout']) {
23 e.addEventListener(evt, focusEventHandler, false);
26 document.body.insertBefore(e, document.body.firstChild);
27 debug("tests on " + ele);
29 if (generateEvent.name == "sendKeyboardTabEvent")
30 sendKeyboardTabEvent();
32 generateEvent(10, 10);
33 if (ele == "select") {
34 generateEvent(160, 160);
36 generateEvent(160, 160);
37 document.body.removeChild(e);
41 for (var ele of ['div', 'input', 'button', 'textarea', 'select', 'a']) {
42 if (ele == "select" && generateEvent.name == "sendGestureTapEvent")
44 testElement(ele, generateEvent);