OLD | NEW |
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 Loading... |
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" | |
70 #include "core/rendering/RenderView.h" | 69 #include "core/rendering/RenderView.h" |
71 #include "core/rendering/compositing/RenderLayerCompositor.h" | 70 #include "core/rendering/compositing/RenderLayerCompositor.h" |
72 #include "core/testing/URLTestHelpers.h" | 71 #include "core/testing/URLTestHelpers.h" |
73 #include "platform/DragImage.h" | 72 #include "platform/DragImage.h" |
74 #include "platform/RuntimeEnabledFeatures.h" | 73 #include "platform/RuntimeEnabledFeatures.h" |
75 #include "platform/UserGestureIndicator.h" | 74 #include "platform/UserGestureIndicator.h" |
76 #include "platform/geometry/FloatRect.h" | 75 #include "platform/geometry/FloatRect.h" |
77 #include "platform/network/ResourceError.h" | 76 #include "platform/network/ResourceError.h" |
78 #include "platform/scroll/ScrollbarTheme.h" | 77 #include "platform/scroll/ScrollbarTheme.h" |
79 #include "platform/weborigin/SchemeRegistry.h" | 78 #include "platform/weborigin/SchemeRegistry.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EXPECT_EQ((expected).y(), (actual).y()); \ | 136 EXPECT_EQ((expected).y(), (actual).y()); \ |
138 } while (false) | 137 } while (false) |
139 | 138 |
140 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ | 139 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ |
141 do { \ | 140 do { \ |
142 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ | 141 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
143 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ | 142 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
144 } while (false) | 143 } while (false) |
145 | 144 |
146 | 145 |
| 146 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
| 147 public: |
| 148 virtual bool enterFullScreen() override { return true; } |
| 149 }; |
| 150 |
147 class WebFrameTest : public testing::Test { | 151 class WebFrameTest : public testing::Test { |
148 protected: | 152 protected: |
149 WebFrameTest() | 153 WebFrameTest() |
150 : m_baseURL("http://internal.test/") | 154 : m_baseURL("http://internal.test/") |
151 , m_notBaseURL("http://external.test/") | 155 , m_notBaseURL("http://external.test/") |
152 , m_chromeURL("chrome://") | 156 , m_chromeURL("chrome://") |
153 { | 157 { |
154 } | 158 } |
155 | 159 |
156 virtual ~WebFrameTest() | 160 virtual ~WebFrameTest() |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 runPendingTasks(); | 680 runPendingTasks(); |
677 } | 681 } |
678 | 682 |
679 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 683 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
680 public: | 684 public: |
681 virtual WebScreenInfo screenInfo() override { return m_screenInfo; } | 685 virtual WebScreenInfo screenInfo() override { return m_screenInfo; } |
682 | 686 |
683 WebScreenInfo m_screenInfo; | 687 WebScreenInfo m_screenInfo; |
684 }; | 688 }; |
685 | 689 |
686 class FakeCompositingWebViewClient : public FixedLayoutTestWebViewClient { | |
687 public: | |
688 virtual bool enterFullScreen() override { return true; } | |
689 }; | |
690 | |
691 // Viewport settings need to be set before the page gets loaded | 690 // Viewport settings need to be set before the page gets loaded |
692 static void enableViewportSettings(WebSettings* settings) | 691 static void enableViewportSettings(WebSettings* settings) |
693 { | 692 { |
694 settings->setViewportMetaEnabled(true); | 693 settings->setViewportMetaEnabled(true); |
695 settings->setViewportEnabled(true); | 694 settings->setViewportEnabled(true); |
696 settings->setMainFrameResizesAreOrientationChanges(true); | 695 settings->setMainFrameResizesAreOrientationChanges(true); |
697 settings->setShrinksViewportContentToFit(true); | 696 settings->setShrinksViewportContentToFit(true); |
698 } | 697 } |
699 | 698 |
700 // Helper function to set autosizing multipliers on a document. | 699 // Helper function to set autosizing multipliers on a document. |
(...skipping 5393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6094 // Show the top controls by just 1px, since we're zoomed in to 2X, that | 6093 // Show the top controls by just 1px, since we're zoomed in to 2X, that |
6095 // should allow an extra 0.5px of scrolling, but since we quantize to ints | 6094 // should allow an extra 0.5px of scrolling, but since we quantize to ints |
6096 // it should clamp such that we don't show anything outside bounds. | 6095 // it should clamp such that we don't show anything outside bounds. |
6097 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); | 6096 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); |
6098 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition()); | 6097 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition()); |
6099 | 6098 |
6100 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); | 6099 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); |
6101 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition()); | 6100 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition()); |
6102 } | 6101 } |
6103 | 6102 |
6104 TEST_F(WebFrameTest, FullscreenLayerSize) | |
6105 { | |
6106 FakeCompositingWebViewClient client; | |
6107 registerMockedHttpURLLoad("fullscreen_div.html"); | |
6108 FrameTestHelpers::WebViewHelper webViewHelper; | |
6109 int viewportWidth = 640; | |
6110 int viewportHeight = 480; | |
6111 client.m_screenInfo.rect.width = viewportWidth; | |
6112 client.m_screenInfo.rect.height = viewportHeight; | |
6113 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, configurePinchVirtualViewport); | |
6114 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | |
6115 webViewImpl->layout(); | |
6116 | |
6117 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | |
6118 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | |
6119 Element* divFullscreen = document->getElementById("div1"); | |
6120 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | |
6121 webViewImpl->didEnterFullScreen(); | |
6122 webViewImpl->layout(); | |
6123 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | |
6124 | |
6125 // Verify that the element is sized to the viewport. | |
6126 RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScree
nRenderer(); | |
6127 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt()); | |
6128 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt()); | |
6129 | |
6130 // Verify it's updated after a device rotation. | |
6131 client.m_screenInfo.rect.width = viewportHeight; | |
6132 client.m_screenInfo.rect.height = viewportWidth; | |
6133 webViewImpl->resize(WebSize(viewportHeight, viewportWidth)); | |
6134 webViewImpl->layout(); | |
6135 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt()); | |
6136 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt()); | |
6137 | |
6138 } | |
6139 | |
6140 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) | 6103 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
6141 { | 6104 { |
6142 FakeCompositingWebViewClient client; | 6105 FakeCompositingWebViewClient client; |
6143 registerMockedHttpURLLoad("fullscreen_div.html"); | 6106 registerMockedHttpURLLoad("fullscreen_div.html"); |
6144 FrameTestHelpers::WebViewHelper webViewHelper; | 6107 FrameTestHelpers::WebViewHelper webViewHelper; |
6145 int viewportWidth = 640; | 6108 int viewportWidth = 640; |
6146 int viewportHeight = 480; | 6109 int viewportHeight = 480; |
6147 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, configurePinchVirtualViewport); | 6110 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
6148 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 6111 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
6149 webViewImpl->layout(); | 6112 webViewImpl->layout(); |
6150 | 6113 |
6151 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 6114 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
6152 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6115 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
6153 Element* divFullscreen = document->getElementById("div1"); | 6116 Element* divFullscreen = document->getElementById("div1"); |
6154 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | 6117 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); |
6155 webViewImpl->didEnterFullScreen(); | 6118 webViewImpl->didEnterFullScreen(); |
6156 webViewImpl->layout(); | 6119 webViewImpl->layout(); |
6157 | 6120 |
6158 // Verify that the main frame is nonscrollable. | 6121 // Verify that the main frame bounds are empty. |
6159 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | 6122 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
6160 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 6123 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
6161 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 6124 ASSERT_EQ(WebSize(), webScrollLayer->bounds()); |
6162 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | |
6163 | 6125 |
6164 // Verify that the main frame is scrollable upon exiting fullscreen. | 6126 // Verify that the main frame is scrollable upon exiting fullscreen. |
6165 webViewImpl->didExitFullScreen(); | 6127 webViewImpl->didExitFullScreen(); |
6166 webViewImpl->layout(); | 6128 webViewImpl->layout(); |
6167 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); | 6129 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); |
6168 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); | 6130 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
6169 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 6131 ASSERT_NE(WebSize(), webScrollLayer->bounds()); |
6170 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | |
6171 } | 6132 } |
6172 | 6133 |
6173 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) | 6134 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
6174 { | 6135 { |
6175 FakeCompositingWebViewClient client; | 6136 FakeCompositingWebViewClient client; |
6176 registerMockedHttpURLLoad("fullscreen_div.html"); | 6137 registerMockedHttpURLLoad("fullscreen_div.html"); |
6177 FrameTestHelpers::WebViewHelper webViewHelper; | 6138 FrameTestHelpers::WebViewHelper webViewHelper; |
6178 int viewportWidth = 640; | 6139 int viewportWidth = 640; |
6179 int viewportHeight = 480; | 6140 int viewportHeight = 480; |
6180 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, configurePinchVirtualViewport); | 6141 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
6181 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 6142 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
6182 webViewImpl->layout(); | 6143 webViewImpl->layout(); |
6183 | 6144 |
6184 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 6145 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
6185 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6146 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
6186 Fullscreen::from(*document).requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest); | 6147 Fullscreen::from(*document).requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest); |
6187 webViewImpl->didEnterFullScreen(); | 6148 webViewImpl->didEnterFullScreen(); |
6188 webViewImpl->layout(); | 6149 webViewImpl->layout(); |
6189 | 6150 |
6190 // Verify that the main frame is still scrollable. | 6151 // Verify that the main frame is still scrollable. |
6191 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | 6152 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
6192 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 6153 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
6193 ASSERT_TRUE(webScrollLayer->scrollable()); | 6154 ASSERT_TRUE(webScrollLayer->scrollable()); |
6194 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | |
6195 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | |
6196 } | 6155 } |
6197 | 6156 |
6198 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) | 6157 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) |
6199 { | 6158 { |
6200 registerMockedHttpURLLoad("percent-height-descendants.html"); | 6159 registerMockedHttpURLLoad("percent-height-descendants.html"); |
6201 FrameTestHelpers::WebViewHelper webViewHelper; | 6160 FrameTestHelpers::WebViewHelper webViewHelper; |
6202 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); | 6161 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); |
6203 | 6162 |
6204 WebView* webView = webViewHelper.webView(); | 6163 WebView* webView = webViewHelper.webView(); |
6205 webView->resize(WebSize(800, 800)); | 6164 webView->resize(WebSize(800, 800)); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6783 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6742 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6784 | 6743 |
6785 // Neither should a page reload. | 6744 // Neither should a page reload. |
6786 localFrame->reload(); | 6745 localFrame->reload(); |
6787 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6746 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6788 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6747 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6789 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6748 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6790 } | 6749 } |
6791 | 6750 |
6792 } // namespace | 6751 } // namespace |
OLD | NEW |