| Index: third_party/WebKit/Source/core/frame/FrameViewTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/FrameViewTest.cpp b/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
|
| index e78918f7c7c59a1c86378089513177ec720548db..40498645a6aef0b30bc18419dec4e99b17d2cffd 100644
|
| --- a/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
|
| @@ -172,31 +172,57 @@ TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) {
|
|
|
| document().body()->setInnerHTML(
|
| "<style>.container { height: 200%; }"
|
| - "#sticky { position: sticky; top: 0; height: 50px; }</style>"
|
| - "<div class='container'><div id='sticky'></div></div>");
|
| + "#sticky1 { position: sticky; top: 0; height: 50px; }"
|
| + "#sticky2 { position: sticky; height: 50px; }</style>"
|
| + "<div class='container'>"
|
| + " <div id='sticky1'></div>"
|
| + " <div id='sticky2'></div>"
|
| + "</div>");
|
| document().view()->updateAllLifecyclePhases();
|
|
|
| - LayoutBoxModelObject* sticky = toLayoutBoxModelObject(
|
| - document().getElementById("sticky")->layoutObject());
|
| + LayoutBoxModelObject* sticky1 = toLayoutBoxModelObject(
|
| + document().getElementById("sticky1")->layoutObject());
|
| + LayoutBoxModelObject* sticky2 = toLayoutBoxModelObject(
|
| + document().getElementById("sticky2")->layoutObject());
|
|
|
| EXPECT_TRUE(
|
| - document().view()->viewportConstrainedObjects()->contains(sticky));
|
| + document().view()->viewportConstrainedObjects()->contains(sticky1));
|
| + // #sticky2 is not viewport constrained because it has no anchor edges.
|
| + EXPECT_FALSE(
|
| + document().view()->viewportConstrainedObjects()->contains(sticky2));
|
|
|
| // Making the element non-sticky should remove it from the set of
|
| // viewport-constrained objects.
|
| - document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr,
|
| - "position: relative");
|
| + document().getElementById("sticky1")->setAttribute(HTMLNames::styleAttr,
|
| + "position: relative");
|
| document().view()->updateAllLifecyclePhases();
|
|
|
| EXPECT_FALSE(
|
| - document().view()->viewportConstrainedObjects()->contains(sticky));
|
| + document().view()->viewportConstrainedObjects()->contains(sticky1));
|
|
|
| // And making it sticky again should put it back in that list.
|
| - document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, "");
|
| + document().getElementById("sticky1")->setAttribute(HTMLNames::styleAttr, "");
|
| + document().view()->updateAllLifecyclePhases();
|
| +
|
| + EXPECT_TRUE(
|
| + document().view()->viewportConstrainedObjects()->contains(sticky1));
|
| +
|
| + // Adding an anchor edge on the non-anchored sticky should add it to the
|
| + // viewport-constrained objects.
|
| + document().getElementById("sticky2")->setAttribute(HTMLNames::styleAttr,
|
| + "top: 0");
|
| document().view()->updateAllLifecyclePhases();
|
|
|
| EXPECT_TRUE(
|
| - document().view()->viewportConstrainedObjects()->contains(sticky));
|
| + document().view()->viewportConstrainedObjects()->contains(sticky2));
|
| +
|
| + // Removing the anchor edge on a sticky position element should remove it from
|
| + // the viewport-constrained objects.
|
| + document().getElementById("sticky2")->setAttribute(HTMLNames::styleAttr, "");
|
| + document().view()->updateAllLifecyclePhases();
|
| +
|
| + EXPECT_FALSE(
|
| + document().view()->viewportConstrainedObjects()->contains(sticky2));
|
| }
|
|
|
| } // namespace
|
|
|