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

Side by Side Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

Issue 2320303002: Reset VisualViewport position after same page navigation (Closed)
Patch Set: add test html Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/frame/VisualViewport.h" 5 #include "core/frame/VisualViewport.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 : public testing::WithParamInterface<TestParamRootLayerScrolling> 188 : public testing::WithParamInterface<TestParamRootLayerScrolling>
189 , private ScopedRootLayerScrollingForTest 189 , private ScopedRootLayerScrollingForTest
190 , public VisualViewportTest { 190 , public VisualViewportTest {
191 public: 191 public:
192 ParameterizedVisualViewportTest() 192 ParameterizedVisualViewportTest()
193 : ScopedRootLayerScrollingForTest(GetParam()) { } 193 : ScopedRootLayerScrollingForTest(GetParam()) { }
194 }; 194 };
195 195
196 INSTANTIATE_TEST_CASE_P(All, ParameterizedVisualViewportTest, ::testing::Bool()) ; 196 INSTANTIATE_TEST_CASE_P(All, ParameterizedVisualViewportTest, ::testing::Bool()) ;
197 197
198 static WebGestureEvent fatTap(int x, int y)
199 {
200 WebGestureEvent event;
201 event.type = WebInputEvent::GestureTap;
202 event.sourceDevice = WebGestureDeviceTouchscreen;
203 event.x = x;
204 event.y = y;
205 event.data.tap.width = 50;
206 event.data.tap.height = 50;
207 return event;
208 }
209
198 // Test that resizing the VisualViewport works as expected and that resizing the 210 // Test that resizing the VisualViewport works as expected and that resizing the
199 // WebView resizes the VisualViewport. 211 // WebView resizes the VisualViewport.
200 TEST_P(ParameterizedVisualViewportTest, TestResize) 212 TEST_P(ParameterizedVisualViewportTest, TestResize)
201 { 213 {
202 initializeWithDesktopSettings(); 214 initializeWithDesktopSettings();
203 webViewImpl()->resize(IntSize(320, 240)); 215 webViewImpl()->resize(IntSize(320, 240));
204 216
205 navigateTo("about:blank"); 217 navigateTo("about:blank");
206 forceFullCompositingUpdate(); 218 forceFullCompositingUpdate();
207 219
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 webViewImpl()->resize(IntSize(600, 800)); 1929 webViewImpl()->resize(IntSize(600, 800));
1918 1930
1919 EXPECT_POINT_EQ( 1931 EXPECT_POINT_EQ(
1920 DoublePoint(), 1932 DoublePoint(),
1921 frameView.layoutViewportScrollableArea()->scrollPositionDouble()); 1933 frameView.layoutViewportScrollableArea()->scrollPositionDouble());
1922 EXPECT_EQ(600, scroller->scrollTop()); 1934 EXPECT_EQ(600, scroller->scrollTop());
1923 1935
1924 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); 1936 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled);
1925 } 1937 }
1926 1938
1939 // Ensure that the scroll position is correct when we navigate to same page afte r scale(zoom-in/zoom-out)
1940 // crbug.com/642279
1941 TEST_P(ParameterizedVisualViewportTest, ScrollPositionForLinkToSamePageAfterResi ze)
1942 {
1943 initializeWithAndroidSettings();
1944
1945 registerMockedHttpURLLoad("same-page-navigate.html");
1946 navigateTo(m_baseURL + "same-page-navigate.html");
1947
1948 webViewImpl()->setPageScaleFactor(2.0);
1949
1950 Element* link = frame()->document()->getElementById("same-page");
1951 webViewImpl()->handleInputEvent(fatTap(link->offsetLeft(), link->offsetTop() ));
1952 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewImpl()->mainFrame Impl());
1953
1954 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1955 EXPECT_POINT_EQ(
1956 DoublePoint(),
1957 frameView.layoutViewportScrollableArea()->scrollPositionDouble());
bokan 2016/09/13 14:56:47 The bug is that the *visual viewport* isn't reset.
1958 }
1959
1960
1961
1927 } // namespace 1962 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698