Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / restore-selection-after-layout.html
blobb5b2f650a5f7e6d2bb2a7bac684f68a4edc1eba8
1 <!DOCTYPE html>
3 <html>
4 <head>
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);
15 } else {
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');
28 testInput.focus();
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();
51 }, 0);
54 window.addEventListener('load', changeStyle, false);
55 </script>
56 </head>
57 <body>
58 <p>This test only works in DRT. You should see 'beforeafter' in the text field.</p>
59 <div id="container">
60 <input id="input" type="text" value="">
61 </div>
63 <div id="result"></div>
64 </body>
65 </html>