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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 636363003: Fix fullscreen elements in pinch viewport mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test Created 6 years, 2 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 | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/fullscreen_iframe.html » ('j') | 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
60 #include "core/html/HTMLDocument.h" 60 #include "core/html/HTMLDocument.h"
61 #include "core/html/HTMLFormElement.h" 61 #include "core/html/HTMLFormElement.h"
62 #include "core/loader/DocumentThreadableLoader.h" 62 #include "core/loader/DocumentThreadableLoader.h"
63 #include "core/loader/DocumentThreadableLoaderClient.h" 63 #include "core/loader/DocumentThreadableLoaderClient.h"
64 #include "core/loader/FrameLoadRequest.h" 64 #include "core/loader/FrameLoadRequest.h"
65 #include "core/loader/ThreadableLoader.h" 65 #include "core/loader/ThreadableLoader.h"
66 #include "core/page/EventHandler.h" 66 #include "core/page/EventHandler.h"
67 #include "core/page/Page.h" 67 #include "core/page/Page.h"
68 #include "core/rendering/HitTestResult.h" 68 #include "core/rendering/HitTestResult.h"
69 #include "core/rendering/RenderFullScreen.h"
69 #include "core/rendering/RenderView.h" 70 #include "core/rendering/RenderView.h"
70 #include "core/rendering/compositing/RenderLayerCompositor.h" 71 #include "core/rendering/compositing/RenderLayerCompositor.h"
71 #include "core/testing/URLTestHelpers.h" 72 #include "core/testing/URLTestHelpers.h"
72 #include "platform/DragImage.h" 73 #include "platform/DragImage.h"
73 #include "platform/RuntimeEnabledFeatures.h" 74 #include "platform/RuntimeEnabledFeatures.h"
74 #include "platform/UserGestureIndicator.h" 75 #include "platform/UserGestureIndicator.h"
75 #include "platform/geometry/FloatRect.h" 76 #include "platform/geometry/FloatRect.h"
76 #include "platform/network/ResourceError.h" 77 #include "platform/network/ResourceError.h"
77 #include "platform/scroll/ScrollbarTheme.h" 78 #include "platform/scroll/ScrollbarTheme.h"
78 #include "platform/weborigin/SchemeRegistry.h" 79 #include "platform/weborigin/SchemeRegistry.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 EXPECT_EQ((expected).y(), (actual).y()); \ 136 EXPECT_EQ((expected).y(), (actual).y()); \
136 } while (false) 137 } while (false)
137 138
138 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ 139 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \
139 do { \ 140 do { \
140 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ 141 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
141 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ 142 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
142 } while (false) 143 } while (false)
143 144
144 145
145 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient {
146 public:
147 virtual bool enterFullScreen() override { return true; }
148 };
149
150 class WebFrameTest : public testing::Test { 146 class WebFrameTest : public testing::Test {
151 protected: 147 protected:
152 WebFrameTest() 148 WebFrameTest()
153 : m_baseURL("http://internal.test/") 149 : m_baseURL("http://internal.test/")
154 , m_notBaseURL("http://external.test/") 150 , m_notBaseURL("http://external.test/")
155 , m_chromeURL("chrome://") 151 , m_chromeURL("chrome://")
156 { 152 {
157 } 153 }
158 154
159 virtual ~WebFrameTest() 155 virtual ~WebFrameTest()
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 runPendingTasks(); 691 runPendingTasks();
696 } 692 }
697 693
698 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 694 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
699 public: 695 public:
700 virtual WebScreenInfo screenInfo() override { return m_screenInfo; } 696 virtual WebScreenInfo screenInfo() override { return m_screenInfo; }
701 697
702 WebScreenInfo m_screenInfo; 698 WebScreenInfo m_screenInfo;
703 }; 699 };
704 700
701 class FakeCompositingWebViewClient : public FixedLayoutTestWebViewClient {
702 public:
703 virtual bool enterFullScreen() override { return true; }
704 };
705
705 // Viewport settings need to be set before the page gets loaded 706 // Viewport settings need to be set before the page gets loaded
706 static void enableViewportSettings(WebSettings* settings) 707 static void enableViewportSettings(WebSettings* settings)
707 { 708 {
708 settings->setViewportMetaEnabled(true); 709 settings->setViewportMetaEnabled(true);
709 settings->setViewportEnabled(true); 710 settings->setViewportEnabled(true);
710 settings->setMainFrameResizesAreOrientationChanges(true); 711 settings->setMainFrameResizesAreOrientationChanges(true);
711 settings->setShrinksViewportContentToFit(true); 712 settings->setShrinksViewportContentToFit(true);
712 } 713 }
713 714
714 // Helper function to set autosizing multipliers on a document. 715 // Helper function to set autosizing multipliers on a document.
(...skipping 5393 matching lines...) Expand 10 before | Expand all | Expand 10 after
6108 // Show the top controls by just 1px, since we're zoomed in to 2X, that 6109 // Show the top controls by just 1px, since we're zoomed in to 2X, that
6109 // should allow an extra 0.5px of scrolling, but since we quantize to ints 6110 // should allow an extra 0.5px of scrolling, but since we quantize to ints
6110 // it should clamp such that we don't show anything outside bounds. 6111 // it should clamp such that we don't show anything outside bounds.
6111 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); 6112 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f);
6112 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition()); 6113 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition());
6113 6114
6114 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); 6115 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f);
6115 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition()); 6116 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition());
6116 } 6117 }
6117 6118
6119 TEST_F(WebFrameTest, FullscreenLayerSize)
6120 {
6121 FakeCompositingWebViewClient client;
6122 registerMockedHttpURLLoad("fullscreen_div.html");
6123 FrameTestHelpers::WebViewHelper webViewHelper;
6124 int viewportWidth = 640;
6125 int viewportHeight = 480;
6126 client.m_screenInfo.rect.width = viewportWidth;
6127 client.m_screenInfo.rect.height = viewportHeight;
6128 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport);
6129 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6130 webViewImpl->layout();
6131
6132 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document();
6133 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6134 Element* divFullscreen = document->getElementById("div1");
6135 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6136 webViewImpl->didEnterFullScreen();
6137 webViewImpl->layout();
6138 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6139
6140 // Verify that the element is sized to the viewport.
6141 RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScree nRenderer();
6142 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt());
6143 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt());
6144
6145 // Verify it's updated after a device rotation.
6146 client.m_screenInfo.rect.width = viewportHeight;
6147 client.m_screenInfo.rect.height = viewportWidth;
6148 webViewImpl->resize(WebSize(viewportHeight, viewportWidth));
6149 webViewImpl->layout();
6150 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt());
6151 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt());
6152 }
6153
6118 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) 6154 TEST_F(WebFrameTest, FullscreenLayerNonScrollable)
6119 { 6155 {
6120 FakeCompositingWebViewClient client; 6156 FakeCompositingWebViewClient client;
6121 registerMockedHttpURLLoad("fullscreen_div.html"); 6157 registerMockedHttpURLLoad("fullscreen_div.html");
6122 FrameTestHelpers::WebViewHelper webViewHelper; 6158 FrameTestHelpers::WebViewHelper webViewHelper;
6123 int viewportWidth = 640; 6159 int viewportWidth = 640;
6124 int viewportHeight = 480; 6160 int viewportHeight = 480;
6125 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView); 6161 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport);
6126 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); 6162 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6127 webViewImpl->layout(); 6163 webViewImpl->layout();
6128 6164
6129 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6165 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document();
6130 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6166 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6131 Element* divFullscreen = document->getElementById("div1"); 6167 Element* divFullscreen = document->getElementById("div1");
6132 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); 6168 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6133 webViewImpl->didEnterFullScreen(); 6169 webViewImpl->didEnterFullScreen();
6134 webViewImpl->layout(); 6170 webViewImpl->layout();
6135 6171
6136 // Verify that the main frame bounds are empty. 6172 // Verify that the main frame is nonscrollable.
6137 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6173 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6138 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); 6174 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer();
6139 ASSERT_EQ(WebSize(), webScrollLayer->bounds()); 6175 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal());
6176 ASSERT_FALSE(webScrollLayer->userScrollableVertical());
6140 6177
6141 // Verify that the main frame is scrollable upon exiting fullscreen. 6178 // Verify that the main frame is scrollable upon exiting fullscreen.
6142 webViewImpl->didExitFullScreen(); 6179 webViewImpl->didExitFullScreen();
6143 webViewImpl->layout(); 6180 webViewImpl->layout();
6144 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); 6181 ASSERT_FALSE(Fullscreen::isFullScreen(*document));
6145 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); 6182 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer();
6146 ASSERT_NE(WebSize(), webScrollLayer->bounds()); 6183 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
6184 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
6147 } 6185 }
6148 6186
6149 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) 6187 TEST_F(WebFrameTest, FullscreenMainFrameScrollable)
6150 { 6188 {
6151 FakeCompositingWebViewClient client; 6189 FakeCompositingWebViewClient client;
6152 registerMockedHttpURLLoad("fullscreen_div.html"); 6190 registerMockedHttpURLLoad("fullscreen_div.html");
6153 FrameTestHelpers::WebViewHelper webViewHelper; 6191 FrameTestHelpers::WebViewHelper webViewHelper;
6154 int viewportWidth = 640; 6192 int viewportWidth = 640;
6155 int viewportHeight = 480; 6193 int viewportHeight = 480;
6156 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView); 6194 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport);
6157 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); 6195 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6158 webViewImpl->layout(); 6196 webViewImpl->layout();
6159 6197
6160 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6198 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document();
6161 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6199 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6162 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest); 6200 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest);
6163 webViewImpl->didEnterFullScreen(); 6201 webViewImpl->didEnterFullScreen();
6164 webViewImpl->layout(); 6202 webViewImpl->layout();
6165 6203
6166 // Verify that the main frame is still scrollable. 6204 // Verify that the main frame is still scrollable.
6167 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6205 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6168 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); 6206 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer();
6169 ASSERT_TRUE(webScrollLayer->scrollable()); 6207 ASSERT_TRUE(webScrollLayer->scrollable());
6208 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
6209 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
6210 }
6211
6212 TEST_F(WebFrameTest, FullscreenSubframe)
6213 {
6214 FakeCompositingWebViewClient client;
6215 registerMockedHttpURLLoad("fullscreen_iframe.html");
6216 registerMockedHttpURLLoad("fullscreen_div.html");
6217 FrameTestHelpers::WebViewHelper webViewHelper;
6218 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_iframe.html", true, 0, &client, configurePinchVirtualViewport);
6219 int viewportWidth = 640;
6220 int viewportHeight = 480;
6221 client.m_screenInfo.rect.width = viewportWidth;
6222 client.m_screenInfo.rect.height = viewportHeight;
6223 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6224 webViewImpl->layout();
6225
6226 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame( )->firstChild())->frame()->document();
6227 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6228 Element* divFullscreen = document->getElementById("div1");
6229 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6230 webViewImpl->didEnterFullScreen();
6231 webViewImpl->layout();
6232
6233 // Verify that the element is sized to the viewport.
6234 RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScree nRenderer();
6235 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt());
6236 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt());
6237
6238 // Verify it's updated after a device rotation.
6239 client.m_screenInfo.rect.width = viewportHeight;
6240 client.m_screenInfo.rect.height = viewportWidth;
6241 webViewImpl->resize(WebSize(viewportHeight, viewportWidth));
6242 webViewImpl->layout();
6243 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt());
6244 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt());
6170 } 6245 }
6171 6246
6172 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) 6247 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants)
6173 { 6248 {
6174 registerMockedHttpURLLoad("percent-height-descendants.html"); 6249 registerMockedHttpURLLoad("percent-height-descendants.html");
6175 FrameTestHelpers::WebViewHelper webViewHelper; 6250 FrameTestHelpers::WebViewHelper webViewHelper;
6176 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html "); 6251 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html ");
6177 6252
6178 WebView* webView = webViewHelper.webView(); 6253 WebView* webView = webViewHelper.webView();
6179 webView->resize(WebSize(800, 800)); 6254 webView->resize(WebSize(800, 800));
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
6722 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6797 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6723 6798
6724 // Neither should a page reload. 6799 // Neither should a page reload.
6725 localFrame->reload(); 6800 localFrame->reload();
6726 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6801 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6727 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6802 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6728 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6803 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6729 } 6804 }
6730 6805
6731 } // namespace 6806 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/fullscreen_iframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698