Title: [253120] trunk/LayoutTests
Revision
253120
Author
[email protected]
Date
2019-12-04 13:50:14 -0800 (Wed, 04 Dec 2019)

Log Message

Adopt UIHelper in a few more layout tests in fast/events
https://bugs.webkit.org/show_bug.cgi?id=204855

Reviewed by Darin Adler.

Fixes and cleans up some more layout tests; see below for details.

* fast/events/ios/touch-events-during-scroll-deceleration-in-overflow.html:

Use async-await here, as well as UIHelper.dragFromPointToPoint.

* fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt:
* fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html:

This test sometimes times out when run in rapid succession, due to touches being dispatched while the test is
finishing. Fix this (and also simplify the test) by using UIHelper instead to synthesize taps, and only finish
the layout test after the expected number of clicks have been observed and all tap gestures have been sent.

* fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt:
* fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html:

This test currently fails due to finishing too early, before the touchend event is observed; fix this by waiting
for touchend events before finishing the test.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253119 => 253120)


--- trunk/LayoutTests/ChangeLog	2019-12-04 20:28:08 UTC (rev 253119)
+++ trunk/LayoutTests/ChangeLog	2019-12-04 21:50:14 UTC (rev 253120)
@@ -1,3 +1,29 @@
+2019-12-04  Wenson Hsieh  <[email protected]>
+
+        Adopt UIHelper in a few more layout tests in fast/events
+        https://bugs.webkit.org/show_bug.cgi?id=204855
+
+        Reviewed by Darin Adler.
+
+        Fixes and cleans up some more layout tests; see below for details.
+
+        * fast/events/ios/touch-events-during-scroll-deceleration-in-overflow.html:
+
+        Use async-await here, as well as UIHelper.dragFromPointToPoint.
+
+        * fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt:
+        * fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html:
+
+        This test sometimes times out when run in rapid succession, due to touches being dispatched while the test is
+        finishing. Fix this (and also simplify the test) by using UIHelper instead to synthesize taps, and only finish
+        the layout test after the expected number of clicks have been observed and all tap gestures have been sent.
+
+        * fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt:
+        * fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html:
+
+        This test currently fails due to finishing too early, before the touchend event is observed; fix this by waiting
+        for touchend events before finishing the test.
+
 2019-12-04  Yusuke Suzuki  <[email protected]>
 
         imported/w3c/web-platform-tests/wasm/jsapi/interface.any.worker.html is a flakey failure, WebAssembly.Global is not implemented

Modified: trunk/LayoutTests/fast/events/ios/touch-events-during-scroll-deceleration-in-overflow.html (253119 => 253120)


--- trunk/LayoutTests/fast/events/ios/touch-events-during-scroll-deceleration-in-overflow.html	2019-12-04 20:28:08 UTC (rev 253119)
+++ trunk/LayoutTests/fast/events/ios/touch-events-during-scroll-deceleration-in-overflow.html	2019-12-04 21:50:14 UTC (rev 253120)
@@ -2,6 +2,7 @@
 <head>
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <script src=""
+    <script src=""
     <style>
         body {
             width: 100%;
@@ -58,15 +59,6 @@
     documentTouches.textContent = `${documentTouchstartEventCount}`;
 });
 
-function getSwipeUIScript(fromX, fromY, toX, toY, duration)
-{
-    return `(() => {
-        uiController.dragFromPointToPoint(${fromX}, ${fromY}, ${toX}, ${toY}, ${duration}, () => {
-            uiController.uiScriptComplete("");
-        });
-    })();`;
-}
-
 function expectTouchCountsToBe(containerCount, documentCount)
 {
     shouldBeEqualToString("document.getElementById('containerTouches').textContent", `${containerCount}`);
@@ -73,18 +65,18 @@
     shouldBeEqualToString("document.getElementById('documentTouches').textContent", `${documentCount}`);
 }
 
+jsTestIsAsync = true;
+
 if (window.testRunner && testRunner.runUIScript) {
     testRunner.dumpAsText();
-    jsTestIsAsync = true;
-    testRunner.runUIScript(getSwipeUIScript(100, 250, 100, 50, 0.1), () => {
-        shouldBecomeDifferent("document.getElementById('container').scrollTop", "0", () => {
-            expectTouchCountsToBe(1, 1);
-            UIHelper.tapAt(100, 350).then(() => {
-                expectTouchCountsToBe(1, 2);
-                finishJSTest();
-            });
-        });
-    });
+    (async () => {
+        await UIHelper.dragFromPointToPoint(100, 250, 100, 50, 0.1);
+        await new Promise(resolve => shouldBecomeDifferent("document.getElementById('container').scrollTop", "0", resolve));
+        expectTouchCountsToBe(1, 1);
+        await UIHelper.activateAt(100, 350);
+        expectTouchCountsToBe(1, 2);
+        finishJSTest();
+    })();
 }
 </script>
 <script src=""

