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

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

Issue 2557943002: Sync requestFullscreen() and exitFullscreen() algorithms with the spec (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 // Scroll the page down. 1718 // Scroll the page down.
1719 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); 1719 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000));
1720 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1720 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1721 1721
1722 // Enter fullscreen. 1722 // Enter fullscreen.
1723 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 1723 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
1724 Element* element = document->getElementById("fullscreenElement"); 1724 Element* element = document->getElementById("fullscreenElement");
1725 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 1725 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
1726 Fullscreen::requestFullscreen(*element); 1726 Fullscreen::requestFullscreen(*element);
1727 webViewImpl->didEnterFullscreen(); 1727 webViewImpl->didEnterFullscreen();
1728 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1728 webViewImpl->updateAllLifecyclePhases(); 1729 webViewImpl->updateAllLifecyclePhases();
1729 1730
1730 // Sanity-check. There should be no scrolling possible. 1731 // Sanity-check. There should be no scrolling possible.
1731 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1732 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1732 ASSERT_EQ(0, webViewImpl->mainFrameImpl() 1733 ASSERT_EQ(0, webViewImpl->mainFrameImpl()
1733 ->frameView() 1734 ->frameView()
1734 ->maximumScrollOffset() 1735 ->maximumScrollOffset()
1735 .height()); 1736 .height());
1736 1737
1737 // Confirm that after exiting and doing a layout, the scroll and scale 1738 // Confirm that after exiting and doing a layout, the scroll and scale
1738 // parameters are reset. The page sets display: none on overflowing elements 1739 // parameters are reset. The page sets display: none on overflowing elements
1739 // while in fullscreen so if we try to restore before the style and layout 1740 // while in fullscreen so if we try to restore before the style and layout
1740 // is applied the offsets will be clamped. 1741 // is applied the offsets will be clamped.
1742 EXPECT_FALSE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
1741 webViewImpl->didExitFullscreen(); 1743 webViewImpl->didExitFullscreen();
1742 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout()); 1744 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
1745 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1746 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1743 webViewImpl->updateAllLifecyclePhases(); 1747 webViewImpl->updateAllLifecyclePhases();
1744
1745 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1748 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1746 } 1749 }
1747 1750
1748 // Tests that exiting and immediately reentering fullscreen doesn't cause the 1751 // Tests that exiting and immediately reentering fullscreen doesn't cause the
1749 // scroll and scale restoration to occur when we enter fullscreen again. 1752 // scroll and scale restoration to occur when we enter fullscreen again.
1750 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { 1753 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) {
1751 URLTestHelpers::registerMockedURLFromBaseURL( 1754 URLTestHelpers::registerMockedURLFromBaseURL(
1752 WebString::fromUTF8(m_baseURL.c_str()), 1755 WebString::fromUTF8(m_baseURL.c_str()),
1753 WebString::fromUTF8("fullscreen_style.html")); 1756 WebString::fromUTF8("fullscreen_style.html"));
1754 WebViewImpl* webViewImpl = 1757 WebViewImpl* webViewImpl =
1755 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html"); 1758 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html");
1756 webViewImpl->resize(WebSize(800, 600)); 1759 webViewImpl->resize(WebSize(800, 600));
1757 webViewImpl->updateAllLifecyclePhases(); 1760 webViewImpl->updateAllLifecyclePhases();
1758 1761
1759 // Scroll the page down. 1762 // Scroll the page down.
1760 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); 1763 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000));
1761 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1764 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1762 1765
1763 // Enter fullscreen. 1766 // Enter fullscreen.
1764 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 1767 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
1765 Element* element = document->getElementById("fullscreenElement"); 1768 Element* element = document->getElementById("fullscreenElement");
1766 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 1769 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
1767 Fullscreen::requestFullscreen(*element); 1770 Fullscreen::requestFullscreen(*element);
1768 webViewImpl->didEnterFullscreen(); 1771 webViewImpl->didEnterFullscreen();
1772 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1769 webViewImpl->updateAllLifecyclePhases(); 1773 webViewImpl->updateAllLifecyclePhases();
1770 1774
1771 // Sanity-check. There should be no scrolling possible. 1775 // Sanity-check. There should be no scrolling possible.
1772 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1776 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1773 ASSERT_EQ(0, webViewImpl->mainFrameImpl() 1777 ASSERT_EQ(0, webViewImpl->mainFrameImpl()
1774 ->frameView() 1778 ->frameView()
1775 ->maximumScrollOffset() 1779 ->maximumScrollOffset()
1776 .height()); 1780 .height());
1777 1781
1778 // Exit and, without performing a layout, reenter fullscreen again. We 1782 // Exit and, without performing a layout, reenter fullscreen again. We
1779 // shouldn't try to restore the scroll and scale values when we layout to 1783 // shouldn't try to restore the scroll and scale values when we layout to
1780 // enter fullscreen. 1784 // enter fullscreen.
1781 webViewImpl->didExitFullscreen(); 1785 webViewImpl->didExitFullscreen();
1782 Fullscreen::requestFullscreen(*element); 1786 Fullscreen::requestFullscreen(*element);
1783 webViewImpl->didEnterFullscreen(); 1787 webViewImpl->didEnterFullscreen();
1788 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1784 webViewImpl->updateAllLifecyclePhases(); 1789 webViewImpl->updateAllLifecyclePhases();
1785 1790
1786 // Sanity-check. There should be no scrolling possible. 1791 // Sanity-check. There should be no scrolling possible.
1787 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1792 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1788 ASSERT_EQ(0, webViewImpl->mainFrameImpl() 1793 ASSERT_EQ(0, webViewImpl->mainFrameImpl()
1789 ->frameView() 1794 ->frameView()
1790 ->maximumScrollOffset() 1795 ->maximumScrollOffset()
1791 .height()); 1796 .height());
1792 1797
1793 // When we exit now, we should restore the original scroll value. 1798 // When we exit now, we should restore the original scroll value.
1794 webViewImpl->didExitFullscreen(); 1799 webViewImpl->didExitFullscreen();
1800 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1795 webViewImpl->updateAllLifecyclePhases(); 1801 webViewImpl->updateAllLifecyclePhases();
1796 1802
1797 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1803 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1798 } 1804 }
1799 1805
1800 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { 1806 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) {
1801 URLTestHelpers::registerMockedURLFromBaseURL( 1807 URLTestHelpers::registerMockedURLFromBaseURL(
1802 WebString::fromUTF8(m_baseURL.c_str()), 1808 WebString::fromUTF8(m_baseURL.c_str()),
1803 WebString::fromUTF8("200-by-300.html")); 1809 WebString::fromUTF8("200-by-300.html"));
1804 WebViewImpl* webViewImpl = 1810 WebViewImpl* webViewImpl =
(...skipping 11 matching lines...) Expand all
1816 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); 1822 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width);
1817 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); 1823 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height);
1818 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); 1824 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x);
1819 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); 1825 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y);
1820 1826
1821 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 1827 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
1822 Element* element = document->body(); 1828 Element* element = document->body();
1823 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 1829 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
1824 Fullscreen::requestFullscreen(*element); 1830 Fullscreen::requestFullscreen(*element);
1825 webViewImpl->didEnterFullscreen(); 1831 webViewImpl->didEnterFullscreen();
1832 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1833 webViewImpl->updateAllLifecyclePhases();
1826 1834
1827 // Page scale factor must be 1.0 during fullscreen for elements to be sized 1835 // Page scale factor must be 1.0 during fullscreen for elements to be sized
1828 // properly. 1836 // properly.
1829 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); 1837 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor());
1830 1838
1831 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. 1839 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving.
1832 Element* otherElement = document->getElementById("content"); 1840 Element* otherElement = document->getElementById("content");
1833 Fullscreen::requestFullscreen(*otherElement); 1841 Fullscreen::requestFullscreen(*otherElement);
1834 1842
1835 // Confirm that exiting fullscreen restores the parameters. 1843 // Confirm that exiting fullscreen restores the parameters.
1836 webViewImpl->didExitFullscreen(); 1844 webViewImpl->didExitFullscreen();
1845 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1837 webViewImpl->updateAllLifecyclePhases(); 1846 webViewImpl->updateAllLifecyclePhases();
1838 1847
1839 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 1848 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
1840 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); 1849 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width);
1841 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); 1850 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height);
1842 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); 1851 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x);
1843 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); 1852 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y);
1844 } 1853 }
1845 1854
1846 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { 1855 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient {
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after
4245 .translate(50, 55) 4254 .translate(50, 55)
4246 .scale(1. / 2.f); 4255 .scale(1. / 2.f);
4247 EXPECT_EQ(expectedMatrix, 4256 EXPECT_EQ(expectedMatrix,
4248 webViewImpl->getDeviceEmulationTransformForTesting()); 4257 webViewImpl->getDeviceEmulationTransformForTesting());
4249 // visibleContentRect doesn't change. 4258 // visibleContentRect doesn't change.
4250 EXPECT_EQ(IntRect(50, 55, 50, 75), 4259 EXPECT_EQ(IntRect(50, 55, 50, 75),
4251 *devToolsEmulator->visibleContentRectForPainting()); 4260 *devToolsEmulator->visibleContentRectForPainting());
4252 } 4261 }
4253 4262
4254 } // namespace blink 4263 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698