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

Unified Diff: third_party/WebKit/LayoutTests/fast/css/sticky/sticky-style-change.html

Issue 2706673002: Mark elements as viewport constrained when they become sticky positioned (Closed)
Patch Set: Add LayoutTest Created 3 years, 10 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
Index: third_party/WebKit/LayoutTests/fast/css/sticky/sticky-style-change.html
diff --git a/third_party/WebKit/LayoutTests/fast/css/sticky/sticky-style-change.html b/third_party/WebKit/LayoutTests/fast/css/sticky/sticky-style-change.html
new file mode 100644
index 0000000000000000000000000000000000000000..deef30720fa01307ff97bd80bd0b881c5c04ac77
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/css/sticky/sticky-style-change.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<script>
+if (window.internals) {
+ internals.settings.setCSSStickyPositionEnabled(true);
+}
+</script>
+
+<html>
+<head>
+<style>
+ body {
+ margin: 0;
+ overflow: hidden; /* hide scrollbars */
+ }
+
+ .container {
+ height: 2000px;
+ }
+
+ .box {
+ height: 50px;
+ }
+
+ .sticky {
+ position: sticky;
+ top: 50px;
+ background-color: green;
+ }
+</style>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDone()
+
+ function doTest()
+ {
+ const sticky = document.querySelector('.sticky');
+ sticky.style.position = 'relative';
+
+ // Force layout.
+ var x = sticky.offsetTop;
flackr 2017/02/22 14:45:42 nit: just call stickyoffsetTop;
smcgruer 2017/02/22 15:26:31 Done.
+
+ sticky.style.position = 'sticky';
+
+ // Yield to allow the sticky change to 'stick'.
+ // TODO(smcgruer): If replaced with call to offsetTop, the sticky still
+ // breaks but blink seems to scroll first and then draw the item so it
+ // *looks* correct for the comparison. Expected?
flackr 2017/02/22 14:45:42 I think what happens is the change to position sti
smcgruer 2017/02/22 15:26:31 Done.
+ setTimeout(function() {
+ window.scrollTo(0, 100);
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, 0);
+ }
+
+ window.addEventListener('load', function() {
+ // The timeout is required to force CompositingInputsUpdater to fire at least
+ // once before we change the position.
+ // TODO(smcgruer): For some reason, a rAF does not wait for this, but a 0 second timeout does.
flackr 2017/02/22 14:45:42 This sounds likely to flake, I think setTimeout is
smcgruer 2017/02/22 15:26:31 Done.
+ setTimeout(doTest, 0);
+ });
+</script>
+</head>
+<body>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698