Modified: trunk/LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt (253119 => 253120)


--- trunk/LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt	2019-12-04 20:28:08 UTC (rev 253119)
+++ trunk/LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt	2019-12-04 21:50:14 UTC (rev 253120)
@@ -1,12 +1,8 @@
+PASS Dispatched three clicks.
 PASS successfullyParsed is true
 
 TEST COMPLETE
 
-Repeatedly tapping on the button should fire click events.
+This test verifies that repeatedly tapping a button when the viewport is at initial scale dispatches click events instead of only causing the user to zoom. To manually run the test, tap the button several quickly; the button should be clicked multiple times, without waiting for a ~300 ms delay between each tap.
 
-This test is best run in WebKitTestRunner. If you are running this test manually, verify that tapping the button causes a "Click!" message to appear below, and that click occurred without the regular 350ms delay for double tapping.
-
-Click!
-Click!
-Click!
-
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html (253119 => 253120)


--- trunk/LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html	2019-12-04 20:28:08 UTC (rev 253119)
+++ trunk/LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html	2019-12-04 21:50:14 UTC (rev 253120)
@@ -5,45 +5,27 @@
 
 <head>
     <script src=""
-    <script id="ui-script" type="text/plain">
-        (function() {
-            var count = 0;
-            function fireSuccessiveTaps() {
-                if (count < 3)
-                    uiController.singleTapAtPoint(200, 200, fireSuccessiveTaps);
-                else
-                    uiController.uiScriptComplete("");
+    <script src=""
+    <script>
+    clickCount = 0;
+    jsTestIsAsync = true;
 
-                count++;
-            }
-            fireSuccessiveTaps();
-        })();
-    </script>
+    async function runTest() {
+        description("This test verifies that repeatedly tapping a button when the viewport is at initial scale dispatches click events instead of only causing the user to zoom. To manually run the test, tap the button several quickly; the button should be clicked multiple times, without waiting for a ~300 ms delay between each tap.");
 
-    <script>
-    var scriptCompleted = false;
-    var clickCount = 0;
-    if (window.testRunner)
-        testRunner.waitUntilDone();
+        if (!testRunner.runUIScript)
+            return;
 
-    function getUIScript() {
-        return document.getElementById("ui-script").text;
+        const target = document.querySelector("button");
+        while (clickCount < 3)
+            await UIHelper.activateElement(target);
+
+        testPassed("Dispatched three clicks.");
+        finishJSTest();
     }
 
-    function runTest() {
-        if (testRunner.runUIScript)
-            testRunner.runUIScript(getUIScript(), function(result) {
-                scriptCompleted = true;
-                if (clickCount == 3)
-                    testRunner.notifyDone();
-            });
-    }
-    function handleClicked() {
+    function handleClick() {
         clickCount++;
-        document.body.appendChild(document.createTextNode("Click!"));
-        document.body.appendChild(document.createElement("br"));
-        if (clickCount == 3 && scriptCompleted)
-            testRunner.notifyDone();
     }
     </script>
 
@@ -52,17 +34,16 @@
         margin: 0;
     }
 
-    #target {
-        width: 400px;
-        height: 400px;
+    button {
+        width: 100%;
+        height: 100px;
     }
     </style>
 </head>
 
 <body _onload_="runTest()">
-    <button id="target" _onclick_="handleClicked()"></button>
-    <p>Repeatedly tapping on the button should fire click events.</p>
-    <p>This test is best run in WebKitTestRunner. If you are running this test manually, verify that tapping the button causes a "Click!" message to appear below, and that click occurred without the regular 350ms delay for double tapping.</p>
+    <button _onclick_="handleClick()"></button>
+    <p id="description"></p>
     <script src=""
 </body>
 

Modified: trunk/LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt (253119 => 253120)


--- trunk/LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt	2019-12-04 20:28:08 UTC (rev 253119)
+++ trunk/LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt	2019-12-04 21:50:14 UTC (rev 253120)
@@ -1,13 +1,22 @@
-touchstart on body - cancelable: true defaultPrevented: true 
-touchstart on documentElement - cancelable: true defaultPrevented: true 
-touchstart on document - cancelable: true defaultPrevented: true 
-touchstart on window - cancelable: true defaultPrevented: true 
-touchmove on body - cancelable: true defaultPrevented: true 
-touchmove on documentElement - cancelable: true defaultPrevented: true 
-touchmove on document - cancelable: true defaultPrevented: true 
-touchmove on window - cancelable: true defaultPrevented: true 
-touchend on body - cancelable: true defaultPrevented: true 
-touchend on documentElement - cancelable: true defaultPrevented: true 
-touchend on document - cancelable: true defaultPrevented: true 
-touchend on window - cancelable: true defaultPrevented: true 
-Done
+This test verifies that active touchstart and touchend event listeners can be added to document, window, documentElement, and body. This test requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS touchstart on body - cancelable: true defaultPrevented: true
+PASS touchstart on documentElement - cancelable: true defaultPrevented: true
+PASS touchstart on document - cancelable: true defaultPrevented: true
+PASS touchstart on window - cancelable: true defaultPrevented: true
+PASS touchmove on body - cancelable: true defaultPrevented: true
+PASS touchmove on documentElement - cancelable: true defaultPrevented: true
+PASS touchmove on document - cancelable: true defaultPrevented: true
+PASS touchmove on window - cancelable: true defaultPrevented: true
+PASS touchend on body - cancelable: true defaultPrevented: true
+PASS touchend on documentElement - cancelable: true defaultPrevented: true
+PASS touchend on document - cancelable: true defaultPrevented: true
+PASS touchend on window - cancelable: true defaultPrevented: true
+PASS touchEndEventCount became 4
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test requires UIScriptController to run.

Modified: trunk/LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html (253119 => 253120)


--- trunk/LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html	2019-12-04 20:28:08 UTC (rev 253119)
+++ trunk/LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html	2019-12-04 21:50:14 UTC (rev 253120)
@@ -1,65 +1,58 @@
+<script src=""
+<script src=""
 <script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-}
