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

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

Issue 2949073002: Changing scroll and view state in onpopstate shouldn't overwrite back/forward state restore (Closed)
Patch Set: +test Created 3 years, 6 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/BrowserControls.h" 8 #include "core/frame/BrowserControls.h"
9 #include "core/frame/FrameTestHelpers.h" 9 #include "core/frame/FrameTestHelpers.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // Test that the HistoryItem for the page stores the visual viewport's offset 862 // Test that the HistoryItem for the page stores the visual viewport's offset
863 // and scale. 863 // and scale.
864 TEST_P(VisualViewportTest, TestSavedToHistoryItem) { 864 TEST_P(VisualViewportTest, TestSavedToHistoryItem) {
865 InitializeWithDesktopSettings(); 865 InitializeWithDesktopSettings();
866 WebViewImpl()->Resize(IntSize(200, 300)); 866 WebViewImpl()->Resize(IntSize(200, 300));
867 WebViewImpl()->UpdateAllLifecyclePhases(); 867 WebViewImpl()->UpdateAllLifecyclePhases();
868 868
869 RegisterMockedHttpURLLoad("200-by-300.html"); 869 RegisterMockedHttpURLLoad("200-by-300.html");
870 NavigateTo(base_url_ + "200-by-300.html"); 870 NavigateTo(base_url_ + "200-by-300.html");
871 871
872 EXPECT_SIZE_EQ(ScrollOffset(0, 0), 872 EXPECT_EQ(nullptr, ToLocalFrame(WebViewImpl()->GetPage()->MainFrame())
873 ToLocalFrame(WebViewImpl()->GetPage()->MainFrame()) 873 ->Loader()
874 ->Loader() 874 .GetDocumentLoader()
875 .GetDocumentLoader() 875 ->GetHistoryItem()
876 ->GetHistoryItem() 876 ->GetScrollAndViewState());
877 ->VisualViewportScrollOffset());
878 877
879 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); 878 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport();
880 visual_viewport.SetScale(2); 879 visual_viewport.SetScale(2);
881 880
882 EXPECT_EQ(2, ToLocalFrame(WebViewImpl()->GetPage()->MainFrame()) 881 EXPECT_EQ(2, ToLocalFrame(WebViewImpl()->GetPage()->MainFrame())
883 ->Loader() 882 ->Loader()
884 .GetDocumentLoader() 883 .GetDocumentLoader()
885 ->GetHistoryItem() 884 ->GetHistoryItem()
886 ->PageScaleFactor()); 885 ->GetScrollAndViewState()
886 ->page_scale_factor_);
887 887
888 visual_viewport.SetLocation(FloatPoint(10, 20)); 888 visual_viewport.SetLocation(FloatPoint(10, 20));
889 889
890 EXPECT_SIZE_EQ(ScrollOffset(10, 20), 890 EXPECT_SIZE_EQ(ScrollOffset(10, 20),
891 ToLocalFrame(WebViewImpl()->GetPage()->MainFrame()) 891 ToLocalFrame(WebViewImpl()->GetPage()->MainFrame())
892 ->Loader() 892 ->Loader()
893 .GetDocumentLoader() 893 .GetDocumentLoader()
894 ->GetHistoryItem() 894 ->GetHistoryItem()
895 ->VisualViewportScrollOffset()); 895 ->GetScrollAndViewState()
896 ->visual_viewport_scroll_offset_);
896 } 897 }
897 898
898 // Test restoring a HistoryItem properly restores the visual viewport's state. 899 // Test restoring a HistoryItem properly restores the visual viewport's state.
899 TEST_P(VisualViewportTest, TestRestoredFromHistoryItem) { 900 TEST_P(VisualViewportTest, TestRestoredFromHistoryItem) {
900 InitializeWithDesktopSettings(); 901 InitializeWithDesktopSettings();
901 WebViewImpl()->Resize(IntSize(200, 300)); 902 WebViewImpl()->Resize(IntSize(200, 300));
902 903
903 RegisterMockedHttpURLLoad("200-by-300.html"); 904 RegisterMockedHttpURLLoad("200-by-300.html");
904 905
905 WebHistoryItem item; 906 WebHistoryItem item;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); 974 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport();
974 visual_viewport.SetScale(2); 975 visual_viewport.SetScale(2);
975 visual_viewport.SetLocation(FloatPoint(350, 350)); 976 visual_viewport.SetLocation(FloatPoint(350, 350));
976 977
977 Persistent<HistoryItem> firstItem = WebViewImpl() 978 Persistent<HistoryItem> firstItem = WebViewImpl()
978 ->MainFrameImpl() 979 ->MainFrameImpl()
979 ->GetFrame() 980 ->GetFrame()
980 ->Loader() 981 ->Loader()
981 .GetDocumentLoader() 982 .GetDocumentLoader()
982 ->GetHistoryItem(); 983 ->GetHistoryItem();
983 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->GetScrollOffset()); 984 EXPECT_SIZE_EQ(ScrollOffset(0, 1000),
985 firstItem->GetScrollAndViewState()->scroll_offset_);
984 986
985 // Now navigate to a page which causes a smaller frame_view. Make sure that 987 // Now navigate to a page which causes a smaller frame_view. Make sure that
986 // navigating doesn't cause the history item to set a new scroll offset 988 // navigating doesn't cause the history item to set a new scroll offset
987 // before the item was replaced. 989 // before the item was replaced.
988 NavigateTo("about:blank"); 990 NavigateTo("about:blank");
989 frame_view = WebViewImpl()->MainFrameImpl()->GetFrameView(); 991 frame_view = WebViewImpl()->MainFrameImpl()->GetFrameView();
990 992
991 EXPECT_NE(firstItem, WebViewImpl() 993 EXPECT_NE(firstItem, WebViewImpl()
992 ->MainFrameImpl() 994 ->MainFrameImpl()
993 ->GetFrame() 995 ->GetFrame()
994 ->Loader() 996 ->Loader()
995 .GetDocumentLoader() 997 .GetDocumentLoader()
996 ->GetHistoryItem()); 998 ->GetHistoryItem());
997 EXPECT_LT(frame_view->FrameRect().Size().Width(), 1000); 999 EXPECT_LT(frame_view->FrameRect().Size().Width(), 1000);
998 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->GetScrollOffset()); 1000 EXPECT_SIZE_EQ(ScrollOffset(0, 1000),
1001 firstItem->GetScrollAndViewState()->scroll_offset_);
999 } 1002 }
1000 1003
1001 // Test that the coordinates sent into moveRangeSelection are offset by the 1004 // Test that the coordinates sent into moveRangeSelection are offset by the
1002 // visual viewport's location. 1005 // visual viewport's location.
1003 TEST_P(VisualViewportTest, 1006 TEST_P(VisualViewportTest,
1004 DISABLED_TestWebFrameRangeAccountsForVisualViewportScroll) { 1007 DISABLED_TestWebFrameRangeAccountsForVisualViewportScroll) {
1005 InitializeWithDesktopSettings(); 1008 InitializeWithDesktopSettings();
1006 WebViewImpl()->GetSettings()->SetDefaultFontSize(12); 1009 WebViewImpl()->GetSettings()->SetDefaultFontSize(12);
1007 WebViewImpl()->Resize(WebSize(640, 480)); 1010 WebViewImpl()->Resize(WebSize(640, 480));
1008 RegisterMockedHttpURLLoad("move_range.html"); 1011 RegisterMockedHttpURLLoad("move_range.html");
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 " margin: 0px;" 2423 " margin: 0px;"
2421 " }" 2424 " }"
2422 " div { height:110vh; width: 110vw; }" 2425 " div { height:110vh; width: 110vw; }"
2423 "</style>" 2426 "</style>"
2424 "<div></div>", 2427 "<div></div>",
2425 base_url); 2428 base_url);
2426 } 2429 }
2427 2430
2428 } // namespace 2431 } // namespace
2429 } // namespace blink 2432 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698