blob: b4e6523bd984358770e946e26244968cd0becd4b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style type="text/css">
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
</style>
</head>
<body style="margin:0" onload="runTest();">
<p>
Tests that page shouldn't scroll when you hit space key on input field
and 'textInput' event was canceled.
</p>
<div id="console"></div>
<input type="text" id="txt" />
<div style="height: 2000px;"></div>
<script type="text/javascript">
var txt = document.getElementById('txt');
txt.addEventListener('textInput', function(e) {
if (e.data === ' ') {
e.preventDefault();
}
}, false);
function focusAndPressSpace()
{
document.getElementById('txt').focus();
// Leave some space for PageUp
document.scrollingElement.scrollTop = window.innerHeight / 2;
eventSender.keyDown("PageUp", []);
// Space key shouldn't cancel PageUp
eventSender.keyDown(" ", []);
// PageUp should finish
shouldBecomeEqual("document.scrollingElement.scrollTop", "0", finishJSTest);
}
jsTestIsAsync = true;
function runTest()
{
if (window.eventSender) {
focusAndPressSpace();
}
}
</script>
</body>
</html>