Simulate user inputs in css-scroll-snap/snap-at-user-scroll-end.html

Use testdriver Action API to simulate wheel scroll actions in
css/css-scroll-snap/snap-at-user-scroll-end.html.

Bug: 1145677
Change-Id: I98e121d71257c2f64244bfee48821fc65a988097
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2569986
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#856129}
diff --git a/css/css-scroll-snap/snap-at-user-scroll-end-manual.html b/css/css-scroll-snap/snap-at-user-scroll-end.html
similarity index 77%
rename from css/css-scroll-snap/snap-at-user-scroll-end-manual.html
rename to css/css-scroll-snap/snap-at-user-scroll-end.html
index 373e3fc..8643b3c 100644
--- a/css/css-scroll-snap/snap-at-user-scroll-end-manual.html
+++ b/css/css-scroll-snap/snap-at-user-scroll-end.html
@@ -3,6 +3,10 @@
 <title>Tests that window should snap at user scroll end.</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="support/common.js"></script>
 <style>
 html {
   margin: 0px;
@@ -55,6 +59,9 @@
 var scrolled_y = false;
 var start_x = window.scrollX;
 var start_y = window.scrollY;
+var actions_promise;
+
+scrollTop = () => window.scrollY;
 
 window.onscroll = function() {
   if (scrolled_x && scrolled_y) {
@@ -84,7 +91,21 @@
   // To make the test result visible.
   var content = document.getElementById("content");
   body.removeChild(content);
-  snap_test.done();
+  actions_promise.then( () => {
+    snap_test.done();
+  });
 }
 
+// Inject scroll actions.
+const pos_x = 20;
+const pos_y = 20;
+const scroll_delta_x = 100;
+const scroll_delta_y = 100;
+actions_promise = new test_driver.Actions()
+    .scroll(pos_x, pos_y, scroll_delta_x, scroll_delta_y)
+    .send().then(() => {
+  return waitForAnimationEnd(scrollTop);
+}).then(() => {
+  return test_driver.click(button);
+});
 </script>