Chromium Code Reviews| 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" | |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 #define EXPECT_EQ_POINT(a, b) \ | 145 #define EXPECT_EQ_POINT(a, b) \ |
| 145 EXPECT_EQ(a.x(), b.x()); \ | 146 EXPECT_EQ(a.x(), b.x()); \ |
| 146 EXPECT_EQ(a.y(), b.y()); | 147 EXPECT_EQ(a.y(), b.y()); |
| 147 | 148 |
| 148 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient { | |
| 149 public: | |
| 150 virtual bool enterFullScreen() override { return true; } | |
| 151 }; | |
| 152 | |
| 153 class WebFrameTest : public testing::Test { | 149 class WebFrameTest : public testing::Test { |
| 154 protected: | 150 protected: |
| 155 WebFrameTest() | 151 WebFrameTest() |
| 156 : m_baseURL("http://www.test.com/") | 152 : m_baseURL("http://www.test.com/") |
| 157 , m_notBaseURL("http://www.nottest.com/") | 153 , m_notBaseURL("http://www.nottest.com/") |
| 158 , m_chromeURL("chrome://") | 154 , m_chromeURL("chrome://") |
| 159 { | 155 { |
| 160 } | 156 } |
| 161 | 157 |
| 162 virtual ~WebFrameTest() | 158 virtual ~WebFrameTest() |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 runPendingTasks(); | 694 runPendingTasks(); |
| 699 } | 695 } |
| 700 | 696 |
| 701 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient { | 697 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 702 public: | 698 public: |
| 703 virtual WebScreenInfo screenInfo() override { return m_screenInfo; } | 699 virtual WebScreenInfo screenInfo() override { return m_screenInfo; } |
| 704 | 700 |
| 705 WebScreenInfo m_screenInfo; | 701 WebScreenInfo m_screenInfo; |
| 706 }; | 702 }; |
| 707 | 703 |
| 704 class FakeCompositingWebViewClient : public FixedLayoutTestWebViewClient { | |
| 705 public: | |
| 706 virtual bool enterFullScreen() override { return true; } | |
| 707 }; | |
| 708 | |
| 708 // Viewport settings need to be set before the page gets loaded | 709 // Viewport settings need to be set before the page gets loaded |
| 709 static void enableViewportSettings(WebSettings* settings) | 710 static void enableViewportSettings(WebSettings* settings) |
| 710 { | 711 { |
| 711 settings->setViewportMetaEnabled(true); | 712 settings->setViewportMetaEnabled(true); |
| 712 settings->setViewportEnabled(true); | 713 settings->setViewportEnabled(true); |
| 713 settings->setMainFrameResizesAreOrientationChanges(true); | 714 settings->setMainFrameResizesAreOrientationChanges(true); |
| 714 settings->setShrinksViewportContentToFit(true); | 715 settings->setShrinksViewportContentToFit(true); |
| 715 } | 716 } |
| 716 | 717 |
| 717 // Helper function to check or set text autosizing multipliers on a document. | 718 // Helper function to check or set text autosizing multipliers on a document. |
| (...skipping 5377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6095 // it should clamp such that we don't show anything outside bounds. | 6096 // it should clamp such that we don't show anything outside bounds. |
| 6096 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); | 6097 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); |
| 6097 EXPECT_EQ_POINT(IntPoint(50, 50), frameView->maximumScrollPosition()); | 6098 EXPECT_EQ_POINT(IntPoint(50, 50), frameView->maximumScrollPosition()); |
| 6098 | 6099 |
| 6099 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); | 6100 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); |
| 6100 EXPECT_EQ_POINT(IntPoint(50, 51), frameView->maximumScrollPosition()); | 6101 EXPECT_EQ_POINT(IntPoint(50, 51), frameView->maximumScrollPosition()); |
| 6101 | 6102 |
| 6102 | 6103 |
| 6103 } | 6104 } |
| 6104 | 6105 |
| 6106 TEST_F(WebFrameTest, FullscreenLayerSize) | |
| 6107 { | |
| 6108 FakeCompositingWebViewClient client; | |
| 6109 registerMockedHttpURLLoad("fullscreen_div.html"); | |
| 6110 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 6111 int viewportWidth = 640; | |
| 6112 int viewportHeight = 480; | |
| 6113 client.m_screenInfo.rect.width = viewportWidth; | |
| 6114 client.m_screenInfo.rect.height = viewportHeight; | |
| 6115 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport); | |
| 6116 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | |
| 6117 webViewImpl->layout(); | |
| 6118 | |
| 6119 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); | |
| 6120 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | |
| 6121 Element* divFullscreen = document->getElementById("div1"); | |
| 6122 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); | |
| 6123 webViewImpl->didEnterFullScreen(); | |
| 6124 webViewImpl->layout(); | |
| 6125 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | |
| 6126 | |
| 6127 // Verify that the element is sized to the viewport. | |
| 6128 RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScree nRenderer(); | |
| 6129 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt()); | |
| 6130 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt()); | |
| 6131 | |
| 6132 // Verify it's updated after a device rotation. | |
| 6133 client.m_screenInfo.rect.width = viewportHeight; | |
| 6134 client.m_screenInfo.rect.height = viewportWidth; | |
| 6135 webViewImpl->resize(WebSize(viewportHeight, viewportWidth)); | |
| 6136 webViewImpl->layout(); | |
| 6137 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt()); | |
| 6138 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt()); | |
| 6139 | |
| 6140 } | |
| 6141 | |
| 6105 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) | 6142 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
| 6106 { | 6143 { |
| 6107 FakeCompositingWebViewClient client; | 6144 FakeCompositingWebViewClient client; |
| 6108 registerMockedHttpURLLoad("fullscreen_div.html"); | 6145 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 6109 FrameTestHelpers::WebViewHelper webViewHelper; | 6146 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6110 int viewportWidth = 640; | 6147 int viewportWidth = 640; |
| 6111 int viewportHeight = 480; | 6148 int viewportHeight = 480; |
| 6112 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView); | 6149 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport); |
|
bokan
2014/10/09 02:19:18
Do you think it's worth keeping a copy of these te
aelias_OOO_until_Jul13
2014/10/09 03:56:24
I don't think we should, as we're going to turn on
| |
| 6113 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 6150 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 6114 webViewImpl->layout(); | 6151 webViewImpl->layout(); |
| 6115 | 6152 |
| 6116 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); | 6153 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); |
| 6117 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6154 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| 6118 Element* divFullscreen = document->getElementById("div1"); | 6155 Element* divFullscreen = document->getElementById("div1"); |
| 6119 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); | 6156 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); |
| 6120 webViewImpl->didEnterFullScreen(); | 6157 webViewImpl->didEnterFullScreen(); |
| 6121 webViewImpl->layout(); | 6158 webViewImpl->layout(); |
| 6122 | 6159 |
| 6123 // Verify that the main frame bounds are empty. | 6160 // Verify that the main frame is nonscrollable. |
| 6124 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | 6161 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| 6125 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); | 6162 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); |
| 6126 ASSERT_EQ(WebSize(), webScrollLayer->bounds()); | 6163 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
| 6164 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | |
| 6127 | 6165 |
| 6128 // Verify that the main frame is scrollable upon exiting fullscreen. | 6166 // Verify that the main frame is scrollable upon exiting fullscreen. |
| 6129 webViewImpl->didExitFullScreen(); | 6167 webViewImpl->didExitFullScreen(); |
| 6130 webViewImpl->layout(); | 6168 webViewImpl->layout(); |
| 6131 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); | 6169 ASSERT_FALSE(Fullscreen::isFullScreen(*document)); |
| 6132 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); | 6170 webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
| 6133 ASSERT_NE(WebSize(), webScrollLayer->bounds()); | 6171 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
| 6172 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | |
| 6134 } | 6173 } |
| 6135 | 6174 |
| 6136 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) | 6175 TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
| 6137 { | 6176 { |
| 6138 FakeCompositingWebViewClient client; | 6177 FakeCompositingWebViewClient client; |
| 6139 registerMockedHttpURLLoad("fullscreen_div.html"); | 6178 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 6140 FrameTestHelpers::WebViewHelper webViewHelper; | 6179 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6141 int viewportWidth = 640; | 6180 int viewportWidth = 640; |
| 6142 int viewportHeight = 480; | 6181 int viewportHeight = 480; |
| 6143 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView); | 6182 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport); |
| 6144 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 6183 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 6145 webViewImpl->layout(); | 6184 webViewImpl->layout(); |
| 6146 | 6185 |
| 6147 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); | 6186 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); |
| 6148 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6187 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| 6149 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest); | 6188 Fullscreen::from(*document).requestFullscreen(*document->documentElement(), Fullscreen::PrefixedRequest); |
| 6150 webViewImpl->didEnterFullScreen(); | 6189 webViewImpl->didEnterFullScreen(); |
| 6151 webViewImpl->layout(); | 6190 webViewImpl->layout(); |
| 6152 | 6191 |
| 6153 // Verify that the main frame is still scrollable. | 6192 // Verify that the main frame is still scrollable. |
| 6154 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | 6193 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| 6155 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); | 6194 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor mLayer(); |
| 6156 ASSERT_TRUE(webScrollLayer->scrollable()); | 6195 ASSERT_TRUE(webScrollLayer->scrollable()); |
| 6196 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | |
| 6197 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | |
| 6157 } | 6198 } |
| 6158 | 6199 |
| 6159 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) | 6200 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) |
| 6160 { | 6201 { |
| 6161 registerMockedHttpURLLoad("percent-height-descendants.html"); | 6202 registerMockedHttpURLLoad("percent-height-descendants.html"); |
| 6162 FrameTestHelpers::WebViewHelper webViewHelper; | 6203 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6163 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html "); | 6204 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html "); |
| 6164 | 6205 |
| 6165 WebView* webView = webViewHelper.webView(); | 6206 WebView* webView = webViewHelper.webView(); |
| 6166 webView->resize(WebSize(800, 800)); | 6207 webView->resize(WebSize(800, 800)); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6709 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6750 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 6710 | 6751 |
| 6711 // Neither should a page reload. | 6752 // Neither should a page reload. |
| 6712 localFrame->reload(); | 6753 localFrame->reload(); |
| 6713 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6754 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
| 6714 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6755 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 6715 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6756 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 6716 } | 6757 } |
| 6717 | 6758 |
| 6718 } // namespace | 6759 } // namespace |
| OLD | NEW |