Changeset 269730 in webkit


Ignore:
Timestamp:
Nov 12, 2020 4:18:12 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
https://bugs.webkit.org/show_bug.cgi?id=218757

Patch by Martin Robinson <mrobinson@igalia.com> on 2020-11-12
Reviewed by Simon Fraser.

  • tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js: Added. Allows

sharing the mainframe scroll testing code between tests and reimplements them with Promises.

  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html:
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html:
Location:
trunk/LayoutTests
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r269728 r269730  
     12020-11-12  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
     4        https://bugs.webkit.org/show_bug.cgi?id=218757
     5
     6        Reviewed by Simon Fraser.
     7
     8        * tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js: Added. Allows
     9        sharing the mainframe scroll testing code between tests and reimplements them with Promises.
     10        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html:
     11        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html:
     12        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html:
     13        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html:
     14        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html:
     15        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html:
     16        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html:
     17        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html:
     18        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html:
     19
    1202020-11-12  Sergio Villar Senin  <svillar@igalia.com>
    221
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html

    r269506 r269730  
    2424        </style>
    2525        <script src="../../../resources/js-test.js"></script>
     26        <script src="../../../resources/ui-helper.js"></script>
     27        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2628        <script>
    2729        window.jsTestIsAsync = true;
    2830
    29         var targetScroller;
    30         var scrollPositionBeforeGlide;
    31         var scrollPositionBeforeSnap;
    32 
    33         function checkForScrollSnap()
     31        async function runTests()
    3432        {
    35             // The div should have snapped back to the previous position
    36             if (targetScroller.scrollLeft != scrollPositionBeforeSnap)
    37                 testFailed("div did not snap back to proper location. Expected " + scrollPositionBeforeSnap + ", but got " + targetScroller.scrollLeft);
    38             else
    39                 testPassed("div honored snap points.");
    40 
     33            await UIHelper.delayFor(0);
     34            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth");
     35            await UIHelper.delayFor(0);
     36            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
    4137            finishJSTest();
    42         }
    43 
    44         function scrollSnapTest()
    45         {
    46             scrollPositionBeforeSnap = targetScroller.scrollLeft;
    47 
    48             var startPosX = targetScroller.offsetLeft + 20;
    49             var startPosY = targetScroller.offsetTop + 20;
    50             eventSender.monitorWheelEvents();
    51             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    52             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    53             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    54             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    55             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    56             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    57         }
    58 
    59         function checkForScrollGlide()
    60         {
    61             // The div should have scrolled (glided) to the next snap point.
    62             if (targetScroller.scrollLeft == window.innerWidth)
    63                 testPassed("div scrolled to next window.");
    64             else
    65                 testFailed("div did not honor snap points. Expected " + window.innerWidth + ", but got " + targetScroller.scrollLeft);
    66 
    67             setTimeout(scrollSnapTest, 0);
    68         }
    69 
    70         function scrollGlideTest()
    71         {
    72             scrollPositionBeforeGlide = targetScroller.scrollLeft;
    73 
    74             var startPosX = targetScroller.offsetLeft + 20;
    75             var startPosY = targetScroller.offsetTop + 20;
    76             eventSender.monitorWheelEvents();
    77             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    78             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    79             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    80             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    81             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    82             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    83             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
    84             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'continue');
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    86             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    8738        }
    8839
    8940        function onLoad()
    9041        {
    91             targetScroller = document.scrollingElement;
    9242            if (window.eventSender) {
    9343                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    94                 setTimeout(scrollGlideTest, 0);
     44                runTests();
    9545            } else {
    9646                var messageLocation = document.getElementById('item0');
    9747                var message = document.createElement('div');
    98                 message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
    99                     + "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
    100                     + "small swipe gesture with some momentum.<br/><br/>"
    101                     + "The region should scroll to show a green region.<br/><br/>"
    102                     + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
    103                     + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
    104                     + "that the region is a single color.<br/><br/>"
    105                     + "You should also be able to repeat these test steps for the vertical region below.</p>";
     48                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
     49                    + "snap between uniform colors which fill the view.<p>";
    10650                messageLocation.appendChild(message);
    10751            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html

    r269622 r269730  
    3030        </style>
    3131        <script src="../../../resources/js-test.js"></script>
     32        <script src="../../../resources/ui-helper.js"></script>
     33        <script src="resources/mainframe-scroll-snap-test.js"></script>
    3234        <script>
    3335        window.jsTestIsAsync = true;
    3436
    35         var targetScroller;
    36         var scrollPositionBeforeGlide;
    37         var scrollPositionBeforeSnap;
    38 
    39         function checkForScrollSnap()
     37        async function runTests()
    4038        {
    41             // The div should have snapped back to the previous position
    42             if (targetScroller.scrollLeft != scrollPositionBeforeSnap)
    43                 testFailed("div did not snap back to proper location. Expected " + scrollPositionBeforeSnap + ", but got " + targetScroller.scrollLeft);
    44             else
    45                 testPassed("div honored snap points.");
    46 
     39            await UIHelper.delayFor(0);
     40            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth + 50");
     41            await UIHelper.delayFor(0);
     42            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
    4743            finishJSTest();
    48         }
    49 
    50         function scrollSnapTest()
    51         {
    52             scrollPositionBeforeSnap = targetScroller.scrollLeft;
    53 
    54             var startPosX = targetScroller.offsetLeft + 20;
    55             var startPosY = targetScroller.offsetTop + 20;
    56             eventSender.monitorWheelEvents();
    57             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    58             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    59             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    60             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    61             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    62             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    63         }
    64 
    65         function checkForScrollGlide()
    66         {
    67             // The div should have scrolled (glided) to the next snap point, which should be the width
    68             // of the first div plus the root element's left margin (50 pixels).
    69             if (targetScroller.scrollLeft == window.innerWidth + 50)
    70                 testPassed("div scrolled to next window.");
    71             else
    72                 testFailed("div did not honor snap points. Expected " + window.innerWidth + ", but got " + targetScroller.scrollLeft);
    73 
    74             setTimeout(scrollSnapTest, 0);
    75         }
    76 
    77         function scrollGlideTest()
    78         {
    79             scrollPositionBeforeGlide = targetScroller.scrollLeft;
    80 
    81             var startPosX = targetScroller.offsetLeft + 20;
    82             var startPosY = targetScroller.offsetTop + 20;
    83             eventSender.monitorWheelEvents();
    84             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    86             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    87             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    88             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    89             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    90             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
    91             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'continue');
    92             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    93             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    9444        }
    9545
    9646        function onLoad()
    9747        {
    98             targetScroller = document.scrollingElement;
    9948            if (window.eventSender) {
    10049                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    101                 setTimeout(scrollGlideTest, 0);
     50                runTests();
    10251            } else {
    10352                var messageLocation = document.getElementById('item0');
    10453                var message = document.createElement('div');
    10554                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
    106                     + "alternate between uniform colors which fill the view.<p>";
     55                    + "snap between uniform colors which fill the view.<p>";
    10756                messageLocation.appendChild(message);
    10857            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html

    r269506 r269730  
    2626        </style>
    2727        <script src="../../../resources/js-test.js"></script>
     28        <script src="../../../resources/ui-helper.js"></script>
     29        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2830        <script>
    2931        window.jsTestIsAsync = true;
    3032
    31         var targetScroller;
    32         var scrollPositionBeforeGlide;
    33         var scrollPositionBeforeSnap;
    34 
    35         function checkForScrollSnap()
     33        async function runTests()
    3634        {
    37             // The div should have snapped back to the previous position
    38             if (targetScroller.scrollLeft != scrollPositionBeforeSnap)
    39                 testFailed("div did not snap back to proper location. Expected " + scrollPositionBeforeSnap + ", but got " + targetScroller.scrollLeft);
    40             else
    41                 testPassed("div honored snap points.");
    42 
     35            await UIHelper.delayFor(0);
     36            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth");
     37            await UIHelper.delayFor(0);
     38            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
    4339            finishJSTest();
    44         }
    45 
    46         function scrollSnapTest()
    47         {
    48             scrollPositionBeforeSnap = targetScroller.scrollLeft;
    49 
    50             var startPosX = targetScroller.offsetLeft + 20;
    51             var startPosY = targetScroller.offsetTop + 20;
    52             eventSender.monitorWheelEvents();
    53             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    54             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    55             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    56             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    57             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    58             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    59         }
    60 
    61         function checkForScrollGlide()
    62         {
    63             // The div should have scrolled (glided) to the next snap point.
    64             if (targetScroller.scrollLeft == window.innerWidth)
    65                 testPassed("div scrolled to next window.");
    66             else
    67                 testFailed("div did not honor snap points. Expected " + window.innerWidth + ", but got " + targetScroller.scrollLeft);
    68 
    69             setTimeout(scrollSnapTest, 0);
    70         }
    71 
    72         function scrollGlideTest()
    73         {
    74             scrollPositionBeforeGlide = targetScroller.scrollLeft;
    75 
    76             var startPosX = targetScroller.offsetLeft + 20;
    77             var startPosY = targetScroller.offsetTop + 20;
    78             eventSender.monitorWheelEvents();
    79             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    80             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    81             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    82             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    83             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    84             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
    86             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'continue');
    87             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    88             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    8940        }
    9041
    9142        function onLoad()
    9243        {
    93             targetScroller = document.scrollingElement;
    9444            if (window.eventSender) {
    9545                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    96                 setTimeout(scrollGlideTest, 0);
     46                runTests();
    9747            } else {
    9848                var messageLocation = document.getElementById('item0');
    9949                var message = document.createElement('div');
    100                 message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
    101                     + "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
    102                     + "small swipe gesture with some momentum.<br/><br/>"
    103                     + "The region should scroll to show a green region.<br/><br/>"
    104                     + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
    105                     + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
    106                     + "that the region is a single color.<br/><br/>"
    107                     + "You should also be able to repeat these test steps for the vertical region below.</p>";
     50                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
     51                    + "snap between uniform colors which fill the view.<p>";
    10852                messageLocation.appendChild(message);
    10953            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html

    r269506 r269730  
    2626        </style>
    2727        <script src="../../../resources/js-test.js"></script>
     28        <script src="../../../resources/ui-helper.js"></script>
     29        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2830        <script>
    2931        window.jsTestIsAsync = true;
    3032
    31         var scrollingTarget;
    32         var scrollPositionBeforeGlide;
    33         var scrollPositionBeforeSnap;
    34 
    35         function checkForScrollSnap() {
    36             // The div should have snapped back to the previous position
    37             if (scrollingTarget.scrollLeft != scrollPositionBeforeSnap)
    38                 testFailed(`div did not snap back to proper location. ${scrollingTarget.scrollLeft} vs. ${scrollPositionBeforeSnap}`);
    39             else
    40                 testPassed("div honored snap points.");
    41 
     33        async function runTests()
     34        {
     35            await UIHelper.delayFor(0);
     36            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth");
     37            await UIHelper.delayFor(0);
     38            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
    4239            finishJSTest();
    43         }
    44 
    45         function scrollSnapTest()
    46         {
    47             scrollPositionBeforeSnap = scrollingTarget.scrollLeft;
    48 
    49             var startPosX = scrollingTarget.offsetLeft + 20;
    50             var startPosY = scrollingTarget.offsetTop + 20;
    51             eventSender.monitorWheelEvents();
    52             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    53             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    54             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    55             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    56             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    57             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    58         }
    59 
    60         function checkForScrollGlide()
    61         {
    62             // The div should have scrolled (glided) to the next snap point.
    63             if (scrollingTarget.scrollLeft == window.innerWidth)
    64                 testPassed("div scrolled to next window.");
    65             else
    66                 testFailed(`div did not honor snap points. ${scrollingTarget.scrollLeft} vs. ${window.innerWidth}`);
    67 
    68             setTimeout(scrollSnapTest, 0);
    69         }
    70 
    71         function scrollGlideTest()
    72         {
    73             scrollPositionBeforeGlide = scrollingTarget.scrollLeft;
    74 
    75             var startPosX = scrollingTarget.offsetLeft + 20;
    76             var startPosY = scrollingTarget.offsetTop + 20;
    77             eventSender.monitorWheelEvents();
    78             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    79             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
    80             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    81             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    82             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    83             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    84             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(-4, 0, 'none', 'continue');
    86             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    87             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    8840        }
    8941
    9042        function onLoad()
    9143        {
    92             scrollingTarget = document.scrollingElement;
    9344            if (window.eventSender) {
    9445                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    95                 setTimeout(scrollGlideTest, 0);
     46                runTests();
    9647            } else {
    9748                var messageLocation = document.getElementById('item0');
    9849                var message = document.createElement('div');
    99                 message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
    100                     + "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
    101                     + "small swipe gesture with some momentum.<br/><br/>"
    102                     + "The region should scroll to show a green region.<br/><br/>"
    103                     + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
    104                     + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
    105                     + "that the region is a single color.<br/><br/>"
    106                     + "You should also be able to repeat these test steps for the vertical region below.</p>";
     50                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
     51                    + "snap between uniform colors which fill the view.<p>";
    10752                messageLocation.appendChild(message);
    10853            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html

    r269506 r269730  
    2626        </style>
    2727        <script src="../../../resources/js-test.js"></script>
     28        <script src="../../../resources/ui-helper.js"></script>
     29        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2830        <script>
    2931        window.jsTestIsAsync = true;
    3032
    31         var targetScroller;
    32         var scrollPositionBeforeGlide;
    33         var scrollPositionBeforeSnap;
    34 
    35         function checkForScrollSnap()
     33        async function runTests()
    3634        {
    37             // The div should have snapped back to the previous position
    38             if (targetScroller.scrollTop != scrollPositionBeforeSnap)
    39                 testFailed(`div did not snap back to proper location. (${targetScroller.scrollTop} vs. ${scrollPositionBeforeSnap})`);
    40             else
    41                 testPassed("div honored snap points.");
    42 
     35            await UIHelper.delayFor(0);
     36            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight");
     37            await UIHelper.delayFor(0);
     38            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
    4339            finishJSTest();
    44         }
    45 
    46         function scrollSnapTest()
    47         {
    48             // See where our div lives:
    49             scrollPositionBeforeSnap = targetScroller.scrollTop;
    50 
    51             var startPosX = targetScroller.offsetLeft + 20;
    52             var startPosY = targetScroller.offsetTop + 20;
    53             eventSender.monitorWheelEvents();
    54             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    55             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    56             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    57             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    58             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    59             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    60         }
    61 
    62         function checkForScrollGlide()
    63         {
    64             // The div should have scrolled (glided) to the next snap point.
    65             if (targetScroller.scrollTop == window.innerHeight)
    66                 testPassed("div scrolled to next window.");
    67             else
    68                 testFailed(`div did not honor snap points. (${targetScroller.scrollTop} vs. ${window.innerHeight})`);
    69 
    70             setTimeout(scrollSnapTest, 0);
    71         }
    72 
    73         function scrollGlideTest()
    74         {
    75             scrollPositionBeforeGlide = targetScroller.scrollTop;
    76 
    77             var startPosX = targetScroller.offsetLeft + 20;
    78             var startPosY = targetScroller.offsetTop + 20;
    79             eventSender.monitorWheelEvents();
    80             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    81             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    82             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    83             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    84             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    86             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
    87             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
    88             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    89             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    9040        }
    9141
    9242        function onLoad()
    9343        {
    94             targetScroller = document.scrollingElement;
    9544            if (window.eventSender) {
    9645                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    97                 setTimeout(scrollGlideTest, 0);
     46                runTests();
    9847            } else {
    9948                var messageLocation = document.getElementById('item0');
    10049                var message = document.createElement('div');
    101                 message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
    102                     + "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
    103                     + "small swipe gesture with some momentum.<br/><br/>"
    104                     + "The region should scroll to show a green region.<br/><br/>"
    105                     + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
    106                     + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
    107                     + "that the region is a single color.<br/><br/>"
    108                     + "You should also be able to repeat these test steps for the vertical region below.</p>";
     50                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
     51                    + "snap between uniform colors which fill the view.<p>";
    10952                messageLocation.appendChild(message);
    11053            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html

    r269506 r269730  
    2424        </style>
    2525        <script src="../../../resources/js-test.js"></script>
     26        <script src="../../../resources/ui-helper.js"></script>
     27        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2628        <script>
    2729        window.jsTestIsAsync = true;
    2830
    29         var scrollingTarget;
    30         var scrollPositionBeforeGlide;
    31         var scrollPositionBeforeSnap;
    32 
    33         function checkForScrollSnap()
     31        async function runTests()
    3432        {
    35             // The div should have snapped back to the previous position
    36             if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
    37                 testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
    38             else
    39                 testPassed("div honored snap points.");
    40 
     33            await UIHelper.delayFor(0);
     34            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight");
     35            await UIHelper.delayFor(0);
     36            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
    4137            finishJSTest();
    42         }
    43 
    44         function scrollSnapTest()
    45         {
    46             scrollPositionBeforeSnap = scrollingTarget.scrollTop;
    47 
    48             var startPosX = scrollingTarget.offsetLeft + 20;
    49             var startPosY = scrollingTarget.offsetTop + 20;
    50             eventSender.monitorWheelEvents();
    51             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    52             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    53             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    54             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    55             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    56             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    57         }
    58 
    59         function checkForScrollGlide()
    60         {
    61             // The div should have scrolled (glided) to the next snap point.
    62             if (scrollingTarget.scrollTop == window.innerHeight)
    63                 testPassed("div scrolled to next window.");
    64             else
    65                 testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
    66 
    67             setTimeout(scrollSnapTest, 0);
    68         }
    69 
    70         function scrollGlideTest()
    71         {
    72             scrollPositionBeforeGlide = scrollingTarget.scrollTop;
    73 
    74             var startPosX = scrollingTarget.offsetLeft + 20;
    75             var startPosY = scrollingTarget.offsetTop + 20;
    76             eventSender.monitorWheelEvents();
    77             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    78             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    79             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    80             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    81             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    82             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    83             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
    84             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    86             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    8738        }
    8839
    8940        function onLoad()
    9041        {
    91             scrollingTarget = document.scrollingElement;
    9242            if (window.eventSender) {
    9343                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    94                 setTimeout(scrollGlideTest, 0);
     44                runTests();
    9545            } else {
    9646                var messageLocation = document.getElementById('item0');
    9747                var message = document.createElement('div');
    98                 message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
    99                     + "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
    100                     + "small swipe gesture with some momentum.<br/><br/>"
    101                     + "The region should scroll to show a green region.<br/><br/>"
    102                     + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
    103                     + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
    104                     + "that the region is a single color.<br/><br/>"
    105                     + "You should also be able to repeat these test steps for the vertical region below.</p>";
     48                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
     49                    + "snap between uniform colors which fill the view.<p>";
    10650                messageLocation.appendChild(message);
    10751            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html

    r269506 r269730  
    2626        </style>
    2727        <script src="../../../resources/js-test.js"></script>
     28        <script src="../../../resources/ui-helper.js"></script>
     29        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2830        <script>
    2931        window.jsTestIsAsync = true;
    3032
    31         function scrollSnapTest()
     33        async function runTest()
    3234        {
    33             var startPosX = document.body.offsetLeft + 20;
    34             var startPosY = document.body.offsetTop + 20;
    35             eventSender.monitorWheelEvents();
    36             eventSender.mouseMoveTo(startPosX, startPosY);
    37             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    38             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    39             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    40             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    41             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
    42             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    43             eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
    44             eventSender.mouseScrollByWithWheelAndMomentumPhases(-4, 0, 'none', 'continue');
    45             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    46             eventSender.callAfterScrollingCompletes(() => {
    47                 if (document.scrollingElement.scrollTop == 0)
    48                     testPassed("scroll offset snapped back to top.");
    49                 else
    50                     testFailed(`did not honor snap points (expected 0, observed ${document.scrollingElement.scrollTop}).`);
     35            // These arrays are arguments that will be passed to eventSender.mouseScrollByWithWheelAndMomentumPhases.
     36            let scrollMotions = [
     37                [0, -1, 'began', 'none'],
     38                [0, -1, 'changed', 'none'],
     39                [-1, 0, 'changed', 'none'],
     40                [-1, 0, 'changed', 'none'],
     41                [-1, 0, 'changed', 'none'],
     42                [0, 0, 'ended', 'none'],
     43                [-1, 0, 'none', 'begin'],
     44                [-4, 0, 'none', 'continue'],
     45                [0, 0, 'none', 'end'],
     46            ];
    5147
    52                 finishJSTest();
    53             });
     48            await UIHelper.delayFor(0);
     49            await doScrollTest(document.scrollingElement, VERTICAL_AND_HORIZONTAL, scrollMotions);
     50
     51            if (document.scrollingElement.scrollTop == 0)
     52                testPassed("scroll offset snapped back to top.");
     53            else
     54                testFailed(`did not honor snap points (expected 0, observed ${document.scrollingElement.scrollTop}).`);
     55
     56            finishJSTest();
    5457        }
    5558
     
    5861            if (window.eventSender) {
    5962                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    60                 setTimeout(scrollSnapTest, 0);
     63                runTest();
    6164            } else {
    6265                var messageLocation = document.getElementById('item0');
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html

    r269622 r269730  
    3030        </style>
    3131        <script src="../../../resources/js-test.js"></script>
     32        <script src="../../../resources/ui-helper.js"></script>
     33        <script src="resources/mainframe-scroll-snap-test.js"></script>
    3234        <script>
    3335        window.jsTestIsAsync = true;
    3436
    35         var scrollingTarget;
    36         var scrollPositionBeforeGlide;
    37         var scrollPositionBeforeSnap;
    38 
    39         function checkForScrollSnap()
     37        async function runTests()
    4038        {
    41             // The div should have snapped back to the previous position
    42             if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
    43                 testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
    44             else
    45                 testPassed("div honored snap points.");
    46 
     39            await UIHelper.delayFor(0);
     40            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight + 50");
     41            await UIHelper.delayFor(0);
     42            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
    4743            finishJSTest();
    48         }
    49 
    50         function scrollSnapTest()
    51         {
    52             scrollPositionBeforeSnap = scrollingTarget.scrollTop;
    53 
    54             var startPosX = scrollingTarget.offsetLeft + 20;
    55             var startPosY = scrollingTarget.offsetTop + 20;
    56             eventSender.monitorWheelEvents();
    57             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    58             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    59             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    60             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    61             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    62             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    63         }
    64 
    65         function checkForScrollGlide()
    66         {
    67             // The div should have scrolled (glided) to the next snap point, which should be the height
    68             // of the first div plus the root element's top margin (50 pixels).
    69             if (scrollingTarget.scrollTop == window.innerHeight + 50)
    70                 testPassed("div scrolled to next window.");
    71             else
    72                 testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
    73 
    74             setTimeout(scrollSnapTest, 0);
    75         }
    76 
    77         function scrollGlideTest()
    78         {
    79             scrollPositionBeforeGlide = scrollingTarget.scrollTop;
    80 
    81             var startPosX = scrollingTarget.offsetLeft + 20;
    82             var startPosY = scrollingTarget.offsetTop + 20;
    83             eventSender.monitorWheelEvents();
    84             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    86             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    87             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    88             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    89             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    90             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
    91             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
    92             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    93             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    9444        }
    9545
    9646        function onLoad()
    9747        {
    98             scrollingTarget = document.scrollingElement;
    9948            if (window.eventSender) {
    10049                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    101                 setTimeout(scrollGlideTest, 0);
     50                runTests();
    10251            } else {
    10352                var messageLocation = document.getElementById('item0');
    10453                var message = document.createElement('div');
    10554                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
    106                     + "alternate between uniform colors which fill the view.<p>";
     55                    + "snap between uniform colors which fill the view.<p>";
    10756                messageLocation.appendChild(message);
    10857            }
  • trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html

    r269506 r269730  
    2626        </style>
    2727        <script src="../../../resources/js-test.js"></script>
     28        <script src="../../../resources/ui-helper.js"></script>
     29        <script src="resources/mainframe-scroll-snap-test.js"></script>
    2830        <script>
    2931        window.jsTestIsAsync = true;
    3032
    31         var scrollingTarget;
    32         var scrollPositionBeforeGlide;
    33         var scrollPositionBeforeSnap;
    34 
    35         function checkForScrollSnap()
     33        async function runTests()
    3634        {
    37             // The div should have snapped back to the previous position
    38             if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
    39                 testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
    40             else
    41                 testPassed("div honored snap points.");
    42 
     35            await UIHelper.delayFor(0);
     36            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight");
     37            await UIHelper.delayFor(0);
     38            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
    4339            finishJSTest();
    44         }
    45 
    46         function scrollSnapTest()
    47         {
    48             scrollPositionBeforeSnap = scrollingTarget.scrollTop;
    49 
    50             var startPosX = scrollingTarget.offsetLeft + 20;
    51             var startPosY = scrollingTarget.offsetTop + 20;
    52             eventSender.monitorWheelEvents();
    53             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    54             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    55             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    56             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    57             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    58             eventSender.callAfterScrollingCompletes(checkForScrollSnap);
    59         }
    60 
    61         function checkForScrollGlide()
    62         {
    63             // The div should have scrolled (glided) to the next snap point.
    64             if (scrollingTarget.scrollTop == window.innerHeight)
    65                 testPassed("div scrolled to next window.");
    66             else
    67                 testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
    68 
    69             setTimeout(scrollSnapTest, 0);
    70         }
    71 
    72         function scrollGlideTest()
    73         {
    74             scrollPositionBeforeGlide = scrollingTarget.scrollTop;
    75 
    76             var startPosX = scrollingTarget.offsetLeft + 20;
    77             var startPosY = scrollingTarget.offsetTop + 20;
    78             eventSender.monitorWheelEvents();
    79             eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
    80             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
    81             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    82             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    83             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
    84             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
    85             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
    86             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
    87             eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
    88             eventSender.callAfterScrollingCompletes(checkForScrollGlide);
    8940        }
    9041
    9142        function onLoad()
    9243        {
    93             scrollingTarget = document.scrollingElement;
    9444            if (window.eventSender) {
    9545                internals.setPlatformMomentumScrollingPredictionEnabled(false);
    96                 setTimeout(scrollGlideTest, 0);
     46                runTests();
    9747            } else {
    9848                var messageLocation = document.getElementById('item0');
    9949                var message = document.createElement('div');
    100                 message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
    101                     + "inside the red region at the top of the page, and then use the mouse wheel or a two-finger swipe to make a<br/>"
    102                     + "small swipe gesture with some momentum.<br/><br/>"
    103                     + "The region should scroll to show a green region.<br/><br/>"
    104                     + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
    105                     + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
    106                     + "that the region is a single color.<br/><br/>"
    107                     + "You should also be able to repeat these test steps for the vertical region below.</p>";
     50                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
     51                    + "snap between uniform colors which fill the view.<p>";
    10852                messageLocation.appendChild(message);
    10953            }
Note: See TracChangeset for help on using the changeset viewer.