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