Increase max frame count in observeScrolling helper.

When threaded compositing is disabled, frames are not tied to vsync and
may pump more quickly (at intervals as short as 1ms, see task posted in
WebTestWebFrameWidgetImpl::ScheduleAnimationInternal).

This means the test may observe more than 500 frames before the end of a
smooth scroll, when running under run_web_tests.py on Chromium bots.

Bug: 888443
Change-Id: I6b2d45cbb1ee7c346e07bc5b5ad0c6d295fd127a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5184797
Commit-Queue: Steve Kobes <skobes@chromium.org>
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1246027}
diff --git a/css/cssom-view/support/scroll-behavior.js b/css/cssom-view/support/scroll-behavior.js
index 0a0968e..b22ebf8 100644
--- a/css/cssom-view/support/scroll-behavior.js
+++ b/css/cssom-view/support/scroll-behavior.js
@@ -1,3 +1,5 @@
+// TODO(crbug.com/888443): It would be better to listen to the scrollend event
+// instead of polling the scroll position.
 function observeScrolling(elements, callback) {
   if (!Array.isArray(elements))
       elements = [elements];
@@ -9,9 +11,12 @@
     lastTop.set(element, element.scrollTop);
   });
   function tick(frames) {
-    // We requestAnimationFrame either for 500 frames or until 20 frames with
-    // no change have been observed.
-    if (frames >= 500 || frames - lastChangedFrame > 20) {
+    // We requestAnimationFrame either for 5000 frames or until 20 frames with
+    // no change have been observed. (In Chromium, frames may run as frequently
+    // as once per millisecond when threaded compositing is disabled. The limit
+    // of 5000 frames is chosen to be high enough to reasonably ensure any
+    // scroll animation will run to completion.)
+    if (frames >= 5000 || frames - lastChangedFrame > 20) {
       callback(true);
     } else {
       var scrollHappened = elements.some((element) => {