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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/scroll-behavior/resources/scroll-interruption-test.js

Issue 2511473003: Round the scroll offset synced back to main instead of flooring. (Closed)
Patch Set: Wait for scroll animation to complete before checking main thread scrolling reasons. Created 4 years 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 unified diff | Download patch
OLDNEW
1 // A SmoothScrollInterruptionTest verifies that in-progress smooth scrolls 1 // A SmoothScrollInterruptionTest verifies that in-progress smooth scrolls
2 // stop when interrupted by an instant scroll, another smooth scroll, a 2 // stop when interrupted by an instant scroll, another smooth scroll, a
3 // touch scroll, or a mouse wheel scroll. 3 // touch scroll, or a mouse wheel scroll.
4 // 4 //
5 // The only SmoothScrollInerruptionTest method that should be called by 5 // The only SmoothScrollInerruptionTest method that should be called by
6 // outside code is run(). 6 // outside code is run().
7 // 7 //
8 // Creates a SmoothScrollInterruptionTest with arguments: 8 // Creates a SmoothScrollInterruptionTest with arguments:
9 // scrollElement - Element being scrolled. 9 // scrollElement - Element being scrolled.
10 // innerPoint - Absolute position (expressed as a dictionary with x and y fields ) 10 // innerPoint - Absolute position (expressed as a dictionary with x and y fields )
(...skipping 29 matching lines...) Expand all
40 return; 40 return;
41 } 41 }
42 42
43 var testCase = this.testCases[this.currentTestCase]; 43 var testCase = this.testCases[this.currentTestCase];
44 this.asyncTest = async_test(testCase.description); 44 this.asyncTest = async_test(testCase.description);
45 45
46 var scrollElement = this.scrollElement; 46 var scrollElement = this.scrollElement;
47 var scrollStartPoint = this.scrollStartPoint; 47 var scrollStartPoint = this.scrollStartPoint;
48 48
49 scrollElement.scrollTop = scrollStartPoint; 49 scrollElement.scrollTop = scrollStartPoint;
50 window.requestAnimationFrame(this.performSmoothScroll.bind(this)); 50 window.requestAnimationFrame(this.waitForSyncScroll.bind(this));
51 }
52
53 SmoothScrollInterruptionTest.prototype.waitForSyncScroll = function() {
54 // Wait until cc has received the commit from main with the scrollStartPoint.
55 if (this.scrollElement.scrollTop != this.scrollStartPoint) {
56 // TODO(flackr): There seems to be a bug in that we shouldn't have to
57 // reapply the scroll position when cancelling a smooth scroll.
58 // https://crbug.com/667477
59 this.scrollElement.scrollTop = this.scrollStartPoint;
60 window.requestAnimationFrame(this.waitForSyncScroll.bind(this));
61 return;
62 }
63
64 this.performSmoothScroll();
51 } 65 }
52 66
53 SmoothScrollInterruptionTest.prototype.performSmoothScroll = function() { 67 SmoothScrollInterruptionTest.prototype.performSmoothScroll = function() {
54 var testCase = this.testCases[this.currentTestCase]; 68 var testCase = this.testCases[this.currentTestCase];
55 var scrollElement = this.scrollElement; 69 var scrollElement = this.scrollElement;
56 var scrollStartPoint = this.scrollStartPoint; 70 var scrollStartPoint = this.scrollStartPoint;
57 71
58 this.jsScroll(this.scrollEndPoint); 72 this.jsScroll(this.scrollEndPoint);
59 this.asyncTest.step(function() { 73 this.asyncTest.step(function() {
60 assert_equals(scrollElement.scrollTop, scrollStartPoint); 74 assert_equals(scrollElement.scrollTop, scrollStartPoint);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 197 }
184 198
185 function interruptWithWheelScroll(smoothScrollTest) { 199 function interruptWithWheelScroll(smoothScrollTest) {
186 if (window.eventSender) { 200 if (window.eventSender) {
187 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro llTest.innerPoint.y); 201 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro llTest.innerPoint.y);
188 window.eventSender.mouseScrollBy(0, -10); 202 window.eventSender.mouseScrollBy(0, -10);
189 } else { 203 } else {
190 document.write("This test does not work in manual mode."); 204 document.write("This test does not work in manual mode.");
191 } 205 }
192 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698