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 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); | 1645 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); |
1646 | 1646 |
1647 // Make the page scale and scroll with the given paremeters. | 1647 // Make the page scale and scroll with the given paremeters. |
1648 webViewImpl->setPageScaleFactor(2.0f); | 1648 webViewImpl->setPageScaleFactor(2.0f); |
1649 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); | 1649 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); |
1650 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 1650 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
1651 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); | 1651 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); |
1652 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); | 1652 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); |
1653 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); | 1653 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); |
1654 mainFrameLocal->loader().saveScrollState(); | 1654 mainFrameLocal->loader().saveScrollState(); |
1655 EXPECT_EQ(2.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); | 1655 EXPECT_EQ(2.0f, mainFrameLocal->loader() |
1656 EXPECT_EQ(94, | 1656 .documentLoader() |
1657 mainFrameLocal->loader().currentItem()->getScrollOffset().width()); | 1657 ->historyItem() |
1658 EXPECT_EQ(111, | 1658 ->pageScaleFactor()); |
1659 mainFrameLocal->loader().currentItem()->getScrollOffset().height()); | 1659 EXPECT_EQ(94, mainFrameLocal->loader() |
| 1660 .documentLoader() |
| 1661 ->historyItem() |
| 1662 ->getScrollOffset() |
| 1663 .width()); |
| 1664 EXPECT_EQ(111, mainFrameLocal->loader() |
| 1665 .documentLoader() |
| 1666 ->historyItem() |
| 1667 ->getScrollOffset() |
| 1668 .height()); |
1660 | 1669 |
1661 // Confirm that resetting the page state resets the saved scroll position. | 1670 // Confirm that resetting the page state resets the saved scroll position. |
1662 webViewImpl->resetScrollAndScaleState(); | 1671 webViewImpl->resetScrollAndScaleState(); |
1663 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 1672 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
1664 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); | 1673 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); |
1665 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); | 1674 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); |
1666 EXPECT_EQ(1.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); | 1675 EXPECT_EQ(1.0f, mainFrameLocal->loader() |
1667 EXPECT_EQ(0, | 1676 .documentLoader() |
1668 mainFrameLocal->loader().currentItem()->getScrollOffset().width()); | 1677 ->historyItem() |
1669 EXPECT_EQ(0, | 1678 ->pageScaleFactor()); |
1670 mainFrameLocal->loader().currentItem()->getScrollOffset().height()); | 1679 EXPECT_EQ(0, mainFrameLocal->loader() |
| 1680 .documentLoader() |
| 1681 ->historyItem() |
| 1682 ->getScrollOffset() |
| 1683 .width()); |
| 1684 EXPECT_EQ(0, mainFrameLocal->loader() |
| 1685 .documentLoader() |
| 1686 ->historyItem() |
| 1687 ->getScrollOffset() |
| 1688 .height()); |
1671 } | 1689 } |
1672 | 1690 |
1673 TEST_P(WebViewTest, BackForwardRestoreScroll) { | 1691 TEST_P(WebViewTest, BackForwardRestoreScroll) { |
1674 registerMockedHttpURLLoad("back_forward_restore_scroll.html"); | 1692 registerMockedHttpURLLoad("back_forward_restore_scroll.html"); |
1675 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad( | 1693 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad( |
1676 m_baseURL + "back_forward_restore_scroll.html"); | 1694 m_baseURL + "back_forward_restore_scroll.html"); |
1677 webViewImpl->resize(WebSize(640, 480)); | 1695 webViewImpl->resize(WebSize(640, 480)); |
1678 webViewImpl->updateAllLifecyclePhases(); | 1696 webViewImpl->updateAllLifecyclePhases(); |
1679 | 1697 |
1680 // Emulate a user scroll | 1698 // Emulate a user scroll |
1681 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900)); | 1699 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900)); |
1682 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); | 1700 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); |
1683 Persistent<HistoryItem> item1 = mainFrameLocal->loader().currentItem(); | 1701 Persistent<HistoryItem> item1 = |
| 1702 mainFrameLocal->loader().documentLoader()->historyItem(); |
1684 | 1703 |
1685 // Click an anchor | 1704 // Click an anchor |
1686 mainFrameLocal->loader().load(FrameLoadRequest( | 1705 mainFrameLocal->loader().load(FrameLoadRequest( |
1687 mainFrameLocal->document(), | 1706 mainFrameLocal->document(), |
1688 ResourceRequest(mainFrameLocal->document()->completeURL("#a")))); | 1707 ResourceRequest(mainFrameLocal->document()->completeURL("#a")))); |
1689 Persistent<HistoryItem> item2 = mainFrameLocal->loader().currentItem(); | 1708 Persistent<HistoryItem> item2 = |
| 1709 mainFrameLocal->loader().documentLoader()->historyItem(); |
1690 | 1710 |
1691 // Go back, then forward, then back again. | 1711 // Go back, then forward, then back again. |
1692 mainFrameLocal->loader().load( | 1712 mainFrameLocal->loader().load( |
1693 FrameLoadRequest( | 1713 FrameLoadRequest(nullptr, item1->generateResourceRequest( |
1694 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1714 WebCachePolicy::UseProtocolCachePolicy)), |
1695 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), | |
1696 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); | 1715 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); |
1697 mainFrameLocal->loader().load( | 1716 mainFrameLocal->loader().load( |
1698 FrameLoadRequest( | 1717 FrameLoadRequest(nullptr, item2->generateResourceRequest( |
1699 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1718 WebCachePolicy::UseProtocolCachePolicy)), |
1700 item2.get(), WebCachePolicy::UseProtocolCachePolicy)), | |
1701 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad); | 1719 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad); |
1702 mainFrameLocal->loader().load( | 1720 mainFrameLocal->loader().load( |
1703 FrameLoadRequest( | 1721 FrameLoadRequest(nullptr, item1->generateResourceRequest( |
1704 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1722 WebCachePolicy::UseProtocolCachePolicy)), |
1705 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), | |
1706 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); | 1723 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); |
1707 | 1724 |
1708 // Click a different anchor | 1725 // Click a different anchor |
1709 mainFrameLocal->loader().load(FrameLoadRequest( | 1726 mainFrameLocal->loader().load(FrameLoadRequest( |
1710 mainFrameLocal->document(), | 1727 mainFrameLocal->document(), |
1711 ResourceRequest(mainFrameLocal->document()->completeURL("#b")))); | 1728 ResourceRequest(mainFrameLocal->document()->completeURL("#b")))); |
1712 Persistent<HistoryItem> item3 = mainFrameLocal->loader().currentItem(); | 1729 Persistent<HistoryItem> item3 = |
| 1730 mainFrameLocal->loader().documentLoader()->historyItem(); |
1713 | 1731 |
1714 // Go back, then forward. The scroll position should be properly set on the | 1732 // Go back, then forward. The scroll position should be properly set on the |
1715 // forward navigation. | 1733 // forward navigation. |
1716 mainFrameLocal->loader().load( | 1734 mainFrameLocal->loader().load( |
1717 FrameLoadRequest( | 1735 FrameLoadRequest(nullptr, item1->generateResourceRequest( |
1718 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1736 WebCachePolicy::UseProtocolCachePolicy)), |
1719 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), | |
1720 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); | 1737 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); |
1721 mainFrameLocal->loader().load( | 1738 mainFrameLocal->loader().load( |
1722 FrameLoadRequest( | 1739 FrameLoadRequest(nullptr, item3->generateResourceRequest( |
1723 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1740 WebCachePolicy::UseProtocolCachePolicy)), |
1724 item3.get(), WebCachePolicy::UseProtocolCachePolicy)), | |
1725 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); | 1741 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); |
1726 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); | 1742 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); |
1727 EXPECT_GT(webViewImpl->mainFrame()->getScrollOffset().height, 2000); | 1743 EXPECT_GT(webViewImpl->mainFrame()->getScrollOffset().height, 2000); |
1728 } | 1744 } |
1729 | 1745 |
1730 // Tests that we restore scroll and scale *after* the fullscreen styles are | 1746 // Tests that we restore scroll and scale *after* the fullscreen styles are |
1731 // removed and the page is laid out. http://crbug.com/625683. | 1747 // removed and the page is laid out. http://crbug.com/625683. |
1732 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { | 1748 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { |
1733 registerMockedHttpURLLoad("fullscreen_style.html"); | 1749 registerMockedHttpURLLoad("fullscreen_style.html"); |
1734 WebViewImpl* webViewImpl = | 1750 WebViewImpl* webViewImpl = |
(...skipping 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4428 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); | 4444 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); |
4429 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 4445 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
4430 EXPECT_NE(nullptr, | 4446 EXPECT_NE(nullptr, |
4431 frameView->layoutViewportScrollableArea()->verticalScrollbar()); | 4447 frameView->layoutViewportScrollableArea()->verticalScrollbar()); |
4432 } else { | 4448 } else { |
4433 EXPECT_NE(nullptr, frameView->verticalScrollbar()); | 4449 EXPECT_NE(nullptr, frameView->verticalScrollbar()); |
4434 } | 4450 } |
4435 } | 4451 } |
4436 | 4452 |
4437 } // namespace blink | 4453 } // namespace blink |
OLD | NEW |