Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / onchange-setvalue.html
blobb8ab0e0beda0b6108404cc3dd15f2d469bf69e9f
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <body>
5 <div id="test">
6 <input type="text">
7 <textarea type="text"></textarea>
8 </div>
9 <div id="console"></div>
10 </body>
11 <script>
13 if (window.testRunner)
14 testRunner.dumpAsText();
16 var events = [];
18 var UPPER_CASE_T_KEY_CODE = 84;
19 var LOWER_CASE_T_CHAR_CODE = 116;
21 function keyListener(event)
23 if (event.keyCode == UPPER_CASE_T_KEY_CODE || event.keyCode == LOWER_CASE_T_CHAR_CODE)
24 event.preventDefault();
25 event.target.value = event.target.value.replace('t', '');
28 function changeListener(event)
30 events.push(event.type + ' ' + event.target.value);
33 function sendKeysForString(target, str)
35 for (var i = 0; i < str.length; i++) {
36 target.focus();
37 eventSender.keyDown(str[i]);
38 target.blur();
42 // Replace value on keyup.
43 var inputElement = document.body.getElementsByTagName('input')[0];
44 inputElement.addEventListener('keyup', keyListener, false);
45 inputElement.addEventListener('change', changeListener, false);
47 if (window.eventSender)
48 sendKeysForString(inputElement, 'test');
50 shouldBe("events.length", "2");
51 shouldBe("events[0]", "'change e'");
52 shouldBe("events[1]", "'change es'");
54 var textAreaElement = document.body.getElementsByTagName('textarea')[0];
55 textAreaElement.addEventListener('keyup', keyListener, false);
56 textAreaElement.addEventListener('change', changeListener, false);
57 events.length = 0;
59 if (window.eventSender)
60 sendKeysForString(textAreaElement, 'atttbttc');
62 shouldBe("events.length", "3");
63 shouldBe("events[0]", "'change a'");
64 shouldBe("events[1]", "'change ab'");
65 shouldBe("events[2]", "'change abc'");
68 // Prevent default on keydown.
69 inputElement.removeEventListener('keyup', keyListener, false);
70 inputElement.addEventListener('keydown', keyListener, false);
71 inputElement.value = '';
72 events.length = 0;
74 if (window.eventSender)
75 sendKeysForString(inputElement, 'test');
77 shouldBe("events.length", "2");
78 shouldBe("events[0]", "'change e'");
79 shouldBe("events[1]", "'change es'");
82 // Prevent default on keypress.
83 inputElement.removeEventListener('keydown', keyListener, false);
84 inputElement.addEventListener('keypress', keyListener, false);
85 inputElement.value = '';
86 events.length = 0;
88 if (window.eventSender)
89 sendKeysForString(inputElement, 'test');
91 shouldBe("events.length", "2");
92 shouldBe("events[0]", "'change e'");
93 shouldBe("events[1]", "'change es'");
95 // Hide test elements after run to avoid whitespace differences across platforms in the results.
96 document.getElementById('test').style.display = 'none';
97 </script>
98 </html>