Changeset 227992 in webkit


Ignore:
Timestamp:
Feb 1, 2018 6:13:40 PM (6 years ago)
Author:
Megan Gardner
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:
Location:
trunk/LayoutTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r227986 r227992  
     12018-02-01  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Fix race-condition in fast/forms/ios/ipad/select-form-run-twice.html
     4        https://bugs.webkit.org/show_bug.cgi?id=182370
     5
     6        Reviewed by Tim Horton.
     7       
     8        There is the potential for multiple button clicks, due to looping function calls that can cause timed functions to
     9        still be running in the next test, causing crashes. Guarding against repeated clicks, and cancelling the timers should
     10        clean up this problem.
     11
     12        * fast/forms/ios/ipad/select-form-run-twice.html:
     13        * fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html:
     14
    1152018-02-01  Matt Lewis  <jlewis3@apple.com>
    216
  • trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html

    r227855 r227992  
    6565        }
    6666
     67        var firstButtonIsClicked = false;
     68        var finalButtonIsClicked = false;
     69        var firstButtonTimeoutID;
     70        var finalButtonTimeoutID;
     71       
    6772        function firstButtonClicked()
    6873        {
    69             document.getElementById('nextStep').textContent = 'PASS: hit testing found #nextButton after first select interaction';
    70             var selectElement = document.getElementsByTagName('select')[0];
    71             var point = getPointInsideElement(selectElement, 10, 10);
    72             testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 5), function() {
    73                 document.getElementById('select-value2').textContent = selectElement.value;
    74                     tryTapOnButton('finalTarget');
    75             });
     74            clearTimeout(firstButtonTimeoutID);
     75            if (!firstButtonIsClicked) {
     76                firstButtonIsClicked = true;
     77               
     78                document.getElementById('nextStep').textContent = 'PASS: hit testing found #nextButton after first select interaction';
     79                var selectElement = document.getElementsByTagName('select')[0];
     80                var point = getPointInsideElement(selectElement, 10, 10);
     81                testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 5), function() {
     82                    document.getElementById('select-value2').textContent = selectElement.value;
     83                        tryTapOnFinalButton();
     84                });
     85            }
    7686        }
    7787   
    7888        function finalButtonClicked()
    7989        {
    80             document.getElementById('result').textContent = 'PASS: hit testing found #finalTarget after select interaction';
    81             if (window.testRunner)
    82                 testRunner.notifyDone();
     90            clearTimeout(finalButtonTimeoutID);
     91            if (!finalButtonIsClicked) {
     92                finalButtonIsClicked = true;
     93                document.getElementById('result').textContent = 'PASS: hit testing found #finalTarget after select interaction';
     94                if (window.testRunner)
     95                    testRunner.notifyDone();
     96            }
    8397        }
    8498
    85         async function tryTapOnButton(target)
     99        async function tryTapOnFirstButton()
    86100        {
    87             var point = getPointInsideElement(document.getElementById(target), 10, 10);
    88             await tapAtPoint(point.x, point.y);
     101            var firstPoint = getPointInsideElement(document.getElementById('firstTarget'), 10, 10);
     102            await tapAtPoint(firstPoint.x, firstPoint.y);
    89103           
    90104            // We have to keep retrying, because the dimming view behind the popover animates out,
    91105            // and we currently have no callback when that animation completes.
    92             window.setTimeout(tryTapOnButton.bind(this, target), 100);
     106            if (!firstButtonIsClicked)
     107                firstButtonTimeoutID = window.setTimeout(tryTapOnFirstButton, 100);
    93108        }
     109   
     110        async function tryTapOnFinalButton()
     111        {
     112            var finalPoint = getPointInsideElement(document.getElementById('finalTarget'), 10, 10);
     113            await tapAtPoint(finalPoint.x, finalPoint.y);
     114           
     115            // We have to keep retrying, because the dimming view behind the popover animates out,
     116            // and we currently have no callback when that animation completes.
     117            if (!finalButtonIsClicked)
     118                finalButtonTimeoutID = window.setTimeout(tryTapOnFinalButton, 100);
     119        }
     120   
    94121
    95122        function doTest()
     
    106133                testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 2), function() {
    107134                    document.getElementById('select-value').textContent = selectElement.value;
    108                     tryTapOnButton('firstTarget');
     135                    tryTapOnFirstButton();
    109136                });
    110137            });
  • trunk/LayoutTests/fast/forms/ios/ipad/unfocus-inside-fixed-hittest.html

    r227710 r227992  
    3131    </style>
    3232    <script src="../resources/zooming-test-utils.js"></script>
     33    <script src="../../../../resources/basic-gestures.js"></script>
    3334    <script>
    3435        if (window.testRunner)
    3536            testRunner.waitUntilDone();
    36 
    37         function getSingleTapUIScript(x, y)
    38         {
    39             return `
    40                 (function() {
    41                     uiController.singleTapAtPoint(${x}, ${y}, function() {
    42                         uiController.uiScriptComplete('');
    43                     });
    44                 })();`
    45         }
    4637
    4738        function getScrollDownUIScript(x, y)
     
    7566
    7667        var clicked = false;
     68        var timeoutID;
    7769        function buttonClicked()
    7870        {
    79             document.getElementById('result').textContent = 'PASS: hit testing found #target after select interaction';
    80             if (window.testRunner)
    81                 testRunner.notifyDone();
     71            window.clearTimeout(timeoutID);
     72            if (!clicked) {
     73                clicked = true;
     74                document.getElementById('result').textContent = 'PASS: hit testing found #target after select interaction';
     75                if (window.testRunner)
     76                    testRunner.notifyDone();
     77            }
    8278        }
    8379
    84         function tryTapOnButton()
     80        async function tryTapOnButton()
    8581        {
    8682            var point = getPointInsideElement(document.getElementById('target'), 10, 10);
    87             testRunner.runUIScript(getSingleTapUIScript(point.x, point.y), function() {
    88             });
    89            
     83            await tapAtPoint(point.x, point.y);
     84
    9085            // We have to keep retrying, because the dimming view behind the popover animates out,
    9186            // and we currently have no callback when that animation completes.
    92             window.setTimeout(tryTapOnButton, 100);
     87            if (!clicked)
     88                timeoutID = window.setTimeout(tryTapOnButton, 100);
    9389        }
    9490
     
    9793            if (!window.testRunner)
    9894                return;
    99 
    10095            testRunner.waitUntilDone();
    10196            testRunner.dumpAsText();
     
    112107       
    113108        window.addEventListener('load', doTest, false);
     109       
    114110    </script>
    115111</head>
Note: See TracChangeset for help on using the changeset viewer.