1 description('Test that ensure textInput events should not fired when preceding key events are cancelled');
3 var targetRoot
= document
.createElement("div");
4 targetRoot
.innerHTML
+= "<input type='text' id='targetInput' />";
5 targetRoot
.innerHTML
+= "<textarea id='targetTextarea'></textarea>";
6 targetRoot
.innerHTML
+= "<div id='targetEditable' contentEditable></div>";
7 document
.body
.appendChild(targetRoot
);
9 var targetInput
= document
.getElementById("targetInput");
10 var targetTextarea
= document
.getElementById("targetTextarea");
11 var targetEditable
= document
.getElementById("targetEditable");
13 var receivedEventTarget
= null;
15 function handleTextInput(evt
)
17 receivedEventTarget
= evt
.target
;
20 var shouldCancel
= false;
22 function mayCancel(evt
)
28 targetInput
.addEventListener("textInput", handleTextInput
);
29 targetInput
.addEventListener("keydown", mayCancel
);
30 targetTextarea
.addEventListener("textInput", handleTextInput
);
31 targetTextarea
.addEventListener("keydown", mayCancel
);
32 targetEditable
.addEventListener("textInput", handleTextInput
);
33 targetEditable
.addEventListener("keydown", mayCancel
);
35 function setup(tocancel
)
37 receivedEventTarget
= null;
38 shouldCancel
= tocancel
;
41 function test(targetNode
)
43 window
.targetNode
= targetNode
;
45 eventSender
.keyDown("a");
46 shouldBe("window.targetNode", "receivedEventTarget");
48 eventSender
.keyDown("a");
49 shouldBe("null", "receivedEventTarget");
55 targetTextarea
.focus();
58 window
.getSelection().setBaseAndExtent(targetEditable
, 0, targetEditable
, 0);
61 targetRoot
.style
.display
= "none";