+jsTestIsAsync = true;
+touchEndEventCount = 0;
 
-function getUIScript()
+async function runTest()
 {
-    return `
-    (function() {
-        uiController.dragFromPointToPoint(50, 250, 50, 30, 0.1, function() {
-            uiController.uiScriptComplete("Done");
-        });
-    })();`
-}
-
-function runTest()
-{
     let output = "";
     window.addEventListener("touchstart", function(event) {
         event.preventDefault();
-        output += `touchstart on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchstart on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false });
 
     window.addEventListener("touchmove", function(event) {
         event.preventDefault();
-        output += `touchmove on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchmove on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false, "once": true });
 
     window.addEventListener("touchend", function(event) {
         event.preventDefault();
-        output += `touchend on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchend on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
+        touchEndEventCount++;
     }, { "passive": false });
 
     document.addEventListener("touchstart", function(event) {
         event.preventDefault();
-        output += `touchstart on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchstart on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false });
 
     document.addEventListener("touchmove", function(event) {
         event.preventDefault();
-        output += `touchmove on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchmove on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false, "once": true });
 
     document.addEventListener("touchend", function(event) {
         event.preventDefault();
-        output += `touchend on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchend on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
+        touchEndEventCount++;
     }, { "passive": false });
 
     document.documentElement.addEventListener("touchstart", function(event) {
         event.preventDefault();
-        output += `touchstart on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchstart on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false });
 
     document.documentElement.addEventListener("touchmove", function(event) {
         event.preventDefault();
-        output += `touchmove on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchmove on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false, "once": true });
 
     document.documentElement.addEventListener("touchend", function(event) {
         event.preventDefault();
-        output += `touchend on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchend on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
+        touchEndEventCount++;
     }, { "passive": false });
 
     let body = document.querySelector("body");
@@ -66,25 +59,25 @@
 
     body.addEventListener("touchstart", function(event) {
         event.preventDefault();
-        output += `touchstart on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchstart on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false });
 
     body.addEventListener("touchmove", function(event) {
         event.preventDefault();
-        output += `touchmove on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchmove on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
     }, { "passive": false, "once": true });
 
     body.addEventListener("touchend", function(event) {
         event.preventDefault();
-        output += `touchend on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`;
+        testPassed(`touchend on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented}`);
+        touchEndEventCount++;
     }, { "passive": false });
 
-    if (testRunner.runUIScript) {
-        testRunner.runUIScript(getUIScript(), function(result) {
-            output += result;
-            document.getElementById("output").innerHTML = output;
-            testRunner.notifyDone();
-        });
+    if (window.testRunner && testRunner.runUIScript) {
+        description("This test verifies that active touchstart and touchend event listeners can be added to document, window, documentElement, and body. This test requires WebKitTestRunner.");
+        await UIHelper.dragFromPointToPoint(50, 250, 50, 30, 0.1);
+        await new Promise(resolve => shouldBecomeEqual("touchEndEventCount", "4", resolve));
+        finishJSTest();
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to