OLD | NEW |
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 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 EXPECT_EQ(-1, info.composition_start); | 1323 EXPECT_EQ(-1, info.composition_start); |
1324 EXPECT_EQ(-1, info.composition_end); | 1324 EXPECT_EQ(-1, info.composition_end); |
1325 } | 1325 } |
1326 | 1326 |
1327 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1327 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
1328 RegisterMockedHttpURLLoad("form_with_input.html"); | 1328 RegisterMockedHttpURLLoad("form_with_input.html"); |
1329 WebViewBase* web_view = | 1329 WebViewBase* web_view = |
1330 web_view_helper_.InitializeAndLoad(base_url_ + "form_with_input.html"); | 1330 web_view_helper_.InitializeAndLoad(base_url_ + "form_with_input.html"); |
1331 web_view->Resize(WebSize(800, 600)); | 1331 web_view->Resize(WebSize(800, 600)); |
1332 web_view->SetInitialFocus(false); | 1332 web_view->SetInitialFocus(false); |
1333 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1333 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); |
1334 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().height); | 1334 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().height); |
1335 | 1335 |
1336 // Set up a composition from existing text that needs to be committed. | 1336 // Set up a composition from existing text that needs to be committed. |
1337 Vector<CompositionUnderline> empty_underlines; | 1337 Vector<CompositionUnderline> empty_underlines; |
1338 WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 1338 WebLocalFrameBase* frame = web_view->MainFrameImpl(); |
1339 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( | 1339 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( |
1340 empty_underlines, 0, 3); | 1340 empty_underlines, 0, 3); |
1341 | 1341 |
1342 // Scroll the input field out of the viewport. | 1342 // Scroll the input field out of the viewport. |
1343 Element* element = static_cast<Element*>( | 1343 Element* element = static_cast<Element*>( |
1344 web_view->MainFrame()->GetDocument().GetElementById("btn")); | 1344 web_view->MainFrame()->GetDocument().GetElementById("btn")); |
1345 element->scrollIntoView(); | 1345 element->scrollIntoView(); |
1346 float offset_height = web_view->MainFrame()->GetScrollOffset().height; | 1346 float offset_height = web_view->MainFrameImpl()->GetScrollOffset().height; |
1347 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1347 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); |
1348 EXPECT_LT(0, offset_height); | 1348 EXPECT_LT(0, offset_height); |
1349 | 1349 |
1350 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 1350 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); |
1351 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); | 1351 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); |
1352 | 1352 |
1353 // Verify that the input field is not scrolled back into the viewport. | 1353 // Verify that the input field is not scrolled back into the viewport. |
1354 frame->FrameWidget() | 1354 frame->FrameWidget() |
1355 ->GetActiveWebInputMethodController() | 1355 ->GetActiveWebInputMethodController() |
1356 ->FinishComposingText(WebInputMethodController::kDoNotKeepSelection); | 1356 ->FinishComposingText(WebInputMethodController::kDoNotKeepSelection); |
1357 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1357 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); |
1358 EXPECT_EQ(offset_height, web_view->MainFrame()->GetScrollOffset().height); | 1358 EXPECT_EQ(offset_height, web_view->MainFrameImpl()->GetScrollOffset().height); |
1359 } | 1359 } |
1360 | 1360 |
1361 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { | 1361 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { |
1362 RegisterMockedHttpURLLoad("text_area_populated.html"); | 1362 RegisterMockedHttpURLLoad("text_area_populated.html"); |
1363 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 1363 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1364 base_url_ + "text_area_populated.html"); | 1364 base_url_ + "text_area_populated.html"); |
1365 web_view->SetInitialFocus(false); | 1365 web_view->SetInitialFocus(false); |
1366 | 1366 |
1367 WebVector<WebCompositionUnderline> empty_underlines; | 1367 WebVector<WebCompositionUnderline> empty_underlines; |
1368 | 1368 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 | 1656 |
1657 EXPECT_EQ(page_scale_expected, web_view_impl->PageScaleFactor()); | 1657 EXPECT_EQ(page_scale_expected, web_view_impl->PageScaleFactor()); |
1658 } | 1658 } |
1659 | 1659 |
1660 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { | 1660 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { |
1661 RegisterMockedHttpURLLoad("200-by-300.html"); | 1661 RegisterMockedHttpURLLoad("200-by-300.html"); |
1662 WebViewBase* web_view_impl = | 1662 WebViewBase* web_view_impl = |
1663 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1663 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
1664 web_view_impl->Resize(WebSize(100, 150)); | 1664 web_view_impl->Resize(WebSize(100, 150)); |
1665 web_view_impl->UpdateAllLifecyclePhases(); | 1665 web_view_impl->UpdateAllLifecyclePhases(); |
1666 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1666 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1667 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1667 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1668 | 1668 |
1669 // Make the page scale and scroll with the given paremeters. | 1669 // Make the page scale and scroll with the given paremeters. |
1670 web_view_impl->SetPageScaleFactor(2.0f); | 1670 web_view_impl->SetPageScaleFactor(2.0f); |
1671 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); | 1671 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(94, 111)); |
1672 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1672 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
1673 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); | 1673 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1674 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); | 1674 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1675 LocalFrame* main_frame_local = | 1675 LocalFrame* main_frame_local = |
1676 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); | 1676 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); |
1677 main_frame_local->Loader().SaveScrollState(); | 1677 main_frame_local->Loader().SaveScrollState(); |
1678 EXPECT_EQ(2.0f, main_frame_local->Loader() | 1678 EXPECT_EQ(2.0f, main_frame_local->Loader() |
1679 .GetDocumentLoader() | 1679 .GetDocumentLoader() |
1680 ->GetHistoryItem() | 1680 ->GetHistoryItem() |
1681 ->PageScaleFactor()); | 1681 ->PageScaleFactor()); |
1682 EXPECT_EQ(94, main_frame_local->Loader() | 1682 EXPECT_EQ(94, main_frame_local->Loader() |
1683 .GetDocumentLoader() | 1683 .GetDocumentLoader() |
1684 ->GetHistoryItem() | 1684 ->GetHistoryItem() |
1685 ->GetScrollOffset() | 1685 ->GetScrollOffset() |
1686 .Width()); | 1686 .Width()); |
1687 EXPECT_EQ(111, main_frame_local->Loader() | 1687 EXPECT_EQ(111, main_frame_local->Loader() |
1688 .GetDocumentLoader() | 1688 .GetDocumentLoader() |
1689 ->GetHistoryItem() | 1689 ->GetHistoryItem() |
1690 ->GetScrollOffset() | 1690 ->GetScrollOffset() |
1691 .Height()); | 1691 .Height()); |
1692 | 1692 |
1693 // Confirm that resetting the page state resets the saved scroll position. | 1693 // Confirm that resetting the page state resets the saved scroll position. |
1694 web_view_impl->ResetScrollAndScaleState(); | 1694 web_view_impl->ResetScrollAndScaleState(); |
1695 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); | 1695 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); |
1696 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1696 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1697 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1697 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1698 EXPECT_EQ(1.0f, main_frame_local->Loader() | 1698 EXPECT_EQ(1.0f, main_frame_local->Loader() |
1699 .GetDocumentLoader() | 1699 .GetDocumentLoader() |
1700 ->GetHistoryItem() | 1700 ->GetHistoryItem() |
1701 ->PageScaleFactor()); | 1701 ->PageScaleFactor()); |
1702 EXPECT_EQ(0, main_frame_local->Loader() | 1702 EXPECT_EQ(0, main_frame_local->Loader() |
1703 .GetDocumentLoader() | 1703 .GetDocumentLoader() |
1704 ->GetHistoryItem() | 1704 ->GetHistoryItem() |
1705 ->GetScrollOffset() | 1705 ->GetScrollOffset() |
1706 .Width()); | 1706 .Width()); |
1707 EXPECT_EQ(0, main_frame_local->Loader() | 1707 EXPECT_EQ(0, main_frame_local->Loader() |
1708 .GetDocumentLoader() | 1708 .GetDocumentLoader() |
1709 ->GetHistoryItem() | 1709 ->GetHistoryItem() |
1710 ->GetScrollOffset() | 1710 ->GetScrollOffset() |
1711 .Height()); | 1711 .Height()); |
1712 } | 1712 } |
1713 | 1713 |
1714 TEST_P(WebViewTest, BackForwardRestoreScroll) { | 1714 TEST_P(WebViewTest, BackForwardRestoreScroll) { |
1715 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); | 1715 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); |
1716 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( | 1716 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( |
1717 base_url_ + "back_forward_restore_scroll.html"); | 1717 base_url_ + "back_forward_restore_scroll.html"); |
1718 web_view_impl->Resize(WebSize(640, 480)); | 1718 web_view_impl->Resize(WebSize(640, 480)); |
1719 web_view_impl->UpdateAllLifecyclePhases(); | 1719 web_view_impl->UpdateAllLifecyclePhases(); |
1720 | 1720 |
1721 // Emulate a user scroll | 1721 // Emulate a user scroll |
1722 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 900)); | 1722 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(0, 900)); |
1723 LocalFrame* main_frame_local = | 1723 LocalFrame* main_frame_local = |
1724 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); | 1724 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); |
1725 Persistent<HistoryItem> item1 = | 1725 Persistent<HistoryItem> item1 = |
1726 main_frame_local->Loader().GetDocumentLoader()->GetHistoryItem(); | 1726 main_frame_local->Loader().GetDocumentLoader()->GetHistoryItem(); |
1727 | 1727 |
1728 // Click an anchor | 1728 // Click an anchor |
1729 main_frame_local->Loader().Load(FrameLoadRequest( | 1729 main_frame_local->Loader().Load(FrameLoadRequest( |
1730 main_frame_local->GetDocument(), | 1730 main_frame_local->GetDocument(), |
1731 ResourceRequest(main_frame_local->GetDocument()->CompleteURL("#a")))); | 1731 ResourceRequest(main_frame_local->GetDocument()->CompleteURL("#a")))); |
1732 Persistent<HistoryItem> item2 = | 1732 Persistent<HistoryItem> item2 = |
(...skipping 23 matching lines...) Expand all Loading... |
1756 // Go back, then forward. The scroll position should be properly set on the | 1756 // Go back, then forward. The scroll position should be properly set on the |
1757 // forward navigation. | 1757 // forward navigation. |
1758 main_frame_local->Loader().Load( | 1758 main_frame_local->Loader().Load( |
1759 FrameLoadRequest(nullptr, item1->GenerateResourceRequest( | 1759 FrameLoadRequest(nullptr, item1->GenerateResourceRequest( |
1760 WebCachePolicy::kUseProtocolCachePolicy)), | 1760 WebCachePolicy::kUseProtocolCachePolicy)), |
1761 kFrameLoadTypeBackForward, item1.Get(), kHistorySameDocumentLoad); | 1761 kFrameLoadTypeBackForward, item1.Get(), kHistorySameDocumentLoad); |
1762 main_frame_local->Loader().Load( | 1762 main_frame_local->Loader().Load( |
1763 FrameLoadRequest(nullptr, item3->GenerateResourceRequest( | 1763 FrameLoadRequest(nullptr, item3->GenerateResourceRequest( |
1764 WebCachePolicy::kUseProtocolCachePolicy)), | 1764 WebCachePolicy::kUseProtocolCachePolicy)), |
1765 kFrameLoadTypeBackForward, item3.Get(), kHistorySameDocumentLoad); | 1765 kFrameLoadTypeBackForward, item3.Get(), kHistorySameDocumentLoad); |
1766 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1766 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1767 EXPECT_GT(web_view_impl->MainFrame()->GetScrollOffset().height, 2000); | 1767 EXPECT_GT(web_view_impl->MainFrameImpl()->GetScrollOffset().height, 2000); |
1768 } | 1768 } |
1769 | 1769 |
1770 // Tests that we restore scroll and scale *after* the fullscreen styles are | 1770 // Tests that we restore scroll and scale *after* the fullscreen styles are |
1771 // removed and the page is laid out. http://crbug.com/625683. | 1771 // removed and the page is laid out. http://crbug.com/625683. |
1772 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { | 1772 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { |
1773 RegisterMockedHttpURLLoad("fullscreen_style.html"); | 1773 RegisterMockedHttpURLLoad("fullscreen_style.html"); |
1774 WebViewBase* web_view_impl = | 1774 WebViewBase* web_view_impl = |
1775 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); | 1775 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); |
1776 web_view_impl->Resize(WebSize(800, 600)); | 1776 web_view_impl->Resize(WebSize(800, 600)); |
1777 web_view_impl->UpdateAllLifecyclePhases(); | 1777 web_view_impl->UpdateAllLifecyclePhases(); |
1778 | 1778 |
1779 // Scroll the page down. | 1779 // Scroll the page down. |
1780 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 1780 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(0, 2000)); |
1781 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1781 ASSERT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1782 | 1782 |
1783 // Enter fullscreen. | 1783 // Enter fullscreen. |
1784 Document* document = | 1784 Document* document = |
1785 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 1785 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
1786 Element* element = document->getElementById("fullscreenElement"); | 1786 Element* element = document->getElementById("fullscreenElement"); |
1787 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 1787 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
1788 Fullscreen::RequestFullscreen(*element); | 1788 Fullscreen::RequestFullscreen(*element); |
1789 web_view_impl->DidEnterFullscreen(); | 1789 web_view_impl->DidEnterFullscreen(); |
1790 web_view_impl->UpdateAllLifecyclePhases(); | 1790 web_view_impl->UpdateAllLifecyclePhases(); |
1791 | 1791 |
1792 // Sanity-check. There should be no scrolling possible. | 1792 // Sanity-check. There should be no scrolling possible. |
1793 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1793 ASSERT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1794 ASSERT_EQ(0, web_view_impl->MainFrameImpl() | 1794 ASSERT_EQ(0, web_view_impl->MainFrameImpl() |
1795 ->GetFrameView() | 1795 ->GetFrameView() |
1796 ->MaximumScrollOffset() | 1796 ->MaximumScrollOffset() |
1797 .Height()); | 1797 .Height()); |
1798 | 1798 |
1799 // Confirm that after exiting and doing a layout, the scroll and scale | 1799 // Confirm that after exiting and doing a layout, the scroll and scale |
1800 // parameters are reset. The page sets display: none on overflowing elements | 1800 // parameters are reset. The page sets display: none on overflowing elements |
1801 // while in fullscreen so if we try to restore before the style and layout | 1801 // while in fullscreen so if we try to restore before the style and layout |
1802 // is applied the offsets will be clamped. | 1802 // is applied the offsets will be clamped. |
1803 web_view_impl->DidExitFullscreen(); | 1803 web_view_impl->DidExitFullscreen(); |
1804 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); | 1804 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); |
1805 web_view_impl->UpdateAllLifecyclePhases(); | 1805 web_view_impl->UpdateAllLifecyclePhases(); |
1806 | 1806 |
1807 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1807 EXPECT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1808 } | 1808 } |
1809 | 1809 |
1810 // Tests that exiting and immediately reentering fullscreen doesn't cause the | 1810 // Tests that exiting and immediately reentering fullscreen doesn't cause the |
1811 // scroll and scale restoration to occur when we enter fullscreen again. | 1811 // scroll and scale restoration to occur when we enter fullscreen again. |
1812 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { | 1812 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { |
1813 RegisterMockedHttpURLLoad("fullscreen_style.html"); | 1813 RegisterMockedHttpURLLoad("fullscreen_style.html"); |
1814 WebViewBase* web_view_impl = | 1814 WebViewBase* web_view_impl = |
1815 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); | 1815 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); |
1816 web_view_impl->Resize(WebSize(800, 600)); | 1816 web_view_impl->Resize(WebSize(800, 600)); |
1817 web_view_impl->UpdateAllLifecyclePhases(); | 1817 web_view_impl->UpdateAllLifecyclePhases(); |
1818 | 1818 |
1819 // Scroll the page down. | 1819 // Scroll the page down. |
1820 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 1820 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(0, 2000)); |
1821 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1821 ASSERT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1822 | 1822 |
1823 // Enter fullscreen. | 1823 // Enter fullscreen. |
1824 Document* document = | 1824 Document* document = |
1825 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 1825 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
1826 Element* element = document->getElementById("fullscreenElement"); | 1826 Element* element = document->getElementById("fullscreenElement"); |
1827 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 1827 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
1828 Fullscreen::RequestFullscreen(*element); | 1828 Fullscreen::RequestFullscreen(*element); |
1829 web_view_impl->DidEnterFullscreen(); | 1829 web_view_impl->DidEnterFullscreen(); |
1830 web_view_impl->UpdateAllLifecyclePhases(); | 1830 web_view_impl->UpdateAllLifecyclePhases(); |
1831 | 1831 |
1832 // Sanity-check. There should be no scrolling possible. | 1832 // Sanity-check. There should be no scrolling possible. |
1833 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1833 ASSERT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1834 ASSERT_EQ(0, web_view_impl->MainFrameImpl() | 1834 ASSERT_EQ(0, web_view_impl->MainFrameImpl() |
1835 ->GetFrameView() | 1835 ->GetFrameView() |
1836 ->MaximumScrollOffset() | 1836 ->MaximumScrollOffset() |
1837 .Height()); | 1837 .Height()); |
1838 | 1838 |
1839 // Exit and, without performing a layout, reenter fullscreen again. We | 1839 // Exit and, without performing a layout, reenter fullscreen again. We |
1840 // shouldn't try to restore the scroll and scale values when we layout to | 1840 // shouldn't try to restore the scroll and scale values when we layout to |
1841 // enter fullscreen. | 1841 // enter fullscreen. |
1842 web_view_impl->DidExitFullscreen(); | 1842 web_view_impl->DidExitFullscreen(); |
1843 Fullscreen::RequestFullscreen(*element); | 1843 Fullscreen::RequestFullscreen(*element); |
1844 web_view_impl->DidEnterFullscreen(); | 1844 web_view_impl->DidEnterFullscreen(); |
1845 web_view_impl->UpdateAllLifecyclePhases(); | 1845 web_view_impl->UpdateAllLifecyclePhases(); |
1846 | 1846 |
1847 // Sanity-check. There should be no scrolling possible. | 1847 // Sanity-check. There should be no scrolling possible. |
1848 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1848 ASSERT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1849 ASSERT_EQ(0, web_view_impl->MainFrameImpl() | 1849 ASSERT_EQ(0, web_view_impl->MainFrameImpl() |
1850 ->GetFrameView() | 1850 ->GetFrameView() |
1851 ->MaximumScrollOffset() | 1851 ->MaximumScrollOffset() |
1852 .Height()); | 1852 .Height()); |
1853 | 1853 |
1854 // When we exit now, we should restore the original scroll value. | 1854 // When we exit now, we should restore the original scroll value. |
1855 web_view_impl->DidExitFullscreen(); | 1855 web_view_impl->DidExitFullscreen(); |
1856 web_view_impl->UpdateAllLifecyclePhases(); | 1856 web_view_impl->UpdateAllLifecyclePhases(); |
1857 | 1857 |
1858 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1858 EXPECT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1859 } | 1859 } |
1860 | 1860 |
1861 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { | 1861 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { |
1862 RegisterMockedHttpURLLoad("200-by-300.html"); | 1862 RegisterMockedHttpURLLoad("200-by-300.html"); |
1863 WebViewBase* web_view_impl = | 1863 WebViewBase* web_view_impl = |
1864 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1864 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
1865 web_view_impl->Resize(WebSize(100, 150)); | 1865 web_view_impl->Resize(WebSize(100, 150)); |
1866 web_view_impl->UpdateAllLifecyclePhases(); | 1866 web_view_impl->UpdateAllLifecyclePhases(); |
1867 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1867 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1868 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1868 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1869 | 1869 |
1870 // Make the page scale and scroll with the given paremeters. | 1870 // Make the page scale and scroll with the given paremeters. |
1871 web_view_impl->SetPageScaleFactor(2.0f); | 1871 web_view_impl->SetPageScaleFactor(2.0f); |
1872 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); | 1872 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(94, 111)); |
1873 web_view_impl->SetVisualViewportOffset(WebFloatPoint(12, 20)); | 1873 web_view_impl->SetVisualViewportOffset(WebFloatPoint(12, 20)); |
1874 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1874 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
1875 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); | 1875 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1876 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); | 1876 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1877 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); | 1877 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); |
1878 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); | 1878 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); |
1879 | 1879 |
1880 Document* document = | 1880 Document* document = |
1881 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 1881 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
1882 Element* element = document->body(); | 1882 Element* element = document->body(); |
1883 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 1883 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
1884 Fullscreen::RequestFullscreen(*element); | 1884 Fullscreen::RequestFullscreen(*element); |
1885 web_view_impl->DidEnterFullscreen(); | 1885 web_view_impl->DidEnterFullscreen(); |
1886 | 1886 |
1887 // Page scale factor must be 1.0 during fullscreen for elements to be sized | 1887 // Page scale factor must be 1.0 during fullscreen for elements to be sized |
1888 // properly. | 1888 // properly. |
1889 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); | 1889 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); |
1890 | 1890 |
1891 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. | 1891 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. |
1892 Element* other_element = document->getElementById("content"); | 1892 Element* other_element = document->getElementById("content"); |
1893 Fullscreen::RequestFullscreen(*other_element); | 1893 Fullscreen::RequestFullscreen(*other_element); |
1894 | 1894 |
1895 // Confirm that exiting fullscreen restores the parameters. | 1895 // Confirm that exiting fullscreen restores the parameters. |
1896 web_view_impl->DidExitFullscreen(); | 1896 web_view_impl->DidExitFullscreen(); |
1897 web_view_impl->UpdateAllLifecyclePhases(); | 1897 web_view_impl->UpdateAllLifecyclePhases(); |
1898 | 1898 |
1899 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1899 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
1900 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); | 1900 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
1901 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); | 1901 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
1902 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); | 1902 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); |
1903 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); | 1903 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); |
1904 } | 1904 } |
1905 | 1905 |
1906 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { | 1906 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { |
1907 public: | 1907 public: |
1908 PrintWebViewClient() : print_called_(false) {} | 1908 PrintWebViewClient() : print_called_(false) {} |
1909 | 1909 |
1910 // WebViewClient methods | 1910 // WebViewClient methods |
1911 void PrintPage(WebLocalFrame*) override { print_called_ = true; } | 1911 void PrintPage(WebLocalFrame*) override { print_called_ = true; } |
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4346 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4346 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |
4347 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 4347 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { |
4348 EXPECT_NE(nullptr, | 4348 EXPECT_NE(nullptr, |
4349 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4349 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |
4350 } else { | 4350 } else { |
4351 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4351 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |
4352 } | 4352 } |
4353 } | 4353 } |
4354 | 4354 |
4355 } // namespace blink | 4355 } // namespace blink |
OLD | NEW |