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

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

Issue 387553003: Fix use of wrong variable in ScrollBehaviorTest (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | « no previous file | 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 ScrollBehaviorTest runs a set of ScrollBehaviorTestCases. The only 1 // A ScrollBehaviorTest runs a set of ScrollBehaviorTestCases. The only
2 // ScrollBehaviorTest method that should be called by external code is run(). 2 // ScrollBehaviorTest method that should be called by external code is run().
3 3
4 // Creates a ScrollBehaviorTest with arguments: 4 // Creates a ScrollBehaviorTest with arguments:
5 // scrollElement - Element being scrolled. 5 // scrollElement - Element being scrolled.
6 // scrollEventTarget - Target for scroll events for |scrollElement|. 6 // scrollEventTarget - Target for scroll events for |scrollElement|.
7 // testsCases - Array of ScrollBehaviorTestCases. 7 // testsCases - Array of ScrollBehaviorTestCases.
8 // getEndPosition - Callback that takes a test case and start position, and 8 // getEndPosition - Callback that takes a test case and start position, and
9 // returns the corresponding end position (where positions 9 // returns the corresponding end position (where positions
10 // are dictionaries with x and y fields). 10 // are dictionaries with x and y fields).
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 ScrollBehaviorTest.prototype.scrollListener = function(testCase) { 29 ScrollBehaviorTest.prototype.scrollListener = function(testCase) {
30 if (testCase.waitForEnd) { 30 if (testCase.waitForEnd) {
31 if (this.scrollElement.scrollLeft == testCase.endX && this.scrollElement .scrollTop == testCase.endY) 31 if (this.scrollElement.scrollLeft == testCase.endX && this.scrollElement .scrollTop == testCase.endY)
32 this.testCaseComplete(); 32 this.testCaseComplete();
33 return; 33 return;
34 } 34 }
35 35
36 // Wait for an intermediate frame, then instant-scroll to the end state. 36 // Wait for an intermediate frame, then instant-scroll to the end state.
37 if ((this.scrollElement.scrollLeft != testCase.startX || this.scrollElement. scrollTop != this.scrollElement.startY) && 37 if ((this.scrollElement.scrollLeft != testCase.startX || this.scrollElement. scrollTop != testCase.startY) &&
38 (this.scrollElement.scrollLeft != testCase.endX || this.scrollElement.sc rollTop != this.scrollElement.endY)) { 38 (this.scrollElement.scrollLeft != testCase.endX || this.scrollElement.sc rollTop != testCase.endY)) {
39 this.scrollElement.scrollLeft = {x: testCase.endX, behavior: "instant"}; 39 this.scrollElement.scrollLeft = {x: testCase.endX, behavior: "instant"};
40 this.scrollElement.scrollTop = {y: testCase.endY, behavior: "instant"}; 40 this.scrollElement.scrollTop = {y: testCase.endY, behavior: "instant"};
41 this.testCaseComplete(); 41 this.testCaseComplete();
42 } 42 }
43 }; 43 };
44 44
45 ScrollBehaviorTest.prototype.startNextTestCase = function() { 45 ScrollBehaviorTest.prototype.startNextTestCase = function() {
46 if (this.currentTestCase >= this.testCases.length) { 46 if (this.currentTestCase >= this.testCases.length) {
47 this.allTestCasesComplete(); 47 this.allTestCasesComplete();
48 return; 48 return;
(...skipping 12 matching lines...) Expand all
61 testCase.setEndPosition(endPosition); 61 testCase.setEndPosition(endPosition);
62 62
63 this.scrollElement.style.scrollBehavior = testCase.css; 63 this.scrollElement.style.scrollBehavior = testCase.css;
64 this.jsScroll(testCase); 64 this.jsScroll(testCase);
65 65
66 var scrollElement = this.scrollElement; 66 var scrollElement = this.scrollElement;
67 if (isSmoothTest) { 67 if (isSmoothTest) {
68 this.asyncTest.step(function() { 68 this.asyncTest.step(function() {
69 assert_equals(scrollElement.scrollLeft + ", " + scrollElement.scroll Top, testCase.startX + ", " + testCase.startY); 69 assert_equals(scrollElement.scrollLeft + ", " + scrollElement.scroll Top, testCase.startX + ", " + testCase.startY);
70 }); 70 });
71 testCase.scrollListener = this.scrollListener.bind(this, testCase); 71 if (scrollElement.scrollLeft == testCase.endX && scrollElement.scrollTop == testCase.endY) {
72 this.scrollEventTarget.addEventListener("scroll", testCase.scrollListene r); 72 // We've instant-scrolled. This means we've already failed the asser t above, and will never
73 // reach an intermediate frame. End the test case now to avoid hangi ng while waiting for an
74 // intermediate frame.
75 this.testCaseComplete();
76 } else {
77 testCase.scrollListener = this.scrollListener.bind(this, testCase);
78 this.scrollEventTarget.addEventListener("scroll", testCase.scrollLis tener);
79 }
73 } else { 80 } else {
74 this.asyncTest.step(function() { 81 this.asyncTest.step(function() {
75 assert_equals(scrollElement.scrollLeft + ", " + scrollElement.scroll Top, testCase.endX + ", " + testCase.endY); 82 assert_equals(scrollElement.scrollLeft + ", " + scrollElement.scroll Top, testCase.endX + ", " + testCase.endY);
76 }); 83 });
77 this.testCaseComplete(); 84 this.testCaseComplete();
78 } 85 }
79 } 86 }
80 87
81 ScrollBehaviorTest.prototype.testCaseComplete = function() { 88 ScrollBehaviorTest.prototype.testCaseComplete = function() {
82 var currentScrollListener = this.testCases[this.currentTestCase].scrollListe ner; 89 var currentScrollListener = this.testCases[this.currentTestCase].scrollListe ner;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 125
119 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { 126 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) {
120 this.startX = startPosition.x; 127 this.startX = startPosition.x;
121 this.startY = startPosition.y; 128 this.startY = startPosition.y;
122 } 129 }
123 130
124 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { 131 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) {
125 this.endX = endPosition.x; 132 this.endX = endPosition.x;
126 this.endY = endPosition.y; 133 this.endY = endPosition.y;
127 } 134 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698