Two fast/scrolling/ios/touch-scroll* tests failing in iOS 13
https://bugs.webkit.org/show_bug.cgi?id=203070
rdar://problem/51756254

Reviewed by Wenson Hsieh.

For some reason the uiController.dragFromPointToPoint() in these tests was too long
to trigger scrolling (maybe an OS change). Fix them to use UIHelper and a shorter
duration, and also to not be sensitive to the exact distance scrolled.

* fast/scrolling/ios/touch-scroll-pointer-events-none-expected.txt:
* fast/scrolling/ios/touch-scroll-pointer-events-none.html:
* fast/scrolling/ios/touch-scroll-visibility-hidden-expected.txt:
* fast/scrolling/ios/touch-scroll-visibility-hidden.html:
* platform/ios-wk2/TestExpectations:
* resources/ui-helper.js:
(window.UIHelper.dragFromPointToPoint):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251242 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 170ffca..0273202 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,25 @@
 2019-10-17  Simon Fraser  <simon.fraser@apple.com>
 
+        Two fast/scrolling/ios/touch-scroll* tests failing in iOS 13
+        https://bugs.webkit.org/show_bug.cgi?id=203070
+        rdar://problem/51756254
+
+        Reviewed by Wenson Hsieh.
+        
+        For some reason the uiController.dragFromPointToPoint() in these tests was too long
+        to trigger scrolling (maybe an OS change). Fix them to use UIHelper and a shorter
+        duration, and also to not be sensitive to the exact distance scrolled.
+
+        * fast/scrolling/ios/touch-scroll-pointer-events-none-expected.txt:
+        * fast/scrolling/ios/touch-scroll-pointer-events-none.html:
+        * fast/scrolling/ios/touch-scroll-visibility-hidden-expected.txt:
+        * fast/scrolling/ios/touch-scroll-visibility-hidden.html:
+        * platform/ios-wk2/TestExpectations:
+        * resources/ui-helper.js:
+        (window.UIHelper.dragFromPointToPoint):
+
+2019-10-17  Simon Fraser  <simon.fraser@apple.com>
+
         REGRESSION (r245483) [iPad Simulator] 2 Layout tests fast/scrolling/ios/overflow-scroll-inherited.html fast/scrolling/ios/overflow-scrolling-touch-enabled-stacking.html are failing
         https://bugs.webkit.org/show_bug.cgi?id=203069
         rdar://problem/51868813
diff --git a/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none-expected.txt b/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none-expected.txt
index b3e7774..1032839 100644
--- a/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none-expected.txt
+++ b/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none-expected.txt
@@ -2,7 +2,7 @@
 PASS scroller.scrollTop is 0
 swipe complete
 PASS scroller.scrollTop is 0
-PASS document.scrollingElement.scrollTop is 90
+PASS documentDidScroll is true
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none.html b/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none.html
index a47f69c..436e3dd 100644
--- a/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none.html
+++ b/LayoutTests/fast/scrolling/ios/touch-scroll-pointer-events-none.html
@@ -41,21 +41,13 @@
         }
     </style>
     <script src="../../../resources/js-test-pre.js"></script>
+    <script src="../../../resources/ui-helper.js"></script>
     <script>
         window.jsTestIsAsync = true;
 
-        function getUIScript()
-        {
-            return `
-            (function() {
-                uiController.dragFromPointToPoint(60, 200, 60, 100, 0.5, function() {
-                    uiController.uiScriptComplete("");
-                });
-            })();`
-        }
-
         var hitElement;
-        function runTest()
+        var documentDidScroll;
+        async function runTest()
         {
             hitElement = document.elementFromPoint(20, 20);
             shouldBeEqualToString("hitElement.id", "under-target");
@@ -63,16 +55,16 @@
             var scroller = document.getElementById('scroller');
             shouldBe("scroller.scrollTop", "0");
 
-            if (testRunner.runUIScript) {
-                testRunner.runUIScript(getUIScript(), function() {
-                    setTimeout(function() {
-                        debug("swipe complete");
-                        shouldBe("scroller.scrollTop", "0");
-                        shouldBe("document.scrollingElement.scrollTop", "90");
-                        finishJSTest();
-                    }, 0);
-                });
-            }
+            await UIHelper.callFunctionAndWaitForScrollToFinish(async () => {
+                await UIHelper.dragFromPointToPoint(60, 200, 60, 100, 0.25);
+            });
+
+            debug("swipe complete");
+            shouldBe("scroller.scrollTop", "0");
+            
+            documentDidScroll = document.scrollingElement.scrollTop > 0;
+            shouldBeTrue("documentDidScroll");
+            finishJSTest();
         }
         window.addEventListener('load', runTest, false);
     </script>
