Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / focus-change-on-keypress.html
blob4b124efa900344b452ed2ab2c52948293f90671b
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>This tests changing the focus on keypress event. The character typed by user should be inserted into input. This test only runs in DRT.</p>
5 <pre><script>
7 function runTest(name, shouldChangeSelection) {
8 var dummy = document.createElement('input');
9 document.body.appendChild(dummy);
11 var element = document.createElement(name);
12 document.body.appendChild(element);
13 element.addEventListener('keypress', function() {
14 if (element.value.length >= 2)
15 dummy.focus();
18 document.writeln(name + (shouldChangeSelection ? ' with selectionchange' : ' without selectionchange'));
20 element.focus();
21 eventSender.keyDown('a');
22 eventSender.leapForward(100);
23 eventSender.keyDown(name == 'textarea' ? '\n' : 'b');
24 eventSender.leapForward(100);
25 if (shouldChangeSelection) {
26 element.selectionStart = 1;
27 element.selectionEnd = 1;
29 eventSender.keyDown('c');
30 eventSender.leapForward(100);
32 var expected = null;
33 if (name == 'textarea')
34 expected = shouldChangeSelection ? 'ac\n' : 'a\nc';
35 else
36 expected = shouldChangeSelection ? 'acb' : 'abc';
38 if (element.value == expected)
39 document.writeln('PASS');
40 else
41 document.writeln('FAIL: value was "' + element.value + '" but expected "' + expected + '"');
42 document.writeln();
45 if (window.testRunner && window.eventSender) {
46 testRunner.dumpAsText();
48 runTest('input', false);
49 runTest('input', true);
50 runTest('textarea', false);
51 runTest('textarea', true);
53 document.writeln('DONE');
56 </script></pre>
57 </body>
58 </html>