Add a test to ensure that preventDefault on touchmove prevents scrolling
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 19:09:23 +0000 (19:09 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 19:09:23 +0000 (19:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166790

Reviewed by Simon Fraser.

* fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling-expected.txt: Added.
* fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210516 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling.html [new file with mode: 0644]

index eee6a36..c1d660f 100644 (file)
@@ -1,3 +1,13 @@
+2017-01-09  Beth Dakin  <bdakin@apple.com>
+
+        Add a test to ensure that preventDefault on touchmove prevents scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=166790
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling-expected.txt: Added.
+        * fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling.html: Added.
+
 2017-01-09  Ryan Haddad  <ryanhaddad@apple.com>
 
         Rebaseline W3C test for ios-simulator after r210468.
diff --git a/LayoutTests/fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling-expected.txt b/LayoutTests/fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling-expected.txt
new file mode 100644 (file)
index 0000000..2b6ea59
--- /dev/null
@@ -0,0 +1,10 @@
+Test that preventing default on touchmove will prevent scrolling in overflow:scroll.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById('scroller').scrollTop is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling.html b/LayoutTests/fast/events/touch/ios/iphone7/prevent-default-touchmove-prevents-scrolling.html
new file mode 100644 (file)
index 0000000..48841fa
--- /dev/null
@@ -0,0 +1,99 @@
+<html >
+<head>
+<script src="../../../../../resources/js-test-pre.js"></script>
+<style>
+#scroller {
+    border: 2px solid black;
+    height: 400px;
+    overflow: scroll;
+    position: absolute;
+}
+        
+#big {
+    width: 50px;
+    height: 2000px;
+    background-color: purple;
+    border: 15px solid green;
+}
+</style>
+</head>
+
+<body>
+<div id="scroller">
+    <div id="big"></div>
+</div>
+
+<script>
+description("Test that preventing default on touchmove will prevent scrolling in overflow:scroll.");
+window.jsTestIsAsync = true;
+
+function getUIScript(startX, startY, endX, endY)
+{
+    return `
+    (function() {
+     var eventStream = {
+     events : [
+        {
+        interpolate : "linear",
+        timestep: 0.025,
+        startEvent : {
+        inputType : "hand",
+        timeOffset : 0,
+        touches : [
+            {
+            inputType : "finger",
+            phase : "began",
+            id : 1,
+            x : ${startX},
+            y : ${startY},
+            pressure : 0
+            }
+        ]
+        },
+        endEvent : {
+        inputType : "hand",
+        timeOffset : 3.0,
+        touches : [
+            {
+            inputType : "finger",
+            phase : "stationary",
+            id : 1,
+            x : ${endX},
+            y : ${endY},
+            pressure : 500
+            }
+        ]
+        }
+    }
+    ]
+    };
+     
+    uiController.sendEventStream(JSON.stringify(eventStream), function() {
+        uiController.uiScriptComplete();
+    });
+    })();`
+}
+
+function runTest()
+{
+    function touchmoveEventHandler(event) {
+        event.preventDefault();
+    }
+
+    let eventTarget = document.getElementById("scroller");
+    eventTarget.addEventListener("touchmove", touchmoveEventHandler);
+    let clientRect = eventTarget.getBoundingClientRect();
+    
+    if (window.testRunner) {
+        testRunner.runUIScript(getUIScript(clientRect.left + 10, clientRect.top + 200, clientRect.left + 10, clientRect.top + 10), function(result) {
+                            shouldBe("document.getElementById('scroller').scrollTop", "0");
+                            finishJSTest();
+                               });
+    }
+}
+
+window.addEventListener('load', runTest, false);
+</script>
+<script src="../../../../../resources/js-test-post.js"></script>
+</body>
+</html>