<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[269730] trunk/LayoutTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/269730">269730</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2020-11-12 04:18:12 -0800 (Thu, 12 Nov 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframehorizontallegacyhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframehorizontalwithmarginhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframehorizontalhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeslowhorizontalhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeslowverticalhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticallegacyhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalthenhorizontalhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalwithmarginhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapresourcesmainframescrollsnaptestjs">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/ChangeLog 2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2020-11-12  Martin Robinson  <mrobinson@igalia.com>
+
+        Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
+        https://bugs.webkit.org/show_bug.cgi?id=218757
+
+        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:
+
</ins><span class="cx"> 2020-11-12  Sergio Villar Senin  <svillar@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Crash in RenderBox::overrideContainingBlockContentHeight()
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapresourcesmainframescrollsnaptestjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js (0 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js                            (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js       2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+const VERTICAL = [0, 1];
+const HORIZONTAL = [1, 0];
+const VERTICAL_AND_HORIZONTAL = [1, 1];
+
+async function doScrollGlide(targetElement, direction)
+{
+    // These arrays are arguments that will be passed to eventSender.mouseScrollByWithWheelAndMomentumPhases.
+    // Depending on whether or not the direction is vertical or horizontal one of the first two elements
+    // of each entry will be zeroed out, so that eventSender only scrolls in one direction at a time.
+    let scrollMotions = [
+        [-1, -1, 'began', 'none'],
+        [-1, -1, 'changed', 'none'],
+        [-1, -1, 'changed', 'none'],
+        [-1, -1, 'changed', 'none'],
+        [0, 0, 'ended', 'none'],
+        [-1, -1, 'none', 'begin'],
+        [-1, -1, 'none', 'continue'],
+        [0, 0, 'none', 'end'],
+    ];
+
+    return doScrollTest(targetElement, direction, scrollMotions);
+}
+
+async function doScrollSnap(targetElement, direction)
+{
+    // These arrays are arguments that will be passed to eventSender.mouseScrollByWithWheelAndMomentumPhases.
+    // Depending on whether or not the direction is vertical or horizontal one of the first two elements
+    // of each entry will be zeroed out, so that eventSender only scrolls in one direction at a time.
+    let scrollMotions = [
+        [-1, 0, 'began', 'none'],
+        [-1, 0, 'changed', 'none'],
+        [-1, 0, 'changed', 'none'],
+        [0, 0, 'ended', 'none'],
+    ];
+    return doScrollTest(targetElement, direction, scrollMotions);
+}
+
+async function doScrollTest(targetElement, direction, scrollMotions)
+{
+    var startPosX;
+    var startPosY;
+    if (document.scrollingElement == targetElement) {
+        // getBoundingClientRect() can be an out-of-viewport rectangle if the
+        // root scrolling element is the targetElement.
+        startPosX = 0;
+        startPosY = 0;
+    } else {
+        var clientRect = targetElement.getBoundingClientRect();
+        var startPosX = clientRect.x;
+        var startPosY = clientRect.y;
+    }
+
+    // Slightly offset the mouse position so that the events are inside the element.
+    startPosX += 5;
+    startPosY += 5;
+
+    eventSender.monitorWheelEvents();
+    eventSender.mouseMoveTo(startPosX, startPosY);
+
+    // `direction` is a two-element array with a one in the appropriate direction.
+    scrollMotions.forEach((callArguments) => {
+        callArguments[0] *= direction[0];
+        callArguments[1] *= direction[1];
+        eventSender.mouseScrollByWithWheelAndMomentumPhases(...callArguments);
+    });
+
+    await UIHelper.waitForScrollCompletion();
+}
+
+function delay(time) {
+    return new Promise(resolve => setTimeout(resolve, time));
+}
+
+function shortScrollShouldSnapBack(targetElement, direction)
+{
+    var scrollPositionBeforeSnap = targetElement.scrollLeft;
+    return doScrollSnap(targetElement, HORIZONTAL).then(() => {
+        // The targetElement should have remained on the same snap point.
+        expectTrue("targetElement.scrollLeft == scrollPositionBeforeSnap", "div honored snap points.");
+    });
+}
+
+function scrollGlideShouldScrollTo(targetElement, direction, expectedValue)
+{
+    return doScrollGlide(targetElement, HORIZONTAL).then(() => {
+        // The targetElement should have snapped to the given snap position.
+        expectTrue("targetElement.scrollLeft == " + expectedValue, "div scrolled to next window.");
+    });
+}
</ins></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframehorizontallegacyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html     2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html        2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -23,86 +23,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var targetScroller;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (targetScroller.scrollLeft != scrollPositionBeforeSnap)
-                testFailed("div did not snap back to proper location. Expected " + scrollPositionBeforeSnap + ", but got " + targetScroller.scrollLeft);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = targetScroller.scrollLeft;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point.
-            if (targetScroller.scrollLeft == window.innerWidth)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed("div did not honor snap points. Expected " + window.innerWidth + ", but got " + targetScroller.scrollLeft);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = targetScroller.scrollLeft;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            targetScroller = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><del>-                message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
-                    + "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/>"
-                    + "small swipe gesture with some momentum.<br/><br/>"
-                    + "The region should scroll to show a green region.<br/><br/>"
-                    + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
-                    + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
-                    + "that the region is a single color.<br/><br/>"
-                    + "You should also be able to repeat these test steps for the vertical region below.</p>";
</del><ins>+                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframehorizontalwithmarginhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html        2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-margin.html   2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -29,81 +29,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var targetScroller;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (targetScroller.scrollLeft != scrollPositionBeforeSnap)
-                testFailed("div did not snap back to proper location. Expected " + scrollPositionBeforeSnap + ", but got " + targetScroller.scrollLeft);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth + 50");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = targetScroller.scrollLeft;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point, which should be the width
-            // of the first div plus the root element's left margin (50 pixels).
-            if (targetScroller.scrollLeft == window.innerWidth + 50)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed("div did not honor snap points. Expected " + window.innerWidth + ", but got " + targetScroller.scrollLeft);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = targetScroller.scrollLeft;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            targetScroller = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><span class="cx">                 message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
</span><del>-                    + "alternate between uniform colors which fill the view.<p>";
</del><ins>+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframehorizontalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html    2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html       2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -25,86 +25,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var targetScroller;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (targetScroller.scrollLeft != scrollPositionBeforeSnap)
-                testFailed("div did not snap back to proper location. Expected " + scrollPositionBeforeSnap + ", but got " + targetScroller.scrollLeft);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = targetScroller.scrollLeft;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point.
-            if (targetScroller.scrollLeft == window.innerWidth)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed("div did not honor snap points. Expected " + window.innerWidth + ", but got " + targetScroller.scrollLeft);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = targetScroller.scrollLeft;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            targetScroller = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><del>-                message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
-                    + "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/>"
-                    + "small swipe gesture with some momentum.<br/><br/>"
-                    + "The region should scroll to show a green region.<br/><br/>"
-                    + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
-                    + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
-                    + "that the region is a single color.<br/><br/>"
-                    + "You should also be able to repeat these test steps for the vertical region below.</p>";
</del><ins>+                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeslowhorizontalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html       2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html  2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -25,85 +25,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var scrollingTarget;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap() {
-            // The div should have snapped back to the previous position
-            if (scrollingTarget.scrollLeft != scrollPositionBeforeSnap)
-                testFailed(`div did not snap back to proper location. ${scrollingTarget.scrollLeft} vs. ${scrollPositionBeforeSnap}`);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+        async function runTests()
+        {
+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = scrollingTarget.scrollLeft;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point.
-            if (scrollingTarget.scrollLeft == window.innerWidth)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed(`div did not honor snap points. ${scrollingTarget.scrollLeft} vs. ${window.innerWidth}`);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = scrollingTarget.scrollLeft;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-4, 0, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            scrollingTarget = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><del>-                message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
-                    + "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/>"
-                    + "small swipe gesture with some momentum.<br/><br/>"
-                    + "The region should scroll to show a green region.<br/><br/>"
-                    + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
-                    + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
-                    + "that the region is a single color.<br/><br/>"
-                    + "You should also be able to repeat these test steps for the vertical region below.</p>";
</del><ins>+                message.innerHTML = "<p>To run this test manually, scroll the page horizontally. The page should "
+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeslowverticalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html 2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html    2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -25,87 +25,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var targetScroller;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (targetScroller.scrollTop != scrollPositionBeforeSnap)
-                testFailed(`div did not snap back to proper location. (${targetScroller.scrollTop} vs. ${scrollPositionBeforeSnap})`);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            // See where our div lives:
-            scrollPositionBeforeSnap = targetScroller.scrollTop;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point.
-            if (targetScroller.scrollTop == window.innerHeight)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed(`div did not honor snap points. (${targetScroller.scrollTop} vs. ${window.innerHeight})`);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = targetScroller.scrollTop;
-
-            var startPosX = targetScroller.offsetLeft + 20;
-            var startPosY = targetScroller.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            targetScroller = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><del>-                message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
-                    + "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/>"
-                    + "small swipe gesture with some momentum.<br/><br/>"
-                    + "The region should scroll to show a green region.<br/><br/>"
-                    + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
-                    + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
-                    + "that the region is a single color.<br/><br/>"
-                    + "You should also be able to repeat these test steps for the vertical region below.</p>";
</del><ins>+                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticallegacyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html       2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html  2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -23,86 +23,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var scrollingTarget;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
-                testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = scrollingTarget.scrollTop;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point.
-            if (scrollingTarget.scrollTop == window.innerHeight)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = scrollingTarget.scrollTop;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            scrollingTarget = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><del>-                message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
-                    + "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/>"
-                    + "small swipe gesture with some momentum.<br/><br/>"
-                    + "The region should scroll to show a green region.<br/><br/>"
-                    + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
-                    + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
-                    + "that the region is a single color.<br/><br/>"
-                    + "You should also be able to repeat these test steps for the vertical region below.</p>";
</del><ins>+                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalthenhorizontalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html      2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html 2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -25,32 +25,35 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
</del><ins>+        async function runTest()
</ins><span class="cx">         {
</span><del>-            var startPosX = document.body.offsetLeft + 20;
-            var startPosY = document.body.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY);
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-1, 0, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(-4, 0, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(() => {
-                if (document.scrollingElement.scrollTop == 0)
-                    testPassed("scroll offset snapped back to top.");
-                else
-                    testFailed(`did not honor snap points (expected 0, observed ${document.scrollingElement.scrollTop}).`);
</del><ins>+            // These arrays are arguments that will be passed to eventSender.mouseScrollByWithWheelAndMomentumPhases.
+            let scrollMotions = [
+                [0, -1, 'began', 'none'],
+                [0, -1, 'changed', 'none'],
+                [-1, 0, 'changed', 'none'],
+                [-1, 0, 'changed', 'none'],
+                [-1, 0, 'changed', 'none'],
+                [0, 0, 'ended', 'none'],
+                [-1, 0, 'none', 'begin'],
+                [-4, 0, 'none', 'continue'],
+                [0, 0, 'none', 'end'],
+            ];
</ins><span class="cx"> 
</span><del>-                finishJSTest();
-            });
</del><ins>+            await UIHelper.delayFor(0);
+            await doScrollTest(document.scrollingElement, VERTICAL_AND_HORIZONTAL, scrollMotions);
+
+            if (document.scrollingElement.scrollTop == 0)
+                testPassed("scroll offset snapped back to top.");
+            else
+                testFailed(`did not honor snap points (expected 0, observed ${document.scrollingElement.scrollTop}).`);
+
+            finishJSTest();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function onLoad()
</span><span class="lines">@@ -57,7 +60,7 @@
</span><span class="cx">         {
</span><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollSnapTest, 0);
</del><ins>+                runTest();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalwithmarginhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html  2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-margin.html     2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -29,81 +29,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var scrollingTarget;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
-                testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight + 50");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = scrollingTarget.scrollTop;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point, which should be the height
-            // of the first div plus the root element's top margin (50 pixels).
-            if (scrollingTarget.scrollTop == window.innerHeight + 50)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = scrollingTarget.scrollTop;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            scrollingTarget = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><span class="cx">                 message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
</span><del>-                    + "alternate between uniform colors which fill the view.<p>";
</del><ins>+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html (269729 => 269730)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html      2020-11-12 11:59:44 UTC (rev 269729)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html 2020-11-12 12:18:12 UTC (rev 269730)
</span><span class="lines">@@ -25,86 +25,30 @@
</span><span class="cx">             #item5 { background-color: fuchsia; }
</span><span class="cx">         </style>
</span><span class="cx">         <script src="../../../resources/js-test.js"></script>
</span><ins>+        <script src="../../../resources/ui-helper.js"></script>
+        <script src="resources/mainframe-scroll-snap-test.js"></script>
</ins><span class="cx">         <script>
</span><span class="cx">         window.jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-        var scrollingTarget;
-        var scrollPositionBeforeGlide;
-        var scrollPositionBeforeSnap;
-
-        function checkForScrollSnap()
</del><ins>+        async function runTests()
</ins><span class="cx">         {
</span><del>-            // The div should have snapped back to the previous position
-            if (scrollingTarget.scrollTop != scrollPositionBeforeSnap)
-                testFailed(`div did not snap back to proper location. (${scrollingTarget.scrollTop} vs. ${scrollPositionBeforeSnap})`);
-            else
-                testPassed("div honored snap points.");
-
</del><ins>+            await UIHelper.delayFor(0);
+            await scrollGlideShouldScrollTo(document.scrollingElement, VERTICAL, "window.innerHeight");
+            await UIHelper.delayFor(0);
+            await shortScrollShouldSnapBack(document.scrollingElement, VERTICAL);
</ins><span class="cx">             finishJSTest();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function scrollSnapTest()
-        {
-            scrollPositionBeforeSnap = scrollingTarget.scrollTop;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.callAfterScrollingCompletes(checkForScrollSnap);
-        }
-
-        function checkForScrollGlide()
-        {
-            // The div should have scrolled (glided) to the next snap point.
-            if (scrollingTarget.scrollTop == window.innerHeight)
-                testPassed("div scrolled to next window.");
-            else
-                testFailed(`div did not honor snap points. (${scrollingTarget.scrollTop} vs. ${window.innerHeight})`);
-
-            setTimeout(scrollSnapTest, 0);
-        }
-
-        function scrollGlideTest()
-        {
-            scrollPositionBeforeGlide = scrollingTarget.scrollTop;
-
-            var startPosX = scrollingTarget.offsetLeft + 20;
-            var startPosY = scrollingTarget.offsetTop + 20;
-            eventSender.monitorWheelEvents();
-            eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
-            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
-            eventSender.callAfterScrollingCompletes(checkForScrollGlide);
-        }
-
</del><span class="cx">         function onLoad()
</span><span class="cx">         {
</span><del>-            scrollingTarget = document.scrollingElement;
</del><span class="cx">             if (window.eventSender) {
</span><span class="cx">                 internals.setPlatformMomentumScrollingPredictionEnabled(false);
</span><del>-                setTimeout(scrollGlideTest, 0);
</del><ins>+                runTests();
</ins><span class="cx">             } else {
</span><span class="cx">                 var messageLocation = document.getElementById('item0');
</span><span class="cx">                 var message = document.createElement('div');
</span><del>-                message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
-                    + "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/>"
-                    + "small swipe gesture with some momentum.<br/><br/>"
-                    + "The region should scroll to show a green region.<br/><br/>"
-                    + "Next, perform a small scroll gesture that does not involve momentum. You should begin to see one of the colors<br/>"
-                    + "to the left (or right) of the current green box. When you release the wheel, the region should scroll back so<br/>"
-                    + "that the region is a single color.<br/><br/>"
-                    + "You should also be able to repeat these test steps for the vertical region below.</p>";
</del><ins>+                message.innerHTML = "<p>To run this test manually, scroll the page vertically. The page should "
+                    + "snap between uniform colors which fill the view.<p>";
</ins><span class="cx">                 messageLocation.appendChild(message);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>