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

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

Issue 2855843002: Reland "Sync requestFullscreen() and exitFullscreen() algorithms with the spec" (Closed)
Patch Set: Reland "Sync requestFullscreen() and exitFullscreen() algorithms with the spec" 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
« 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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); 1775 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000));
1776 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); 1776 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height);
1777 1777
1778 // Enter fullscreen. 1778 // Enter fullscreen.
1779 Document* document = 1779 Document* document =
1780 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); 1780 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument();
1781 Element* element = document->getElementById("fullscreenElement"); 1781 Element* element = document->getElementById("fullscreenElement");
1782 UserGestureIndicator gesture(UserGestureToken::Create(document)); 1782 UserGestureIndicator gesture(UserGestureToken::Create(document));
1783 Fullscreen::RequestFullscreen(*element); 1783 Fullscreen::RequestFullscreen(*element);
1784 web_view_impl->DidEnterFullscreen(); 1784 web_view_impl->DidEnterFullscreen();
1785 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1785 web_view_impl->UpdateAllLifecyclePhases(); 1786 web_view_impl->UpdateAllLifecyclePhases();
1786 1787
1787 // Sanity-check. There should be no scrolling possible. 1788 // Sanity-check. There should be no scrolling possible.
1788 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); 1789 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height);
1789 ASSERT_EQ(0, web_view_impl->MainFrameImpl() 1790 ASSERT_EQ(0, web_view_impl->MainFrameImpl()
1790 ->GetFrameView() 1791 ->GetFrameView()
1791 ->MaximumScrollOffset() 1792 ->MaximumScrollOffset()
1792 .Height()); 1793 .Height());
1793 1794
1794 // Confirm that after exiting and doing a layout, the scroll and scale 1795 // Confirm that after exiting and doing a layout, the scroll and scale
1795 // parameters are reset. The page sets display: none on overflowing elements 1796 // parameters are reset. The page sets display: none on overflowing elements
1796 // while in fullscreen so if we try to restore before the style and layout 1797 // while in fullscreen so if we try to restore before the style and layout
1797 // is applied the offsets will be clamped. 1798 // is applied the offsets will be clamped.
1799 EXPECT_FALSE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout());
1798 web_view_impl->DidExitFullscreen(); 1800 web_view_impl->DidExitFullscreen();
1799 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); 1801 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout());
1802 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1803 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height);
1800 web_view_impl->UpdateAllLifecyclePhases(); 1804 web_view_impl->UpdateAllLifecyclePhases();
1801
1802 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); 1805 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height);
1803 } 1806 }
1804 1807
1805 // Tests that exiting and immediately reentering fullscreen doesn't cause the 1808 // Tests that exiting and immediately reentering fullscreen doesn't cause the
1806 // scroll and scale restoration to occur when we enter fullscreen again. 1809 // scroll and scale restoration to occur when we enter fullscreen again.
1807 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { 1810 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) {
1808 RegisterMockedHttpURLLoad("fullscreen_style.html"); 1811 RegisterMockedHttpURLLoad("fullscreen_style.html");
1809 WebViewBase* web_view_impl = 1812 WebViewBase* web_view_impl =
1810 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); 1813 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html");
1811 web_view_impl->Resize(WebSize(800, 600)); 1814 web_view_impl->Resize(WebSize(800, 600));
1812 web_view_impl->UpdateAllLifecyclePhases(); 1815 web_view_impl->UpdateAllLifecyclePhases();
1813 1816
1814 // Scroll the page down. 1817 // Scroll the page down.
1815 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); 1818 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000));
1816 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); 1819 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height);
1817 1820
1818 // Enter fullscreen. 1821 // Enter fullscreen.
1819 Document* document = 1822 Document* document =
1820 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); 1823 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument();
1821 Element* element = document->getElementById("fullscreenElement"); 1824 Element* element = document->getElementById("fullscreenElement");
1822 UserGestureIndicator gesture(UserGestureToken::Create(document)); 1825 UserGestureIndicator gesture(UserGestureToken::Create(document));
1823 Fullscreen::RequestFullscreen(*element); 1826 Fullscreen::RequestFullscreen(*element);
1824 web_view_impl->DidEnterFullscreen(); 1827 web_view_impl->DidEnterFullscreen();
1828 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1825 web_view_impl->UpdateAllLifecyclePhases(); 1829 web_view_impl->UpdateAllLifecyclePhases();
1826 1830
1827 // Sanity-check. There should be no scrolling possible. 1831 // Sanity-check. There should be no scrolling possible.
1828 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); 1832 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height);
1829 ASSERT_EQ(0, web_view_impl->MainFrameImpl() 1833 ASSERT_EQ(0, web_view_impl->MainFrameImpl()
1830 ->GetFrameView() 1834 ->GetFrameView()
1831 ->MaximumScrollOffset() 1835 ->MaximumScrollOffset()
1832 .Height()); 1836 .Height());
1833 1837
1834 // Exit and, without performing a layout, reenter fullscreen again. We 1838 // Exit and, without performing a layout, reenter fullscreen again. We
1835 // shouldn't try to restore the scroll and scale values when we layout to 1839 // shouldn't try to restore the scroll and scale values when we layout to
1836 // enter fullscreen. 1840 // enter fullscreen.
1837 web_view_impl->DidExitFullscreen(); 1841 web_view_impl->DidExitFullscreen();
1838 Fullscreen::RequestFullscreen(*element); 1842 Fullscreen::RequestFullscreen(*element);
1839 web_view_impl->DidEnterFullscreen(); 1843 web_view_impl->DidEnterFullscreen();
1844 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1840 web_view_impl->UpdateAllLifecyclePhases(); 1845 web_view_impl->UpdateAllLifecyclePhases();
1841 1846
1842 // Sanity-check. There should be no scrolling possible. 1847 // Sanity-check. There should be no scrolling possible.
1843 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); 1848 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height);
1844 ASSERT_EQ(0, web_view_impl->MainFrameImpl() 1849 ASSERT_EQ(0, web_view_impl->MainFrameImpl()
1845 ->GetFrameView() 1850 ->GetFrameView()
1846 ->MaximumScrollOffset() 1851 ->MaximumScrollOffset()
1847 .Height()); 1852 .Height());
1848 1853
1849 // When we exit now, we should restore the original scroll value. 1854 // When we exit now, we should restore the original scroll value.
1850 web_view_impl->DidExitFullscreen(); 1855 web_view_impl->DidExitFullscreen();
1856 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1851 web_view_impl->UpdateAllLifecyclePhases(); 1857 web_view_impl->UpdateAllLifecyclePhases();
1852 1858
1853 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); 1859 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height);
1854 } 1860 }
1855 1861
1856 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { 1862 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) {
1857 RegisterMockedHttpURLLoad("200-by-300.html"); 1863 RegisterMockedHttpURLLoad("200-by-300.html");
1858 WebViewBase* web_view_impl = 1864 WebViewBase* web_view_impl =
1859 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); 1865 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html");
1860 web_view_impl->Resize(WebSize(100, 150)); 1866 web_view_impl->Resize(WebSize(100, 150));
(...skipping 10 matching lines...) Expand all
1871 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); 1877 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height);
1872 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); 1878 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x);
1873 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); 1879 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y);
1874 1880
1875 Document* document = 1881 Document* document =
1876 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); 1882 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument();
1877 Element* element = document->body(); 1883 Element* element = document->body();
1878 UserGestureIndicator gesture(UserGestureToken::Create(document)); 1884 UserGestureIndicator gesture(UserGestureToken::Create(document));
1879 Fullscreen::RequestFullscreen(*element); 1885 Fullscreen::RequestFullscreen(*element);
1880 web_view_impl->DidEnterFullscreen(); 1886 web_view_impl->DidEnterFullscreen();
1887 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1888 web_view_impl->UpdateAllLifecyclePhases();
1881 1889
1882 // Page scale factor must be 1.0 during fullscreen for elements to be sized 1890 // Page scale factor must be 1.0 during fullscreen for elements to be sized
1883 // properly. 1891 // properly.
1884 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); 1892 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor());
1885 1893
1886 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. 1894 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving.
1887 Element* other_element = document->getElementById("content"); 1895 Element* other_element = document->getElementById("content");
1888 Fullscreen::RequestFullscreen(*other_element); 1896 Fullscreen::RequestFullscreen(*other_element);
1889 1897
1890 // Confirm that exiting fullscreen restores the parameters. 1898 // Confirm that exiting fullscreen restores the parameters.
1891 web_view_impl->DidExitFullscreen(); 1899 web_view_impl->DidExitFullscreen();
1900 web_view_impl->BeginFrame(WTF::MonotonicallyIncreasingTime());
1892 web_view_impl->UpdateAllLifecyclePhases(); 1901 web_view_impl->UpdateAllLifecyclePhases();
1893 1902
1894 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); 1903 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor());
1895 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); 1904 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width);
1896 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); 1905 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height);
1897 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); 1906 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x);
1898 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); 1907 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y);
1899 } 1908 }
1900 1909
1901 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { 1910 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient {
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
4338 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); 4347 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars());
4339 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4348 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4340 EXPECT_NE(nullptr, 4349 EXPECT_NE(nullptr,
4341 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); 4350 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar());
4342 } else { 4351 } else {
4343 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); 4352 EXPECT_NE(nullptr, frame_view->VerticalScrollbar());
4344 } 4353 }
4345 } 4354 }
4346 4355
4347 } // namespace blink 4356 } // 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