Index: third_party/WebKit/LayoutTests/fast/events/space-scroll-textinput-canceled.html |
diff --git a/third_party/WebKit/LayoutTests/fast/events/space-scroll-textinput-canceled.html b/third_party/WebKit/LayoutTests/fast/events/space-scroll-textinput-canceled.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..84ca7464a76a48346d8780923c6c604937604469 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/events/space-scroll-textinput-canceled.html |
@@ -0,0 +1,55 @@ |
+<!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> |