Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/main-thread-scrolling-reason-correctness.html

Issue 1648293003: Fix smooth scroll jump when switching scroll handling between MT and CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skip irrelevant test on mac Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/main-thread-scrolling-reason-correctness.html
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/main-thread-scrolling-reason-correctness.html b/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/main-thread-scrolling-reason-correctness.html
new file mode 100644
index 0000000000000000000000000000000000000000..2c785326444dda114f2a25f332cabb728b0386c1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/main-thread-scrolling-reason-correctness.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<script src="../../../../../resources/js-test.js"></script>
+<style>
+body {
+ width: 2000px;
+ height: 2000px;
+}
+</style>
+
+<script>
+var jsTestIsAsync = true;
+
+description("This test verifies that the ScrollAnimator can schedule " +
+ "animations on the compositor when it adds a temporary main thread " +
+ "scrolling reason.");
+
+// From ScrollingCoordinator::mainThreadScrollingReasonsAsText.
+var ANIMATING_TEXT = 'Animating scroll on main thread';
+// From ScrollAnimatorCompositorCoordinator::RunState.
+var RUNNING_ON_COMPOSITOR = 2;
+var RUNNING_ON_COMPOSITOR_BUT_NEEDS_UPDATE = 3;
+
+function finishTest() {
+ requestAnimationFrame(function() {
+ // Check that main thread scrolling reason is removed.
+ shouldBeTrue("internals.mainThreadScrollingReasons(document) == ''");
+ finishJSTest();
+ });
+}
+
+function needsUpdateOrRunningOnCompositor(node) {
+ var state = internals.getScrollAnimationState(node);
+ return state == RUNNING_ON_COMPOSITOR ||
+ state == RUNNING_ON_COMPOSITOR_BUT_NEEDS_UPDATE;
+}
+
+function runTest() {
+ if (document.scrollingElement.scrollTop == 0) {
+ requestAnimationFrame(runTest);
+ } else {
+ // Check that initiated by main thread and running on the compositor.
+ shouldBeTrue("internals.getScrollAnimationState(document) " +
+ "== RUNNING_ON_COMPOSITOR");
+ // Check that main thread scrolling reason is added.
+ shouldBeTrue("internals.mainThreadScrollingReasons(document) " +
+ "== ANIMATING_TEXT");
+
+ // Scroll 1 more tick down.
+ eventSender.mouseScrollBy(0, -1);
+ shouldBeTrue("internals.getScrollAnimationState(document) " +
+ "== RUNNING_ON_COMPOSITOR_BUT_NEEDS_UPDATE");
+
+ requestAnimationFrame(function() {
+ // Check that the temporary main thread scrolling is still there
+ // and running on the compositor.
+ shouldBeTrue("internals.mainThreadScrollingReasons(document) " +
+ "== ANIMATING_TEXT");
+ shouldBeTrue("needsUpdateOrRunningOnCompositor(document)");
+ shouldBecomeEqual("document.scrollingElement.scrollTop == 80",
+ "true", finishTest);
+ });
+ }
+}
+
+onload = function() {
+ if (!window.eventSender || !window.internals) {
+ debug("This test requires window.eventSender.")
+ finishJSTest();
+ return;
+ }
+ internals.settings.setScrollAnimatorEnabled(true);
+
+ document.scrollingElement.scrollTop = 0;
+
+ // Scroll 1 ticks down.
+ eventSender.mouseMoveTo(20, 20);
+ eventSender.mouseScrollBy(0, -1);
+ runTest();
+};
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698