Layout Test fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html is a Flaky Failure
https://bugs.webkit.org/show_bug.cgi?id=202867
<rdar://52968736>

Reviewed by Wenson Hsieh.

From the failing results, it looks like the event listener for touchend was firing
after the uiScriptController returned its result, which is strange.
I was unable to reproduce this, so I rewrote the test to use UIHelper, which
hopefully will improve the situation (although... is basically the same code).

* fast/events/touch/ios/tap-with-passive-listener-inside-active-listener-expected.txt:
* fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251026 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5c15fc1..5eedb46 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2019-10-11  Dean Jackson  <dino@apple.com>
+
+        Layout Test fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html is a Flaky Failure
+        https://bugs.webkit.org/show_bug.cgi?id=202867
+        <rdar://52968736>
+
+        Reviewed by Wenson Hsieh.
+
+        From the failing results, it looks like the event listener for touchend was firing
+        after the uiScriptController returned its result, which is strange.
+        I was unable to reproduce this, so I rewrote the test to use UIHelper, which
+        hopefully will improve the situation (although... is basically the same code).
+
+        * fast/events/touch/ios/tap-with-passive-listener-inside-active-listener-expected.txt:
+        * fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html:
+
 2019-10-10  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Local Resource Overrides: UI for overriding image and font resource content
diff --git a/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener-expected.txt b/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener-expected.txt
index 8da0466..8deabd7 100644
--- a/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener-expected.txt
+++ b/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener-expected.txt
@@ -6,7 +6,7 @@
 Listener target1 received cancelable event touchend targetting eventTarget1
 defaultPrevented before preventDefault(): false
 defaultPrevented after preventDefault(): true
-Done
+
 Tap on Target2 (red)
 
 Listener target1 received cancelable event touchstart targetting eventTarget2 at 150, 50
@@ -15,7 +15,7 @@
 Listener target1 received cancelable event touchend targetting eventTarget2
 defaultPrevented before preventDefault(): false
 defaultPrevented after preventDefault(): true
-Done
+
 Tap on Target3 (blue)
 
 Listener target3 received cancelable event touchstart targetting eventTarget3 at 250, 50
diff --git a/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html b/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html
index ccc9a50..1ee7ed7 100644
--- a/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html
+++ b/LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html
@@ -2,23 +2,14 @@
 
 <html>
 <head>
+    <script src="../../../../resources/ui-helper.js"></script>
     <script>
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.waitUntilDone();
         }
 
-        function getUIScript(x, y)
-        {
-            return `
-            (function() {
-                uiController.singleTapAtPoint(${x}, ${y}, function() {
-                    uiController.uiScriptComplete("Done");
-                });
-            })();`
-        }
-
-        function runTest()
+        async function runTest()
         {
             if (!testRunner.runUIScript)
                 return;
@@ -61,18 +52,16 @@
             target3.addEventListener('touchcancel', getLogEvent("target3"), { 'passive': true });
 
             output += "<h1>Tap on Target1 (green)</h1>";
-            testRunner.runUIScript(getUIScript(50, 50), function(result) {
-                output += result;
-                output += "<h1>Tap on Target2 (red)</h1>";
-                testRunner.runUIScript(getUIScript(150, 50), function(result) {
-                    output += result;
-                    output += "<h1>Tap on Target3 (blue)</h1>";
-                    testRunner.runUIScript(getUIScript(250, 50), function(result) {
-                        document.getElementById('output').innerHTML = output;
-                        testRunner.notifyDone();
-                    });
-                });
-            });
+            await UIHelper.tapAt(50, 50);
+
+            output += "<br><h1>Tap on Target2 (red)</h1>";
+            await UIHelper.tapAt(150, 50);
+
+            output += "<br><h1>Tap on Target3 (blue)</h1>";
+            await UIHelper.tapAt(250, 50);
+
+            document.getElementById('output').innerHTML = output;
+            testRunner.notifyDone();
         }
 
         window.addEventListener('load', runTest, false);