Chromium Code Reviews| 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 2fb1618e812e260690b26b83dba7947b51760d1b..571ded339671ea6e56b739a6b548dec6e3d97a1b 100644 |
| --- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp |
| +++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp |
| @@ -155,6 +155,45 @@ TEST_F(ScrollAnchorTest, VisualViewportAnchors) |
| EXPECT_EQ(nullptr, scrollAnchor(lViewport).anchorObject()); |
| } |
| +// Test that we don't descend into elements that clip overflow content since we |
|
skobes
2016/07/11 21:25:03
nit: it's not that we will never descend into them
ymalik
2016/07/11 21:35:34
Done!
|
| +// may end up with an anchor that we think is in the viewport but is really not. |
| +TEST_F(ScrollAnchorTest, ClippedScrollersSkipped) |
| +{ |
| + setBodyInnerHTML( |
| + "<style>" |
| + " body { height: 2000px; }" |
| + " #scroller { overflow: scroll; width: 500px; height: 300px; }" |
| + " .anchor {" |
| + " position:relative; height: 100px; width: 150px;" |
| + " background-color: #afa; border: 1px solid gray;" |
| + " }" |
| + " #forceScrolling { height: 500px; background-color: #fcc; }" |
| + "</style>" |
| + "<div id='scroller'>" |
| + " <div id='innerChanger'></div>" |
| + " <div id='innerAnchor' class='anchor'></div>" |
| + " <div id='forceScrolling'></div>" |
| + "</div>" |
| + "<div id='outerChanger'></div>" |
| + "<div id='outerAnchor' class='anchor'></div>"); |
| + |
| + ScrollableArea* scroller = scrollerForElement(document().getElementById("scroller")); |
| + ScrollableArea* viewport = layoutViewport(); |
| + |
| + document().getElementById("scroller")->setScrollTop(100); |
| + scrollLayoutViewport(DoubleSize(0, 350)); |
| + |
| + setHeight(document().getElementById("innerChanger"), 200); |
| + setHeight(document().getElementById("outerChanger"), 150); |
| + |
| + EXPECT_EQ(300, scroller->scrollPosition().y()); |
| + EXPECT_EQ(document().getElementById("innerAnchor")->layoutObject(), |
| + scrollAnchor(scroller).anchorObject()); |
| + EXPECT_EQ(500, viewport->scrollPosition().y()); |
| + EXPECT_EQ(document().getElementById("outerAnchor")->layoutObject(), |
| + scrollAnchor(viewport).anchorObject()); |
| +} |
| + |
| TEST_F(ScrollAnchorTest, FractionalOffsetsAreRoundedBeforeComparing) |
| { |
| setBodyInnerHTML( |