| Index: third_party/WebKit/Source/core/dom/DocumentTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
|
| index c79b959aa029ba666b3cc04033426a54c150dbec..3edf8ca902d6d13f9cde4b8172776a40b871aedd 100644
|
| --- a/third_party/WebKit/Source/core/dom/DocumentTest.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
|
| @@ -797,4 +797,50 @@ TEST_F(DocumentTest, SuboriginDisablesAppCache) {
|
| EXPECT_TRUE(mock_web_host->without_manifest_was_called_);
|
| }
|
|
|
| +// Verifies that calling EnsureAuxiliaryLocationDataValidForNode cleans
|
| +// compositor inputs only when necessary. We generally want to avoid cleaning
|
| +// the compositing inputs, as it is more expensive than just doing layout.
|
| +TEST_F(
|
| + DocumentTest,
|
| + EnsureAuxiliaryLocationDataValidForNodeCompositingInputsOnlyWhenNecessary) {
|
| + GetDocument().body()->setInnerHTML(
|
| + "<div id='ancestor'>"
|
| + " <div id='sticky' style='position:sticky;'>"
|
| + " <div id='stickyChild'></div>"
|
| + " </div>"
|
| + " <div id='nonSticky'></div>"
|
| + "</div>");
|
| + EXPECT_EQ(DocumentLifecycle::kStyleClean,
|
| + GetDocument().Lifecycle().GetState());
|
| +
|
| + // Asking for any element that is not affected by a sticky element should only
|
| + // advance the lifecycle to layout clean.
|
| + GetDocument().EnsureAuxiliaryLocationDataValidForNode(
|
| + GetDocument().getElementById("ancestor"));
|
| + EXPECT_EQ(DocumentLifecycle::kLayoutClean,
|
| + GetDocument().Lifecycle().GetState());
|
| +
|
| + GetDocument().EnsureAuxiliaryLocationDataValidForNode(
|
| + GetDocument().getElementById("nonSticky"));
|
| + EXPECT_EQ(DocumentLifecycle::kLayoutClean,
|
| + GetDocument().Lifecycle().GetState());
|
| +
|
| + // However, asking for either the sticky element or it's descendents should
|
| + // clean compositing inputs as well.
|
| + GetDocument().EnsureAuxiliaryLocationDataValidForNode(
|
| + GetDocument().getElementById("sticky"));
|
| + EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
|
| + GetDocument().Lifecycle().GetState());
|
| +
|
| + // Dirty layout.
|
| + GetDocument().body()->setAttribute("style", "background: red;");
|
| + EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending,
|
| + GetDocument().Lifecycle().GetState());
|
| +
|
| + GetDocument().EnsureAuxiliaryLocationDataValidForNode(
|
| + GetDocument().getElementById("stickyChild"));
|
| + EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
|
| + GetDocument().Lifecycle().GetState());
|
| +}
|
| +
|
| } // namespace blink
|
|
|