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 function focusAndPressSpace() |
| 31 { |
| 32 document.getElementById('txt').focus(); |
| 33 // Leave some space for pageUp |
| 34 document.scrollingElement.scrollTop = window.innerHeight / 2; |
| 35 |
| 36 eventSender.keyDown("pageUp", []); |
| 37 // Space key shouldn't cancel pageUp |
| 38 eventSender.keyDown(" ", []); |
| 39 |
| 40 // pageUp should finish |
| 41 shouldBecomeEqual("document.scrollingElement.scrollTop", "0", finishJSTest); |
| 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 |