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

Unified Diff: third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/feedback-loop.html

Issue 2118683002: Limit ScrollAnchor to 20 adjustments between user scrolls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/feedback-loop.html
diff --git a/third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/feedback-loop.html b/third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/feedback-loop.html
new file mode 100644
index 0000000000000000000000000000000000000000..2bfe126d2c264769398928f19f913f217f593c61
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/feedback-loop.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<style>
+
+body { margin: 0; height: 5000px; }
+#evil { height: 200px; width: 200px; background-color: #fcc; }
+
+</style>
+<div id="evil"></div>
+<script>
+
+internals.runtimeFlags.scrollAnchoringEnabled = true;
+
+var kMaxAdjustments = 20; // Keep in sync with kMaxAdjustments in ScrollAnchor.cpp
+
+var evil = document.querySelector('#evil');
+onscroll = () => { evil.style.marginTop = scrollY + "px"; };
+
+var frame = () => new Promise((resolve) => { requestAnimationFrame(resolve); });
+
+var waitFor = function(condition, failmsg, deadline) {
+ if (!deadline) deadline = Date.now() + 1000;
+ if (condition()) return Promise.resolve();
+ else if (Date.now() > deadline) return Promise.reject(failmsg);
+ else return frame().then(() => waitFor(condition, failmsg, deadline));
+};
+
+var waitFrames = function(n, condition, failmsg) {
+ var p = Promise.resolve();
+ var check = () => (!condition || condition() ?
+ Promise.resolve() : Promise.reject(failmsg));
+ while (n--)
+ p = p.then(check).then(frame);
+ return p.then(check);
+};
+
+var scrollSettlesAt = function(expectedY) {
+ return waitFor(() => (scrollY == expectedY),
+ "scroll did not reach " + expectedY)
+ .then(() => waitFrames(3))
+ .then(() => waitFrames(3, () => (scrollY == expectedY),
+ "scroll did not stay at " + expectedY));
+};
+
+promise_test(function() {
+ var y = 10;
+ return Promise.resolve()
+ .then(() => { scrollTo(0, y); })
+ .then(() => scrollSettlesAt(y + kMaxAdjustments * y));
+}, "Scroll anchoring with scroll event handler feedback loop");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698