OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 <style type="text/css"> | |
6 ::-webkit-scrollbar { | |
7 width: 0px; | |
8 height: 0px; | |
9 } | |
10 </style> | |
11 </head> | |
12 <body style="margin:0" onload="runTest();"> | |
13 <p> | |
14 Tests that page shouldn't scroll when you hit space key on input field | |
15 and 'textInput' event was canceled. | |
16 </p> | |
17 <div id="console"></div> | |
18 | |
19 <input type="text" id="txt" /> | |
20 <div style="height: 2000px;"></div> | |
21 | |
22 <script type="text/javascript"> | |
23 var txt = document.getElementById('txt'); | |
24 txt.addEventListener('textInput', function(e) { | |
25 if (e.data === ' ') { | |
26 e.preventDefault(); | |
27 } | |
28 }, false); | |
29 | |
30 var scrolled = false; | |
31 document.addEventListener('scroll', function(e) {scrolled = true;}, false); | |
32 | |
33 function focusAndPressSpace() | |
34 { | |
35 document.getElementById('txt').focus(); | |
36 eventSender.keyDown(" ", []); | |
37 // Wait for scroll | |
38 setTimeout(function() { | |
39 shouldBeFalse('scrolled'); | |
40 finishJSTest(); | |
41 }, 10); | |
dtapuska
2016/02/08 13:50:07
Is this reliable? Should we instead register for a
| |
42 } | |
43 | |
44 jsTestIsAsync = true; | |
45 | |
46 function runTest() | |
47 { | |
48 if (window.eventSender) { | |
49 focusAndPressSpace(); | |
50 } | |
51 } | |
52 </script> | |
53 | |
54 </body> | |
55 </html> | |
OLD | NEW |