Changeset 244974 in webkit


Ignore:
Timestamp:
May 6, 2019 1:39:28 PM (5 years ago)
Author:
graouts@webkit.org
Message:

Tests under pointerevents/ios are flaky
https://bugs.webkit.org/show_bug.cgi?id=197624

Reviewed by Dean Jackson.

Tests under pointerevents/ios generate touches that use UIScriptController may not succeed if ran in multiple iterations or in a specific
order due to not ensuring that all touches are released when the test completes. We now ensure that we do when running swipes, taps, and pinches.

  • pointerevents/ios/pointer-events-dispatch-on-stylus.html: Use the new ui.tapStylus() method to generate a tap with the stylus which ensures all

touches are removed upon completion.

  • pointerevents/ios/pointer-events-dispatch-on-touch.html: Use a tap to ensure all touches are removed upon completion.
  • pointerevents/ios/pointer-events-implicit-capture-has-pointer-capture-in-pointer-down.html: Use a tap to ensure all touches are removed upon completion.
  • pointerevents/ios/pointer-events-implicit-capture-release-exception.html: Use a tap to ensure all touches are removed upon completion.
  • pointerevents/ios/pointer-events-implicit-capture-release.html: Use a tap to ensure all touches are removed upon completion.
  • pointerevents/ios/pointer-events-prevent-default-allows-click-event.html: Ensure both the "click" event and the tap generation have succeeded before

marking the test as complete.

  • pointerevents/ios/pointer-events-set-pointer-capture-exceptions.html: Use a tap to ensure all touches are removed upon completion.
  • pointerevents/ios/touch-action-none-link-traversal.html: Ensure both the "load" event and the tap generation have succeeded before marking the test

as complete.

  • pointerevents/ios/touch-action-pan-x-pan-y.html: Remove the requestAnimationFrame() call since ui.swipe() now resolves its promise once all touches

have completed.

  • pointerevents/ios/touch-action-pan-x.html: Remove the requestAnimationFrame() call since ui.swipe() now resolves its promise once all touches

have completed.

  • pointerevents/ios/touch-action-pan-y.html: Remove the requestAnimationFrame() call since ui.swipe() now resolves its promise once all touches

have completed.

  • pointerevents/ios/touch-action-pinch-zoom-allows-zooming.html: Remove the requestAnimationFrame() call since ui.pinchOut() now resolves its promise

once all touches have completed.

  • pointerevents/ios/touch-action-pointercancel-pan-x.html: We don't need to track "pointermove" events since dispatch of "pointercancel" is asynchronous

and the number of "pointermove" events prior to its dispatch can legitimately vary.

  • pointerevents/ios/touch-action-pointercancel-pan-y.html: We don't need to track "pointermove" events since dispatch of "pointercancel" is asynchronous

and the number of "pointermove" events prior to its dispatch can legitimately vary.

  • pointerevents/utils.js:

(const.ui.new.UIController.prototype.swipe): Wait until the swipe is complete before resolving the promise.
(const.ui.new.UIController.prototype.pinchOut): Use a custom sequence to ensure that the pinch releases touches upon completion.
(const.ui.new.UIController.prototype.tapStylus): Introduce this new method to perform a stylus tap which ensures all touches are complete before resolving
the promise.
(const.ui.new.UIController.prototype.beginTouches): Deleted.
(const.ui.new.UIController.prototype.beginStylus): Deleted.

