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

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

Issue 872433002: Fix flake in threaded CSSOM smooth scroll layout tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/scroll-behavior/resources/scroll-behavior-test.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this)); 69 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this));
70 } 70 }
71 71
72 SmoothScrollInterruptionTest.prototype.waitForSmoothScrollStart = function() { 72 SmoothScrollInterruptionTest.prototype.waitForSmoothScrollStart = function() {
73 if (this.scrollElement.scrollTop == this.scrollStartPoint) { 73 if (this.scrollElement.scrollTop == this.scrollStartPoint) {
74 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this)); 74 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this));
75 return; 75 return;
76 } 76 }
77 77
78 var scrollElement = this.scrollElement;
79 var scrollEndPoint = this.scrollEndPoint;
80 this.asyncTest.step(function() {
81 assert_not_equals(scrollElement.scrollTop, scrollEndPoint);
82 });
83
84 var testCase = this.testCases[this.currentTestCase]; 78 var testCase = this.testCases[this.currentTestCase];
85 testCase.interruptSmoothScroll(this); 79 testCase.interruptSmoothScroll(this);
86 window.requestAnimationFrame(testCase.verifyScrollInterrupted.bind(testCase, this, this.testCaseComplete.bind(this))); 80 window.requestAnimationFrame(testCase.verifyScrollInterrupted.bind(testCase, this, this.testCaseComplete.bind(this)));
87 } 81 }
88 82
89 SmoothScrollInterruptionTest.prototype.testCaseComplete = function() { 83 SmoothScrollInterruptionTest.prototype.testCaseComplete = function() {
90 this.asyncTest.done(); 84 this.asyncTest.done();
91 85
92 this.currentTestCase++; 86 this.currentTestCase++;
93 this.startNextTestCase(); 87 this.startNextTestCase();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 smoothScrollTest.asyncTest.step(function() { 134 smoothScrollTest.asyncTest.step(function() {
141 assert_not_equals(smoothScrollTest.scrollElement.scrollTop, smoothScroll Test.scrollNewEndpoint); 135 assert_not_equals(smoothScrollTest.scrollElement.scrollTop, smoothScroll Test.scrollNewEndpoint);
142 }); 136 });
143 137
144 this.scrollInterruptionPoint = smoothScrollTest.scrollElement.scrollTop; 138 this.scrollInterruptionPoint = smoothScrollTest.scrollElement.scrollTop;
145 } 139 }
146 140
147 function verifyScrollInterruptedBySmoothScroll(smoothScrollTest, verificationCom plete) { 141 function verifyScrollInterruptedBySmoothScroll(smoothScrollTest, verificationCom plete) {
148 var currentPosition = smoothScrollTest.scrollElement.scrollTop; 142 var currentPosition = smoothScrollTest.scrollElement.scrollTop;
149 143
150 if (currentPosition < this.scrollInterruptionPoint && currentPosition > smoo thScrollTest.scrollNewEndpoint) { 144 if (currentPosition < this.scrollInterruptionPoint && currentPosition >= smo othScrollTest.scrollNewEndpoint) {
151 verificationComplete(); 145 verificationComplete();
152 } else { 146 } else {
153 window.requestAnimationFrame(this.verifyScrollInterrupted.bind(this, smo othScrollTest, verificationComplete)); 147 window.requestAnimationFrame(this.verifyScrollInterrupted.bind(this, smo othScrollTest, verificationComplete));
154 } 148 }
155 } 149 }
156 150
157 function interruptWithTouchScroll(smoothScrollTest) { 151 function interruptWithTouchScroll(smoothScrollTest) {
158 if (window.eventSender) { 152 if (window.eventSender) {
159 window.eventSender.gestureScrollBegin(smoothScrollTest.innerPoint.x, smo othScrollTest.innerPoint.y); 153 window.eventSender.gestureScrollBegin(smoothScrollTest.innerPoint.x, smo othScrollTest.innerPoint.y);
160 window.eventSender.gestureScrollUpdate(0, -10); 154 window.eventSender.gestureScrollUpdate(0, -10);
(...skipping 28 matching lines...) Expand all
189 } 183 }
190 184
191 function interruptWithWheelScroll(smoothScrollTest) { 185 function interruptWithWheelScroll(smoothScrollTest) {
192 if (window.eventSender) { 186 if (window.eventSender) {
193 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro llTest.innerPoint.y); 187 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro llTest.innerPoint.y);
194 window.eventSender.mouseScrollBy(0, -10); 188 window.eventSender.mouseScrollBy(0, -10);
195 } else { 189 } else {
196 document.write("This test does not work in manual mode."); 190 document.write("This test does not work in manual mode.");
197 } 191 }
198 } 192 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/scroll-behavior/resources/scroll-behavior-test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698