| Index: third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/cancel-user-scroll.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/cancel-user-scroll.html b/third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/cancel-user-scroll.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dfb5fc166c3d37b654944f6aa55b205506160111
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/fast/scroll-behavior/smooth-scroll/cancel-user-scroll.html
|
| @@ -0,0 +1,67 @@
|
| +<!DOCTYPE HTML>
|
| +<head>
|
| + <script src="../../../resources/js-test.js"></script>
|
| + <style>
|
| + #spacer {
|
| + height: 10000px;
|
| + width: 10000px;
|
| + }
|
| + </style>
|
| + <script>
|
| + function failTest(why) {
|
| + testFailed(why);
|
| + if (testRunner)
|
| + testRunner.notifyDone();
|
| + }
|
| +
|
| + function execInNRafs(n, func) {
|
| + var count = n;
|
| + var rafCall = function() {
|
| + count--;
|
| + if (count <= 0)
|
| + func();
|
| + else
|
| + requestAnimationFrame(rafCall);
|
| + };
|
| +
|
| + requestAnimationFrame(rafCall);
|
| + }
|
| +
|
| + internals.settings.setScrollAnimatorEnabled(true);
|
| + internals.settings.setMockScrollbarsEnabled(false);
|
| +
|
| + if (testRunner) {
|
| + testRunner.waitUntilDone();
|
| + }
|
| +
|
| + onload = function() {
|
| + var checkScroll = function() {
|
| + shouldBe('window.scrollY', '0');
|
| + testRunner.notifyDone();
|
| + }
|
| +
|
| + var numScrolls = 0;
|
| + window.addEventListener('scroll', function() {
|
| + ++numScrolls;
|
| + if (numScrolls == 2) {
|
| + // This programmatic scroll should cancel the user scroll.
|
| + window.scrollTo(0, 0);
|
| + } else if (numScrolls == 3) {
|
| + // End the test a small delay and check that we haven't scrolled
|
| + // any more after that delay.
|
| + shouldBe('window.scrollY', '0');
|
| + execInNRafs(10, checkScroll);
|
| + } else if (numScrolls > 3) {
|
| + // Fail if we receive any more scrolls.
|
| + failTest('Continued user scroll after programmatic scroll.');
|
| + }
|
| + });
|
| +
|
| + window.eventSender.keyDown('end');
|
| + };
|
| + </script>
|
| +</head>
|
| +
|
| +<body>
|
| + <div id="spacer"></div>
|
| +</body>
|
|
|