Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <script src="../../../resources/testharness.js"></script> | |
| 2 <script src="../../../resources/testharnessreport.js"></script> | |
| 3 <style> | |
| 4 body { | |
| 5 margin: 0px; | |
| 6 height: 2000px; | |
| 7 width: 2000px; | |
| 8 } | |
| 9 #changer { | |
| 10 background-color: #FF7F7F; | |
| 11 height: 10px; | |
| 12 } | |
| 13 #anchor { | |
| 14 height: 1500px; | |
| 15 background-color: #84BE6A; | |
| 16 } | |
| 17 </style> | |
| 18 | |
| 19 <div id="changer"></div> | |
| 20 <div id="anchor"></div> | |
| 21 | |
| 22 <script> | |
| 23 var asyncTest = async_test("Verify smooth scroll interaction with scroll anchr oing"); | |
| 24 | |
| 25 // The element that will change in height. | |
| 26 var ch; | |
| 27 | |
| 28 // Initital scroll position. | |
| 29 var initialX = 0; | |
| 30 var initialY = 10; | |
| 31 // Amount to smooth scroll by. | |
| 32 var userScrollX = 51; | |
| 33 var userScrollY = 205; | |
| 34 // Amount to change the height of the element above the viewport. | |
| 35 var changerY = 100; | |
| 36 // End position: initial + scroll + changer | |
| 37 var endX = 51; | |
| 38 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.
| |
| 39 | |
| 40 function scrollListener() { | |
| 41 if (window.scrollX == endX && window.scrollY == endY) { | |
| 42 asyncTest.done(); | |
| 43 return; | |
| 44 } | |
| 45 | |
| 46 if (ch.style.height != "100") | |
| 47 ch.style.height = changerY; | |
| 48 } | |
| 49 | |
| 50 window.onload = function() { | |
| 51 // Turn on smooth scrolling. | |
| 52 internals.settings.setScrollAnimatorEnabled(true); | |
| 53 | |
| 54 ch = document.getElementById("changer"); | |
| 55 document.getElementById('anchor').scrollIntoView(); | |
| 56 | |
| 57 // Smooth scroll. | |
| 58 eventSender.mouseMoveTo(100, 100); | |
| 59 eventSender.continuousMouseScrollBy(-userScrollX, -userScrollY); | |
| 60 | |
| 61 asyncTest.step(function() { | |
| 62 assert_equals(window.scrollX, initialX); | |
| 63 assert_equals(window.scrollY, initialY); | |
| 64 }); | |
| 65 | |
| 66 document.addEventListener("scroll", scrollListener); | |
| 67 } | |
| 68 </script> | |
| OLD | NEW |