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

Unified Diff: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp

Issue 2394053004: Clear scroll anchor on all parent scrollers from ScrollAnchor::clear (Closed)
Patch Set: review comments Created 4 years, 2 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 | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
index 60e58d7a6f792814e153818b217b46b0f6abb112..2001464266372a95230e976246c76d17283966f9 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -241,6 +241,34 @@ TEST_F(ScrollAnchorTest, AnchoringWhenContentRemovedFromScrollingDiv) {
scrollAnchor(scroller).anchorObject());
}
+// Test that a non-anchoring scroll on scroller clears scroll anchors for all
+// parent scrollers.
+TEST_F(ScrollAnchorTest, ClearScrollAnchorsOnAncestors) {
+ setBodyInnerHTML(
+ "<style>"
+ " body { height: 1000px } div { height: 200px }"
+ " #scroller { height: 100px; width: 200px; overflow: scroll; }"
+ "</style>"
+ "<div id='changer'>abc</div>"
+ "<div id='anchor'>def</div>"
+ "<div id='scroller'><div></div></div>");
+
+ ScrollableArea* viewport = layoutViewport();
+
+ scrollLayoutViewport(ScrollOffset(0, 250));
+ setHeight(document().getElementById("changer"), 300);
+
+ EXPECT_EQ(350, viewport->scrollOffsetInt().height());
+ EXPECT_EQ(document().getElementById("anchor")->layoutObject(),
+ scrollAnchor(viewport).anchorObject());
+
+ // Scrolling the nested scroller should clear the anchor on the main frame.
+ ScrollableArea* scroller =
+ scrollerForElement(document().getElementById("scroller"));
+ scroller->scrollBy(ScrollOffset(0, 100), UserScroll);
+ EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
+}
+
TEST_F(ScrollAnchorTest, FractionalOffsetsAreRoundedBeforeComparing) {
setBodyInnerHTML(
"<style> body { height: 1000px } </style>"
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698