Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/ongoing-smooth-scroll-anchors.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/ongoing-smooth-scroll-anchors.html b/third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/ongoing-smooth-scroll-anchors.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..db89e5e8b77f5acc5ce311ca0be5b8e563b369fb |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/ongoing-smooth-scroll-anchors.html |
| @@ -0,0 +1,68 @@ |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<style> |
| + body { |
| + margin: 0px; |
| + height: 2000px; |
| + width: 2000px; |
| + } |
| + #changer { |
| + background-color: #FF7F7F; |
| + height: 10px; |
| + } |
| + #anchor { |
| + height: 1500px; |
| + background-color: #84BE6A; |
| + } |
| +</style> |
| + |
| +<div id="changer"></div> |
| +<div id="anchor"></div> |
| + |
| +<script> |
| + var asyncTest = async_test("Verify smooth scroll interaction with scroll anchroing"); |
| + |
| + // The element that will change in height. |
| + var ch; |
| + |
| + // Initital scroll position. |
| + var initialX = 0; |
| + var initialY = 10; |
| + // Amount to smooth scroll by. |
| + var userScrollX = 51; |
| + var userScrollY = 205; |
| + // Amount to change the height of the element above the viewport. |
| + var changerY = 100; |
| + // End position: initial + scroll + changer |
| + var endX = 51; |
| + var endY = 305; |
|
ajuma
2016/04/27 15:46:10
Should this be 315 (by the math from the comment a
ymalik
2016/04/27 16:21:38
The comment is wrong. Fixed.
|
| + |
| + function scrollListener() { |
| + if (window.scrollX == endX && window.scrollY == endY) { |
| + asyncTest.done(); |
| + return; |
| + } |
| + |
| + if (ch.style.height != "100") |
| + ch.style.height = changerY; |
| + } |
| + |
| + window.onload = function() { |
| + // Turn on smooth scrolling. |
| + internals.settings.setScrollAnimatorEnabled(true); |
| + |
| + ch = document.getElementById("changer"); |
| + document.getElementById('anchor').scrollIntoView(); |
| + |
| + // Smooth scroll. |
| + eventSender.mouseMoveTo(100, 100); |
| + eventSender.continuousMouseScrollBy(-userScrollX, -userScrollY); |
| + |
| + asyncTest.step(function() { |
| + assert_equals(window.scrollX, initialX); |
| + assert_equals(window.scrollY, initialY); |
| + }); |
| + |
| + document.addEventListener("scroll", scrollListener); |
| + } |
| +</script> |