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..37479532635e4c13a3cae40414c13fb02748438d |
--- /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); |
+ |
+var scrolled = false; |
+document.addEventListener('scroll', function(e) {scrolled = true;}, false); |
+ |
+function focusAndPressSpace() |
+{ |
+ document.getElementById('txt').focus(); |
+ eventSender.keyDown(" ", []); |
+ // Wait for scroll |
+ setTimeout(function() { |
+ shouldBeFalse('scrolled'); |
+ finishJSTest(); |
+ }, 10); |
dtapuska
2016/02/08 13:50:07
Is this reliable? Should we instead register for a
|
+} |
+ |
+jsTestIsAsync = true; |
+ |
+function runTest() |
+{ |
+ if (window.eventSender) { |
+ focusAndPressSpace(); |
+ } |
+} |
+</script> |
+ |
+</body> |
+</html> |