Location:
trunk/LayoutTests
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r244965 r244974  
     12019-05-06  Antoine Quint  <graouts@apple.com>
     2
     3        Tests under pointerevents/ios are flaky
     4        https://bugs.webkit.org/show_bug.cgi?id=197624
     5
     6        Reviewed by Dean Jackson.
     7
     8        Tests under pointerevents/ios generate touches that use UIScriptController may not succeed if ran in multiple iterations or in a specific
     9        order due to not ensuring that all touches are released when the test completes. We now ensure that we do when running swipes, taps, and pinches.
     10
     11        * pointerevents/ios/pointer-events-dispatch-on-stylus.html: Use the new ui.tapStylus() method to generate a tap with the stylus which ensures all
     12        touches are removed upon completion.
     13        * pointerevents/ios/pointer-events-dispatch-on-touch.html: Use a tap to ensure all touches are removed upon completion.
     14        * pointerevents/ios/pointer-events-implicit-capture-has-pointer-capture-in-pointer-down.html: Use a tap to ensure all touches are removed upon completion.
     15        * pointerevents/ios/pointer-events-implicit-capture-release-exception.html: Use a tap to ensure all touches are removed upon completion.
     16        * pointerevents/ios/pointer-events-implicit-capture-release.html: Use a tap to ensure all touches are removed upon completion.
     17        * pointerevents/ios/pointer-events-prevent-default-allows-click-event.html: Ensure both the "click" event and the tap generation have succeeded before
     18        marking the test as complete.
     19        * pointerevents/ios/pointer-events-set-pointer-capture-exceptions.html: Use a tap to ensure all touches are removed upon completion.
     20        * pointerevents/ios/touch-action-none-link-traversal.html: Ensure both the "load" event and the tap generation have succeeded before marking the test
     21        as complete.
     22        * pointerevents/ios/touch-action-pan-x-pan-y.html: Remove the requestAnimationFrame() call since ui.swipe() now resolves its promise once all touches
     23        have completed.
     24        * pointerevents/ios/touch-action-pan-x.html: Remove the requestAnimationFrame() call since ui.swipe() now resolves its promise once all touches
     25        have completed.
     26        * pointerevents/ios/touch-action-pan-y.html: Remove the requestAnimationFrame() call since ui.swipe() now resolves its promise once all touches
     27        have completed.
     28        * pointerevents/ios/touch-action-pinch-zoom-allows-zooming.html: Remove the requestAnimationFrame() call since ui.pinchOut() now resolves its promise
     29        once all touches have completed.
     30        * pointerevents/ios/touch-action-pointercancel-pan-x.html: We don't need to track "pointermove" events since dispatch of "pointercancel" is asynchronous
     31        and the number of "pointermove" events prior to its dispatch can legitimately vary.
     32        * pointerevents/ios/touch-action-pointercancel-pan-y.html: We don't need to track "pointermove" events since dispatch of "pointercancel" is asynchronous
     33        and the number of "pointermove" events prior to its dispatch can legitimately vary.
     34        * pointerevents/utils.js:
     35        (const.ui.new.UIController.prototype.swipe): Wait until the swipe is complete before resolving the promise.
     36        (const.ui.new.UIController.prototype.pinchOut): Use a custom sequence to ensure that the pinch releases touches upon completion.
     37        (const.ui.new.UIController.prototype.tapStylus): Introduce this new method to perform a stylus tap which ensures all touches are complete before resolving
     38        the promise.
     39        (const.ui.new.UIController.prototype.beginTouches): Deleted.
     40        (const.ui.new.UIController.prototype.beginStylus): Deleted.
     41
    1422019-05-06  Truitt Savell  <tsavell@apple.com>
    243
  • trunk/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-stylus.html

    r240721 r244974  
    2828        test.done();
    2929    });
    30     ui.beginStylus({ x: 50, y: 50, pressure: 0.75, azimuthAngle: fifteenDegrees, altitudeAngle: thirtyDegrees });
     30    ui.tapStylus({ x: 50, y: 50, pressure: 0.75, azimuthAngle: fifteenDegrees, altitudeAngle: thirtyDegrees });
    3131}, "Pointer events get dispatched in response to a stylus.");
    3232
  • trunk/LayoutTests/pointerevents/ios/pointer-events-dispatch-on-touch.html

    r240632 r244974  
    2222        test.done();
    2323    });
    24     ui.beginTouches({ x: 50, y: 50 });
     24    ui.tap({ x: 50, y: 50 });
    2525}, "Pointer events get dispatched in response to a touch.");
    2626
  • trunk/LayoutTests/pointerevents/ios/pointer-events-implicit-capture-has-pointer-capture-in-pointer-down.html

    r240634 r244974  
    1515target_test((target, test) => {
    1616    target.addEventListener("pointerdown", event => assert_true(target.hasPointerCapture(event.pointerId)));
    17     ui.beginTouches({ x: 50, y: 50 }).then(() => test.done());
     17    ui.tap({ x: 50, y: 50 }).then(() => test.done());
    1818}, "Calling hasPointerCapture() in the 'pointerdown' event handler returns true for direct manipulation devices.");
    1919
  • trunk/LayoutTests/pointerevents/ios/pointer-events-implicit-capture-release-exception.html

    r240634 r244974  
    1919        assert_true(target.hasPointerCapture(event.pointerId));
    2020    });
    21     ui.beginTouches({ x: 50, y: 50 }).then(() => test.done());
     21    ui.tap({ x: 50, y: 50 }).then(() => test.done());
    2222}, "Calling releasePointerCapture() in the 'pointerdown' event handler with a bogus pointer id raises an exception and does not alter pointer capture.");
    2323
  • trunk/LayoutTests/pointerevents/ios/pointer-events-implicit-capture-release.html

    r240634 r244974  
    1919        assert_false(target.hasPointerCapture(event.pointerId));
    2020    });
    21     ui.beginTouches({ x: 50, y: 50 }).then(() => test.done());
     21    ui.tap({ x: 50, y: 50 }).then(() => test.done());
    2222}, "Calling releasePointerCapture() in the 'pointerdown' event handler makes hasPointerCapture() return false.");
    2323
  • trunk/LayoutTests/pointerevents/ios/pointer-events-prevent-default-allows-click-event.html

    r244598 r244974  
    1515target_test((target, test) => {
    1616    target.addEventListener("pointerdown", event => event.preventDefault());
    17     target.addEventListener("click", event => test.done());
    18     ui.tap({ x: 100, y: 100 });
     17    const clicked = new Promise(resolve => target.addEventListener("click", resolve));
     18    const tapped = ui.tap({ x: 100, y: 100 });
     19    Promise.all([clicked, tapped]).then(() => test.done());
    1920}, "A 'click' event is dispatched when tapping even if preventDefault() was called for a pointer event.");
    2021
  • trunk/LayoutTests/pointerevents/ios/pointer-events-set-pointer-capture-exceptions.html

    r240634 r244974  
    2020        assert_throws("InvalidStateError", () => document.createElement("div").setPointerCapture(event.pointerId), "Calling setPointerCapture() with a valid pointer id on a disconnected element throws an InvalidStateError exception.");
    2121    });
    22     ui.beginTouches({ x: 50, y: 50 }).then(() => test.done());
     22    ui.tap({ x: 50, y: 50 }).then(() => test.done());
    2323}, "The setPointerCapture() method can throw.");
    2424
  • trunk/LayoutTests/pointerevents/ios/touch-action-none-link-traversal.html

    r241760 r244974  
    4040    assert_equals(iframe.contentWindow.location.href, "about:blank", "The iframe initially has no URL.");
    4141
    42     iframe.addEventListener("load", () => {
    43         assert_true(iframe.contentWindow.location.href.includes("disabled.html"), "Upon navigation the URL has a location.");
    44         test.done();
     42    const loaded = new Promise(resolve => {
     43        iframe.addEventListener("load", () => {
     44            assert_true(iframe.contentWindow.location.href.includes("disabled.html"), "Upon navigation the URL has a location.");
     45            resolve();
     46        });
    4547    });
    4648
    47     ui.tap({ x: 100, y: 100 });
     49    const tapped = ui.tap({ x: 100, y: 100 });
     50
     51    Promise.all([loaded, tapped]).then(() => test.done());
    4852}, "Testing that setting touch-action: none allows link traversal.");
    4953
  • trunk/LayoutTests/pointerevents/ios/touch-action-pan-x-pan-y.html

    r240875 r244974  
    2020
    2121    ui.swipe({ x: 150, y: 150 }, { x: 50, y: 50 }).then(() => {
    22         requestAnimationFrame(() => {
    23             assert_not_equals(window.pageXOffset, 0, "The page was scrolled in the x-axis.");
    24             assert_not_equals(window.pageYOffset, 0, "The page was scrolled in the y-axis.");
    25             test.done();
    26         });
     22        assert_not_equals(window.pageXOffset, 0, "The page was scrolled in the x-axis.");
     23        assert_not_equals(window.pageYOffset, 0, "The page was scrolled in the y-axis.");
     24        test.done();
    2725    });
    2826
  • trunk/LayoutTests/pointerevents/ios/touch-action-pan-x.html

    r240875 r244974  
    2020
    2121    ui.swipe({ x: 150, y: 150 }, { x: 50, y: 50 }).then(() => {
    22         requestAnimationFrame(() => {
    23             assert_not_equals(window.pageXOffset, 0, "The page was scrolled in the x-axis.");
    24             assert_equals(window.pageYOffset, 0, "The page was not scrolled in the y-axis.");
    25             test.done();
    26         });
     22        assert_not_equals(window.pageXOffset, 0, "The page was scrolled in the x-axis.");
     23        assert_equals(window.pageYOffset, 0, "The page was not scrolled in the y-axis.");
     24        test.done();
    2725    });
    2826}, "Testing that setting touch-action: pan-x on an element prevents page scrolling in the y-axis.");
  • trunk/LayoutTests/pointerevents/ios/touch-action-pan-y.html

    r240875 r244974  
    2020
    2121    ui.swipe({ x: 150, y: 150 }, { x: 50, y: 50 }).then(() => {
    22         requestAnimationFrame(() => {
    23             assert_equals(window.pageXOffset, 0, "The page was not scrolled in the x-axis.");
    24             assert_not_equals(window.pageYOffset, 0, "The page was scrolled in the y-axis.");
    25             test.done();
    26         });
     22        assert_equals(window.pageXOffset, 0, "The page was not scrolled in the x-axis.");
     23        assert_not_equals(window.pageYOffset, 0, "The page was scrolled in the y-axis.");
     24        test.done();
    2725    });
    2826}, "Testing that setting touch-action: pan-y on an element prevents page scrolling in the x-axis.");
  • trunk/LayoutTests/pointerevents/ios/touch-action-pinch-zoom-allows-zooming.html

    r240875 r244974  
    2020
    2121    ui.pinchOut({ x: 50, y: 50, width: 100, height: 100, scale: 0.5 }).then(() => {
    22         requestAnimationFrame(() => {
    23             assert_not_equals(window.internals.pageScaleFactor(), 1, "The page was scaled.");
    24             test.done();
    25         });
     22        assert_not_equals(window.internals.pageScaleFactor(), 1, "The page was scaled.");
     23        test.done();
    2624    });
    2725}, "Testing that setting touch-action: pinch-zoom on an element allows page zooming.");
  • trunk/LayoutTests/pointerevents/ios/touch-action-pointercancel-pan-x.html

    r240875 r244974  
    1919    target.style.touchAction = "pan-x";
    2020
    21     const eventTracker = new EventTracker(target, ["pointerdown", "pointermove", "pointerup", "pointercancel"]);
     21    const eventTracker = new EventTracker(target, ["pointerdown", "pointerup", "pointercancel"]);
    2222
    2323    const one = ui.finger();
     
    3232        eventTracker.assertMatchesEvents([
    3333            { type: "pointerdown" },
    34             { type: "pointermove" },
    35             { type: "pointermove" },
    36             { type: "pointermove" },
    3734            { type: "pointercancel" }
    3835        ]);
  • trunk/LayoutTests/pointerevents/ios/touch-action-pointercancel-pan-y.html

    r240875 r244974  
    1919    target.style.touchAction = "pan-y";
    2020
    21     const eventTracker = new EventTracker(target, ["pointerdown", "pointermove", "pointerup", "pointercancel"]);
     21    const eventTracker = new EventTracker(target, ["pointerdown", "pointerup", "pointercancel"]);
    2222
    2323    const one = ui.finger();
     
    3232        eventTracker.assertMatchesEvents([
    3333            { type: "pointerdown" },
    34             { type: "pointermove" },
    35             { type: "pointermove" },
    36             { type: "pointermove" },
    3734            { type: "pointercancel" }
    3835        ]);
  • trunk/LayoutTests/pointerevents/utils.js

    r244328 r244974  
    108108    }
    109109
    110     beginTouches(options)
    111     {
    112         return this._run(`uiController.touchDownAtPoint(${options.x}, ${options.y}, ${options.numberOfTouches || 1})`);
    113     }
    114 
    115110    swipe(from, to)
    116111    {
    117         const durationInSeconds = 0.5;
    118         return this._run(`uiController.dragFromPointToPoint(${from.x}, ${from.y}, ${to.x}, ${to.y}, ${durationInSeconds})`);
     112        const durationInSeconds = 0.1;
     113        return new Promise(resolve => this._run(`uiController.dragFromPointToPoint(${from.x}, ${from.y}, ${to.x}, ${to.y}, ${durationInSeconds})`).then(() =>
     114            setTimeout(resolve, durationInSeconds * 1000)
     115        ));
    119116    }
    120117
     
    133130        options.y = options.y || 0;
    134131
    135         const startEvent = {
    136             inputType : "hand",
    137             timeOffset : 0,
    138             touches : [
    139                 { inputType : "finger",
    140                   phase : "moved",
    141                   id : 1,
    142                   x : options.x,
    143                   y : options.y,
    144                   pressure : 0
    145                 },
    146                 { inputType : "finger",
    147                   phase : "moved",
    148                   id : 2,
    149                   x : (options.x + options.width) / options.scale,
    150                   y : (options.y + options.height) / options.scale,
    151                   pressure : 0
    152                 }
    153             ]
    154         };
    155 
    156         const endEvent = {
    157             inputType : "hand",
    158             timeOffset : 0.5,
    159             touches : [
    160                 { inputType : "finger",
    161                   phase : "moved",
    162                   id : 1,
    163                   x : options.x,
    164                   y : options.y,
    165                   pressure : 0
    166                 },
    167                 { inputType : "finger",
    168                   phase : "moved",
    169                   id : 2,
    170                   x : options.x + options.width,
    171                   y : options.y + options.height,
    172                   pressure : 0
    173                 }
    174             ]
    175         };
    176 
    177         return this._runEvents([{
    178             interpolate : "linear",
    179             timestep: 0.1,
    180             coordinateSpace : "content",
    181             startEvent: startEvent,
    182             endEvent: endEvent
    183         }]);
     132        const startPoint = { x: options.x + options.width, y: options.y + options.height };
     133        const endPoint = { x: options.x + options.width * options.scale, y: options.y + options.height * options.scale };
     134
     135        function step(factor)
     136        {
     137            return {
     138                x: endPoint.x + (startPoint.x - endPoint.x) * (1 - factor),
     139                y: endPoint.y + (startPoint.y - endPoint.y) * (1 - factor)
     140            };
     141        }
     142
     143        const one = this.finger();
     144        const two = this.finger();
     145        return this.sequence([
     146            one.begin({ x: options.x, y: options.y }),
     147            two.begin(step(0)),
     148            two.move(step(0.2)),
     149            two.move(step(0.4)),
     150            two.move(step(0.6)),
     151            two.move(step(0.8)),
     152            two.move(step(1)),
     153            one.end(),
     154            two.end()
     155        ]);
    184156    }
    185157
     
    218190    }
    219191
    220     beginStylus(options)
     192    tapStylus(options)
    221193    {
    222194        options.azimuthAngle = options.azimuthAngle || 0;
    223195        options.altitudeAngle = options.altitudeAngle || 0;
    224196        options.pressure = options.pressure || 0;
    225         return this._run(`uiController.stylusDownAtPoint(${options.x}, ${options.y}, ${options.azimuthAngle}, ${options.altitudeAngle}, ${options.pressure})`);
     197        return this._run(`uiController.stylusTapAtPoint(${options.x}, ${options.y}, ${options.azimuthAngle}, ${options.altitudeAngle}, ${options.pressure})`);
    226198    }
    227199
Note: See TracChangeset for help on using the changeset viewer.