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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/onscroll-bouncing.html

Issue 2002623003: Exclude position:absolute elements when picking an anchor for ScrollAnchoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script> 2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <script src="resources/scroll-anchoring-test.js"></script>
4 <style> 5 <style>
5 6
6 body { margin: 80px 0; height: 5000px; } 7 body { margin: 80px 0; height: 5000px; }
7 #a, #b { height: 200px; width: 200px; } 8 #a, #b { height: 200px; width: 200px; }
8 #c { height: 400px; } 9 #c { height: 400px; }
9 #left, #c { display: inline-block; width: 200px; vertical-align: top; } 10 #left, #c { display: inline-block; width: 200px; vertical-align: top; }
10 #a.f { position: fixed; top: 30px; left: 150px; } 11 #a.f { position: fixed; top: 30px; left: 150px; }
11 #a { background-color: #fcc; } 12 #a { background-color: #fcc; }
12 #b { background-color: #cfc; } 13 #b { background-color: #cfc; }
13 #c { background-color: #ccf; } 14 #c { background-color: #ccf; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 if (fixed == (y > 300)) 47 if (fixed == (y > 300))
47 return; 48 return;
48 if (y < 130) { 49 if (y < 130) {
49 // Clear the scroll anchor. 50 // Clear the scroll anchor.
50 scrollBy(0, 10); 51 scrollBy(0, 10);
51 scrollBy(0, -10); 52 scrollBy(0, -10);
52 } 53 }
53 a.className = (fixed = !fixed) ? "f" : ""; 54 a.className = (fixed = !fixed) ? "f" : "";
54 }; 55 };
55 56
56 var frame = () => new Promise((resolve) => { requestAnimationFrame(resolve); });
57
58 var waitFor = function(condition, failmsg, deadline) {
59 if (!deadline) deadline = Date.now() + 1000;
60 if (condition()) return Promise.resolve();
61 else if (Date.now() > deadline) return Promise.reject(failmsg);
62 else return frame().then(() => waitFor(condition, failmsg, deadline));
63 };
64
65 var waitFrames = function(n, condition, failmsg) {
66 var p = Promise.resolve();
67 var check = () => (!condition || condition() ?
68 Promise.resolve() : Promise.reject(failmsg));
69 while (n--)
70 p = p.then(check).then(frame);
71 return p.then(check);
72 };
73
74 var scrollSettlesAt = function(expectedY) {
75 return waitFor(() => (scrollY == expectedY),
76 "scroll did not reach " + expectedY)
77 .then(() => waitFrames(3))
78 .then(() => waitFrames(3, () => (scrollY == expectedY),
79 "scroll did not stay at " + expectedY));
80 };
81
82 promise_test(function() { 57 promise_test(function() {
83 return Promise.resolve() 58 return Promise.resolve()
84 59
85 // The 320px offset tests for the first failure mode. 60 // The 320px offset tests for the first failure mode.
86 .then(() => { eventSender.continuousMouseScrollBy(0, -320); }) 61 .then(() => { eventSender.continuousMouseScrollBy(0, -320); })
87 .then(() => scrollSettlesAt(320)) 62 .then(() => scrollSettlesAt(320))
88 63
89 .then(() => { scrollTo(0, 0); }) 64 .then(() => { scrollTo(0, 0); })
90 .then(() => frame()) 65 .then(() => frame())
91 66
92 // The 360px offset tests for the second failure mode. 67 // The 360px offset tests for the second failure mode.
93 .then(() => { eventSender.continuousMouseScrollBy(0, -360); }) 68 .then(() => { eventSender.continuousMouseScrollBy(0, -360); })
94 .then(() => scrollSettlesAt(360)); 69 .then(() => scrollSettlesAt(360));
95 70
96 }, "Scroll anchoring with scroll event handlers"); 71 }, "Scroll anchoring with scroll event handlers");
97 72
98 </script> 73 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698