OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ScrollAnchor.h" | 5 #include "core/layout/ScrollAnchor.h" |
6 | 6 |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 class ScrollAnchorTest : public RenderingTest { | 11 class ScrollAnchorTest : public RenderingTest { |
12 public: | 12 public: |
13 ScrollAnchorTest() { RuntimeEnabledFeatures::setScrollAnchoringEnabled(true)
; } | 13 ScrollAnchorTest() { RuntimeEnabledFeatures::setScrollAnchoringEnabled(true)
; } |
14 ~ScrollAnchorTest() { RuntimeEnabledFeatures::setScrollAnchoringEnabled(fals
e); } | 14 ~ScrollAnchorTest() { RuntimeEnabledFeatures::setScrollAnchoringEnabled(fals
e); } |
15 }; | 15 }; |
16 | 16 |
17 TEST_F(ScrollAnchorTest, Basic) | 17 TEST_F(ScrollAnchorTest, Basic) |
18 { | 18 { |
19 ScrollAnchor scrollAnchor(document().view()->layoutViewportScrollableArea())
; | 19 setBodyInnerHTML( |
20 scrollAnchor.clear(); | 20 "<style> body { height: 1000px } div { height: 100px } </style>" |
21 EXPECT_EQ(nullptr, scrollAnchor.anchorObject()); | 21 "<div id='block1'>abc</div>" |
| 22 "<div id='block2'>def</div>"); |
| 23 |
| 24 ScrollableArea* viewport = document().view()->layoutViewportScrollableArea()
; |
| 25 viewport->scrollBy(DoubleSize(0, 150), UserScroll); |
| 26 document().getElementById("block1")->setAttribute(HTMLNames::styleAttr, "hei
ght: 200px"); |
| 27 document().view()->updateAllLifecyclePhases(); |
| 28 EXPECT_EQ(250, viewport->scrollPosition().y()); |
22 } | 29 } |
| 30 |
23 } | 31 } |
OLD | NEW |