5 <script type=
"text/javascript" charset=
"utf-8">
6 if (window.testRunner) {
7 testRunner.dumpAsText();
8 testRunner.waitUntilDone();
11 function sendKey(element, key) {
12 if (window.testRunner) {
13 key = key.substr(
0,
1).toLowerCase() + key.substr(
1); // lowercase
1st letter for eventSender
14 eventSender.keyDown(key);
16 // Note that initKeyboardEvent is broken:
17 // https://bugs.webkit.org/show_bug.cgi?id=
16735
18 var event = document.createEvent(
"KeyboardEvents");
19 event.initKeyboardEvent(
"keydown", true, true, document.defaultView, key,
0,
20 false, false, false, false, false);
21 element.dispatchEvent(event);
25 function changeStyle()
27 var testInput = document.getElementById('input');
30 sendKey(testInput, 'b');
31 sendKey(testInput, 'e');
32 sendKey(testInput, 'f');
33 sendKey(testInput, 'o');
34 sendKey(testInput, 'r');
35 sendKey(testInput, 'e');
37 // make a layout happen
38 var containerDiv = document.getElementById('container')
39 containerDiv.style.display = 'inline';
41 window.setTimeout(function() {
42 sendKey(testInput, 'a');
43 sendKey(testInput, 'f');
44 sendKey(testInput, 't');
45 sendKey(testInput, 'e');
46 sendKey(testInput, 'r');
48 document.getElementById('result').innerText = testInput.value;
49 if (window.testRunner)
50 testRunner.notifyDone();
54 window.addEventListener('load', changeStyle, false);
58 <p>This test only works in DRT. You should see 'beforeafter' in the text field.
</p>
60 <input id=
"input" type=
"text" value=
"">
63 <div id=
"result"></div>