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

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

Issue 1961243002: Round anchor offsets to DIPs in ScrollAnchor::restore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak and add comments Created 4 years, 7 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/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 194ae5e604e12b76cd094bed82b273253e8e7973..8f76258d676c8a8721855fa796c5cb98cf06c951 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -84,6 +84,23 @@ TEST_F(ScrollAnchorTest, Basic)
EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
}
+TEST_F(ScrollAnchorTest, FractionalOffsetsAreRoundedBeforeComparing)
+{
+ setBodyInnerHTML(
+ "<style> body { height: 1000px } </style>"
+ "<div id='block1' style='height: 50.4px'>abc</div>"
+ "<div id='block2' style='height: 100px'>def</div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ scrollLayoutViewport(DoubleSize(0, 100));
+
+ document().getElementById("block1")->setAttribute(
+ HTMLNames::styleAttr, "height: 50.6px");
+ update();
+
+ EXPECT_EQ(101, viewport->scrollPosition().y());
+}
+
TEST_F(ScrollAnchorTest, UMAMetricUpdated)
{
HistogramTester histogramTester;

Powered by Google App Engine
This is Rietveld 408576698