Title: [227992] trunk/LayoutTests
Revision
227992
Author
[email protected]
Date
2018-02-01 18:13:40 -0800 (Thu, 01 Feb 2018)

Log Message

Fix race-condition in fast/forms/ios/ipad/select-form-run-twice.html
https://bugs.webkit.org/show_bug.cgi?id=182370

Reviewed by Tim Horton.
        
There is the potential for multiple button clicks, due to looping function calls that can cause timed functions to 
still be running in the next test, causing crashes. Guarding against repeated clicks, and cancelling the timers should 
clean up this problem.

* fast/forms/ios/ipad/select-form-run-twice.html:
* fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227991 => 227992)


--- trunk/LayoutTests/ChangeLog	2018-02-02 00:54:43 UTC (rev 227991)
+++ trunk/LayoutTests/ChangeLog	2018-02-02 02:13:40 UTC (rev 227992)
@@ -1,3 +1,17 @@
+2018-02-01  Megan Gardner  <[email protected]>
+
+        Fix race-condition in fast/forms/ios/ipad/select-form-run-twice.html
+        https://bugs.webkit.org/show_bug.cgi?id=182370
+
+        Reviewed by Tim Horton.
+        
+        There is the potential for multiple button clicks, due to looping function calls that can cause timed functions to 
+        still be running in the next test, causing crashes. Guarding against repeated clicks, and cancelling the timers should 
+        clean up this problem.
+
+        * fast/forms/ios/ipad/select-form-run-twice.html:
+        * fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html:
+
 2018-02-01  Matt Lewis  <[email protected]>
 
         Skipped http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html on macOS WK2.

Modified: trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html (227991 => 227992)


--- trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html	2018-02-02 00:54:43 UTC (rev 227991)
+++ trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html	2018-02-02 02:13:40 UTC (rev 227992)
@@ -64,33 +64,60 @@
                 })();`
         }
 
+        var firstButtonIsClicked = false;
+        var finalButtonIsClicked = false;
+        var firstButtonTimeoutID;
+        var finalButtonTimeoutID;
+        
         function firstButtonClicked()
         {
-            document.getElementById('nextStep').textContent = 'PASS: hit testing found #nextButton after first select interaction';
-            var selectElement = document.getElementsByTagName('select')[0];
-            var point = getPointInsideElement(selectElement, 10, 10);
-            testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 5), function() {
-                document.getElementById('select-value2').textContent = selectElement.value;
-                    tryTapOnButton('finalTarget');
-            });
+            clearTimeout(firstButtonTimeoutID);
+            if (!firstButtonIsClicked) {
+                firstButtonIsClicked = true;
+                
+                document.getElementById('nextStep').textContent = 'PASS: hit testing found #nextButton after first select interaction';
+                var selectElement = document.getElementsByTagName('select')[0];
+                var point = getPointInsideElement(selectElement, 10, 10);
+                testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 5), function() {
+                    document.getElementById('select-value2').textContent = selectElement.value;
+                        tryTapOnFinalButton();
+                });
+            }
         }
     
         function finalButtonClicked()
         {
-            document.getElementById('result').textContent = 'PASS: hit testing found #finalTarget after select interaction';
-            if (window.testRunner)
-                testRunner.notifyDone();
+            clearTimeout(finalButtonTimeoutID);
+            if (!finalButtonIsClicked) {
+                finalButtonIsClicked = true;
+                document.getElementById('result').textContent = 'PASS: hit testing found #finalTarget after select interaction';
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }
         }
 
-        async function tryTapOnButton(target)
+        async function tryTapOnFirstButton()
         {
-            var point = getPointInsideElement(document.getElementById(target), 10, 10);
-            await tapAtPoint(point.x, point.y);
+            var firstPoint = getPointInsideElement(document.getElementById('firstTarget'), 10, 10);
+            await tapAtPoint(firstPoint.x, firstPoint.y);
             
             // We have to keep retrying, because the dimming view behind the popover animates out,
             // and we currently have no callback when that animation completes.
-            window.setTimeout(tryTapOnButton.bind(this, target), 100);
+            if (!firstButtonIsClicked)
+                firstButtonTimeoutID = window.setTimeout(tryTapOnFirstButton, 100);
         }
+    
+        async function tryTapOnFinalButton()
+        {
+            var finalPoint = getPointInsideElement(document.getElementById('finalTarget'), 10, 10);
+            await tapAtPoint(finalPoint.x, finalPoint.y);
+            
+            // We have to keep retrying, because the dimming view behind the popover animates out,
+            // and we currently have no callback when that animation completes.
+            if (!finalButtonIsClicked)
+                finalButtonTimeoutID = window.setTimeout(tryTapOnFinalButton, 100);
+        }
+    
 
         function doTest()
         {
@@ -105,7 +132,7 @@
                 var point = getPointInsideElement(selectElement, 10, 10);
                 testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 2), function() {
                     document.getElementById('select-value').textContent = selectElement.value;
-                    tryTapOnButton('firstTarget');
+                    tryTapOnFirstButton();
                 });
             });
         }

Modified: trunk/LayoutTests/fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html (227991 => 227992)


--- trunk/LayoutTests/fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html	2018-02-02 00:54:43 UTC (rev 227991)
+++ trunk/LayoutTests/fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html	2018-02-02 02:13:40 UTC (rev 227992)
@@ -30,20 +30,11 @@
         
     </style>
     <script src=""
+    <script src=""
     <script>
         if (window.testRunner)
             testRunner.waitUntilDone();
 
-        function getSingleTapUIScript(x, y)
-        {
-            return `
-                (function() {
-                    uiController.singleTapAtPoint(${x}, ${y}, function() {
-                        uiController.uiScriptComplete('');
-                    });
-                })();`
-        }
-
         function getScrollDownUIScript(x, y)
         {
             return `
@@ -74,22 +65,27 @@
         }
 
         var clicked = false;
+        var timeoutID;
         function buttonClicked()
         {
-            document.getElementById('result').textContent = 'PASS: hit testing found #target after select interaction';
-            if (window.testRunner)
-                testRunner.notifyDone();
+            window.clearTimeout(timeoutID);
+            if (!clicked) {
+                clicked = true;
+                document.getElementById('result').textContent = 'PASS: hit testing found #target after select interaction';
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }
         }
 
-        function tryTapOnButton()
+        async function tryTapOnButton()
         {
             var point = getPointInsideElement(document.getElementById('target'), 10, 10);
-            testRunner.runUIScript(getSingleTapUIScript(point.x, point.y), function() {
-            });
-            
+            await tapAtPoint(point.x, point.y);
+
             // We have to keep retrying, because the dimming view behind the popover animates out,
             // and we currently have no callback when that animation completes.
-            window.setTimeout(tryTapOnButton, 100);
+            if (!clicked)
+                timeoutID = window.setTimeout(tryTapOnButton, 100);
         }
 
         function doTest()
@@ -96,7 +92,6 @@
         {
             if (!window.testRunner)
                 return;
-
             testRunner.waitUntilDone();
             testRunner.dumpAsText();
 
@@ -111,6 +106,7 @@
         }
         
         window.addEventListener('load', doTest, false);
+        
     </script>
 </head>
 <body>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to