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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(94, 111)); 1670 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(94, 111));
1671 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); 1671 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor());
1672 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); 1672 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width);
1673 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); 1673 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height);
1674 LocalFrame* main_frame_local = 1674 LocalFrame* main_frame_local =
1675 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); 1675 ToLocalFrame(web_view_impl->GetPage()->MainFrame());
1676 main_frame_local->Loader().SaveScrollState(); 1676 main_frame_local->Loader().SaveScrollState();
1677 EXPECT_EQ(2.0f, main_frame_local->Loader() 1677 EXPECT_EQ(2.0f, main_frame_local->Loader()
1678 .GetDocumentLoader() 1678 .GetDocumentLoader()
1679 ->GetHistoryItem() 1679 ->GetHistoryItem()
1680 ->PageScaleFactor()); 1680 ->GetScrollAndViewState()
1681 ->page_scale_factor_);
1681 EXPECT_EQ(94, main_frame_local->Loader() 1682 EXPECT_EQ(94, main_frame_local->Loader()
1682 .GetDocumentLoader() 1683 .GetDocumentLoader()
1683 ->GetHistoryItem() 1684 ->GetHistoryItem()
1684 ->GetScrollOffset() 1685 ->GetScrollAndViewState()
1685 .Width()); 1686 ->scroll_offset_.Width());
1686 EXPECT_EQ(111, main_frame_local->Loader() 1687 EXPECT_EQ(111, main_frame_local->Loader()
1687 .GetDocumentLoader() 1688 .GetDocumentLoader()
1688 ->GetHistoryItem() 1689 ->GetHistoryItem()
1689 ->GetScrollOffset() 1690 ->GetScrollAndViewState()
1690 .Height()); 1691 ->scroll_offset_.Height());
1691 1692
1692 // Confirm that resetting the page state resets the saved scroll position. 1693 // Confirm that resetting the page state resets the saved scroll position.
1693 web_view_impl->ResetScrollAndScaleState(); 1694 web_view_impl->ResetScrollAndScaleState();
1694 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); 1695 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor());
1695 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); 1696 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width);
1696 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); 1697 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height);
1697 EXPECT_EQ(1.0f, main_frame_local->Loader() 1698 EXPECT_EQ(nullptr, main_frame_local->Loader()
1698 .GetDocumentLoader() 1699 .GetDocumentLoader()
1699 ->GetHistoryItem() 1700 ->GetHistoryItem()
1700 ->PageScaleFactor()); 1701 ->GetScrollAndViewState());
1701 EXPECT_EQ(0, main_frame_local->Loader()
1702 .GetDocumentLoader()
1703 ->GetHistoryItem()
1704 ->GetScrollOffset()
1705 .Width());
1706 EXPECT_EQ(0, main_frame_local->Loader()
1707 .GetDocumentLoader()
1708 ->GetHistoryItem()
1709 ->GetScrollOffset()
1710 .Height());
1711 } 1702 }
1712 1703
1713 TEST_P(WebViewTest, BackForwardRestoreScroll) { 1704 TEST_P(WebViewTest, BackForwardRestoreScroll) {
1714 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); 1705 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html");
1715 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( 1706 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad(
1716 base_url_ + "back_forward_restore_scroll.html"); 1707 base_url_ + "back_forward_restore_scroll.html");
1717 web_view_impl->Resize(WebSize(640, 480)); 1708 web_view_impl->Resize(WebSize(640, 480));
1718 web_view_impl->UpdateAllLifecyclePhases(); 1709 web_view_impl->UpdateAllLifecyclePhases();
1719 1710
1720 // Emulate a user scroll 1711 // Emulate a user scroll
(...skipping 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); 4328 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars());
4338 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { 4329 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) {
4339 EXPECT_NE(nullptr, 4330 EXPECT_NE(nullptr,
4340 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); 4331 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar());
4341 } else { 4332 } else {
4342 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); 4333 EXPECT_NE(nullptr, frame_view->VerticalScrollbar());
4343 } 4334 }
4344 } 4335 }
4345 4336
4346 } // namespace blink 4337 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698