diff --git a/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden-expected.txt b/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden-expected.txt
index 6a48e53..bec09c7 100644
--- a/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden-expected.txt
+++ b/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden-expected.txt
@@ -2,7 +2,7 @@
 PASS scroller.scrollTop is 0
 swipe complete
 PASS scroller.scrollTop is 0
-PASS document.scrollingElement.scrollTop is 90
+PASS documentDidScroll is true
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden.html b/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden.html
index 9817be6..6d0ca9f 100644
--- a/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden.html
+++ b/LayoutTests/fast/scrolling/ios/touch-scroll-visibility-hidden.html
@@ -42,21 +42,13 @@
         }
     </style>
     <script src="../../../resources/js-test-pre.js"></script>
+    <script src="../../../resources/ui-helper.js"></script>
     <script>
         window.jsTestIsAsync = true;
 
-        function getUIScript()
-        {
-            return `
-            (function() {
-                uiController.dragFromPointToPoint(60, 200, 60, 100, 0.5, function() {
-                    uiController.uiScriptComplete("");
-                });
-            })();`
-        }
-
         var hitElement;
-        function runTest()
+        var documentDidScroll;
+        async function runTest()
         {
             hitElement = document.elementFromPoint(20, 20);
             shouldBeEqualToString("hitElement.id", "under-target");
@@ -64,16 +56,16 @@
             var scroller = document.getElementById('scroller');
             shouldBe("scroller.scrollTop", "0");
 
-            if (testRunner.runUIScript) {
-                testRunner.runUIScript(getUIScript(), function() {
-                    setTimeout(function() {
-                        debug("swipe complete");
-                        shouldBe("scroller.scrollTop", "0");
-                        shouldBe("document.scrollingElement.scrollTop", "90");
-                        finishJSTest();
-                    }, 0);
-                });
-            }
+            await UIHelper.callFunctionAndWaitForScrollToFinish(async () => {
+                await UIHelper.dragFromPointToPoint(60, 200, 60, 100, 0.25);
+            });
+
+            debug("swipe complete");
+            shouldBe("scroller.scrollTop", "0");
+            
+            documentDidScroll = document.scrollingElement.scrollTop > 0;
+            shouldBeTrue("documentDidScroll");
+            finishJSTest();
         }
         window.addEventListener('load', runTest, false);
     </script>
diff --git a/LayoutTests/platform/ios-wk2/TestExpectations b/LayoutTests/platform/ios-wk2/TestExpectations
index deb6edd..ac96437 100644
--- a/LayoutTests/platform/ios-wk2/TestExpectations
+++ b/LayoutTests/platform/ios-wk2/TestExpectations
@@ -1359,9 +1359,5 @@
 # problem with blur handling
 mathml/focus-event-handling.html [ Failure ]
 
-# <rdar://problem/51756254>REGRESSION (r244582-r244596) Layout tests fast/scrolling/ios/touch-scroll-visibility-hidden.html fast/scrolling/ios/touch-scroll-pointer-events-none.html are failing
-fast/scrolling/ios/touch-scroll-pointer-events-none.html [ Failure ]
-fast/scrolling/ios/touch-scroll-visibility-hidden.html [ Failure ]
 # <rdar://problem/52962272> fast/scrolling/ios/body-overflow-hidden.html is an Image failure
 fast/scrolling/ios/body-overflow-hidden.html [ Pass ImageOnlyFailure ]
-
diff --git a/LayoutTests/resources/ui-helper.js b/LayoutTests/resources/ui-helper.js
index a481de8..5af9744 100644
--- a/LayoutTests/resources/ui-helper.js
+++ b/LayoutTests/resources/ui-helper.js
@@ -1007,7 +1007,7 @@
         return new Promise(resolve => {
             testRunner.runUIScript(`(() => {
                 uiController.dragFromPointToPoint(${fromX}, ${fromY}, ${toX}, ${toY}, ${duration}, () => {
-                    uiController.uiScriptComplete("");
+                    uiController.uiScriptComplete();
                 });
             })();`, resolve);
         });