REGRESSION(r147602): Search text field doesn't render selection when it has some...
[WebKit-https.git] / ManualTests / style-keypress-events.html
1 <body onload="setup()">
2 <p>cmd+b and cmd+i should generate a keydown event in contentEditable fields.  Also, calling
3 preventDefault() in the keydown event should cancel the text styling.</p>
4
5 <div contentEditable id="test" style="border: 1px solid; padding: 4px;">
6 This is some sample text.<br><br><br><br>
7 </div>
8 <div>
9 <input type="checkbox" id="disable"><label for="disable">preventDefault() in keydown</label>
10 </div>
11 <div id="log"></div>
12
13 <script>
14 function setup()
15 {
16     var test = document.getElementById("test");
17     test.addEventListener("keydown", keydown, false);
18
19     var selection = window.getSelection();
20     selection.setPosition(test, 0);
21     selection.modify("extend", "forward", "sentence");
22     test.focus();
23 }
24
25 function log(msg)
26 {
27     var log = document.getElementById("log");
28     log.innerHTML += "<br>" + msg;
29 }
30
31 function keydown(event)
32 {
33     log("keydown");
34     if (document.getElementById("disable").checked)
35         event.preventDefault();
36 }
37 </script>
38 </body>