| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/dom/DocumentMarkerController.h" | 43 #include "core/dom/DocumentMarkerController.h" |
| 44 #include "core/dom/Fullscreen.h" | 44 #include "core/dom/Fullscreen.h" |
| 45 #include "core/dom/NodeRenderStyle.h" | 45 #include "core/dom/NodeRenderStyle.h" |
| 46 #include "core/dom/Range.h" | 46 #include "core/dom/Range.h" |
| 47 #include "core/editing/Editor.h" | 47 #include "core/editing/Editor.h" |
| 48 #include "core/editing/FrameSelection.h" | 48 #include "core/editing/FrameSelection.h" |
| 49 #include "core/editing/SpellChecker.h" | 49 #include "core/editing/SpellChecker.h" |
| 50 #include "core/editing/VisiblePosition.h" | 50 #include "core/editing/VisiblePosition.h" |
| 51 #include "core/events/MouseEvent.h" | 51 #include "core/events/MouseEvent.h" |
| 52 #include "core/fetch/MemoryCache.h" | 52 #include "core/fetch/MemoryCache.h" |
| 53 #include "core/frame/FrameHost.h" |
| 53 #include "core/frame/FrameView.h" | 54 #include "core/frame/FrameView.h" |
| 54 #include "core/frame/LocalFrame.h" | 55 #include "core/frame/LocalFrame.h" |
| 56 #include "core/frame/PinchViewport.h" |
| 55 #include "core/frame/Settings.h" | 57 #include "core/frame/Settings.h" |
| 56 #include "core/html/HTMLDocument.h" | 58 #include "core/html/HTMLDocument.h" |
| 57 #include "core/html/HTMLFormElement.h" | 59 #include "core/html/HTMLFormElement.h" |
| 58 #include "core/loader/DocumentThreadableLoader.h" | 60 #include "core/loader/DocumentThreadableLoader.h" |
| 59 #include "core/loader/DocumentThreadableLoaderClient.h" | 61 #include "core/loader/DocumentThreadableLoaderClient.h" |
| 60 #include "core/loader/FrameLoadRequest.h" | 62 #include "core/loader/FrameLoadRequest.h" |
| 61 #include "core/loader/ThreadableLoader.h" | 63 #include "core/loader/ThreadableLoader.h" |
| 62 #include "core/page/EventHandler.h" | 64 #include "core/page/EventHandler.h" |
| 63 #include "core/page/Page.h" | 65 #include "core/page/Page.h" |
| 64 #include "core/rendering/HitTestResult.h" | 66 #include "core/rendering/HitTestResult.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 #include <v8.h> | 112 #include <v8.h> |
| 111 | 113 |
| 112 namespace { | 114 namespace { |
| 113 | 115 |
| 114 using blink::URLTestHelpers::toKURL; | 116 using blink::URLTestHelpers::toKURL; |
| 115 using blink::FrameTestHelpers::runPendingTasks; | 117 using blink::FrameTestHelpers::runPendingTasks; |
| 116 using namespace blink; | 118 using namespace blink; |
| 117 | 119 |
| 118 const int touchPointPadding = 32; | 120 const int touchPointPadding = 32; |
| 119 | 121 |
| 120 #define EXPECT_EQ_RECT(a, b) \ | 122 #define EXPECT_RECT_EQ(a, b) \ |
| 121 EXPECT_EQ(a.x(), b.x()); \ | 123 do { \ |
| 122 EXPECT_EQ(a.y(), b.y()); \ | 124 EXPECT_EQ(a.x(), b.x()); \ |
| 123 EXPECT_EQ(a.width(), b.width()); \ | 125 EXPECT_EQ(a.y(), b.y()); \ |
| 124 EXPECT_EQ(a.height(), b.height()); | 126 EXPECT_EQ(a.width(), b.width()); \ |
| 127 EXPECT_EQ(a.height(), b.height()); \ |
| 128 } while (false) |
| 129 |
| 130 #define EXPECT_POINT_EQ(expected, actual) \ |
| 131 do { \ |
| 132 EXPECT_EQ((expected).x(), (actual).x()); \ |
| 133 EXPECT_EQ((expected).y(), (actual).y()); \ |
| 134 } while (false) |
| 135 |
| 136 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ |
| 137 do { \ |
| 138 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
| 139 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
| 140 } while (false) |
| 125 | 141 |
| 126 #define EXPECT_EQ_POINT(a, b) \ | 142 #define EXPECT_EQ_POINT(a, b) \ |
| 127 EXPECT_EQ(a.x(), b.x()); \ | 143 EXPECT_EQ(a.x(), b.x()); \ |
| 128 EXPECT_EQ(a.y(), b.y()); | 144 EXPECT_EQ(a.y(), b.y()); |
| 129 | 145 |
| 130 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 146 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
| 131 public: | 147 public: |
| 132 virtual bool enterFullScreen() OVERRIDE { return true; } | 148 virtual bool enterFullScreen() OVERRIDE { return true; } |
| 133 }; | 149 }; |
| 134 | 150 |
| (...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 webViewHelper.webView()->setPageScaleFactor(0.5); | 2211 webViewHelper.webView()->setPageScaleFactor(0.5); |
| 2196 | 2212 |
| 2197 SkBitmap bitmap; | 2213 SkBitmap bitmap; |
| 2198 bitmap.allocN32Pixels(200, 200); | 2214 bitmap.allocN32Pixels(200, 200); |
| 2199 bitmap.eraseColor(0); | 2215 bitmap.eraseColor(0); |
| 2200 SkCanvas canvas(bitmap); | 2216 SkCanvas canvas(bitmap); |
| 2201 | 2217 |
| 2202 GraphicsContext context(&canvas); | 2218 GraphicsContext context(&canvas); |
| 2203 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); | 2219 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
| 2204 | 2220 |
| 2205 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); | 2221 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); |
| 2206 | 2222 |
| 2207 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); | 2223 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
| 2208 IntRect paintRect(0, 0, 200, 200); | 2224 IntRect paintRect(0, 0, 200, 200); |
| 2209 view->paint(&context, paintRect); | 2225 view->paint(&context, paintRect); |
| 2210 | 2226 |
| 2211 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient | 2227 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient |
| 2212 // to return a non-null layerTreeView, which is what all our shipping config
urations do, | 2228 // to return a non-null layerTreeView, which is what all our shipping config
urations do, |
| 2213 // so this is just exposing an existing bug. | 2229 // so this is just exposing an existing bug. |
| 2214 // crbug.com/365812 | 2230 // crbug.com/365812 |
| 2215 #ifndef NDEBUG | 2231 #ifndef NDEBUG |
| 2216 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); | 2232 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); |
| 2217 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); | 2233 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); |
| 2218 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); | 2234 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); |
| 2219 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); | 2235 EXPECT_RECT_EQ(clippedRect, context.opaqueRegion().asRect()); |
| 2220 #endif | 2236 #endif |
| 2221 } | 2237 } |
| 2222 | 2238 |
| 2223 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) | 2239 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) |
| 2224 { | 2240 { |
| 2225 UseMockScrollbarSettings mockScrollbarSettings; | 2241 UseMockScrollbarSettings mockScrollbarSettings; |
| 2226 registerMockedHttpURLLoad("fixed_layout.html"); | 2242 registerMockedHttpURLLoad("fixed_layout.html"); |
| 2227 | 2243 |
| 2228 FixedLayoutTestWebViewClient client; | 2244 FixedLayoutTestWebViewClient client; |
| 2229 client.m_screenInfo.deviceScaleFactor = 1; | 2245 client.m_screenInfo.deviceScaleFactor = 1; |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4206 | 4222 |
| 4207 frame = webViewHelper.webView()->mainFrame(); | 4223 frame = webViewHelper.webView()->mainFrame(); |
| 4208 frame->executeCommand(WebString::fromUTF8("Unselect")); | 4224 frame->executeCommand(WebString::fromUTF8("Unselect")); |
| 4209 webViewHelper.webView()->layout(); | 4225 webViewHelper.webView()->layout(); |
| 4210 ASSERT_FALSE(frame->hasSelection()); | 4226 ASSERT_FALSE(frame->hasSelection()); |
| 4211 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | 4227 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); |
| 4212 } | 4228 } |
| 4213 | 4229 |
| 4214 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie
wClient { | 4230 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie
wClient { |
| 4215 public: | 4231 public: |
| 4216 virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<W
ebRect>& targetRects) OVERRIDE | 4232 virtual bool didTapMultipleTargets(const WebSize&, const WebRect&, const Web
Vector<WebRect>& targetRects) OVERRIDE |
| 4217 { | 4233 { |
| 4218 EXPECT_GE(targetRects.size(), 2u); | 4234 EXPECT_GE(targetRects.size(), 2u); |
| 4219 m_triggered = true; | 4235 m_triggered = true; |
| 4220 return true; | 4236 return true; |
| 4221 } | 4237 } |
| 4222 | 4238 |
| 4223 bool triggered() const { return m_triggered; } | 4239 bool triggered() const { return m_triggered; } |
| 4224 void resetTriggered() { m_triggered = false; } | 4240 void resetTriggered() { m_triggered = false; } |
| 4225 bool m_triggered; | 4241 bool m_triggered; |
| 4226 }; | 4242 }; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 EXPECT_FALSE(client.triggered()); | 4380 EXPECT_FALSE(client.triggered()); |
| 4365 } | 4381 } |
| 4366 | 4382 |
| 4367 for (int i = 0; i <= 46; i++) { | 4383 for (int i = 0; i <= 46; i++) { |
| 4368 client.resetTriggered(); | 4384 client.resetTriggered(); |
| 4369 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); | 4385 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); |
| 4370 EXPECT_FALSE(client.triggered()); | 4386 EXPECT_FALSE(client.triggered()); |
| 4371 } | 4387 } |
| 4372 } | 4388 } |
| 4373 | 4389 |
| 4390 static void enableVirtualViewport(WebSettings* settings) |
| 4391 { |
| 4392 settings->setPinchVirtualViewportEnabled(true); |
| 4393 settings->setViewportEnabled(true); |
| 4394 settings->setViewportMetaEnabled(true); |
| 4395 settings->setShrinksViewportContentToFit(true); |
| 4396 } |
| 4397 |
| 4398 TEST_F(WebFrameTest, DisambiguationPopupPinchViewport) |
| 4399 { |
| 4400 UseMockScrollbarSettings mockScrollbarSettings; |
| 4401 const std::string htmlFile = "disambiguation_popup_200_by_800.html"; |
| 4402 registerMockedHttpURLLoad(htmlFile); |
| 4403 |
| 4404 DisambiguationPopupTestWebViewClient client; |
| 4405 |
| 4406 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4407 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client, enab
leVirtualViewport); |
| 4408 |
| 4409 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); |
| 4410 ASSERT_TRUE(webViewImpl); |
| 4411 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); |
| 4412 ASSERT_TRUE(frame); |
| 4413 |
| 4414 webViewHelper.webView()->resize(WebSize(100, 200)); |
| 4415 |
| 4416 // Scroll main frame to the bottom of the document |
| 4417 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 400)); |
| 4418 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); |
| 4419 |
| 4420 webViewImpl->setPageScaleFactor(2.0); |
| 4421 |
| 4422 // Scroll pinch viewport to the top of the main frame. |
| 4423 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); |
| 4424 pinchViewport.setLocation(FloatPoint(0, 0)); |
| 4425 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.location()); |
| 4426 |
| 4427 // Tap at the top: there is nothing there. |
| 4428 client.resetTriggered(); |
| 4429 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); |
| 4430 EXPECT_FALSE(client.triggered()); |
| 4431 |
| 4432 // Scroll pinch viewport to the bottom of the main frame. |
| 4433 pinchViewport.setLocation(FloatPoint(0, 200)); |
| 4434 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 200), pinchViewport.location()); |
| 4435 |
| 4436 // Now the tap with the same coordinates should hit two elements. |
| 4437 client.resetTriggered(); |
| 4438 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); |
| 4439 EXPECT_TRUE(client.triggered()); |
| 4440 } |
| 4441 |
| 4374 TEST_F(WebFrameTest, DisambiguationPopupBlacklist) | 4442 TEST_F(WebFrameTest, DisambiguationPopupBlacklist) |
| 4375 { | 4443 { |
| 4376 const unsigned viewportWidth = 500; | 4444 const unsigned viewportWidth = 500; |
| 4377 const unsigned viewportHeight = 1000; | 4445 const unsigned viewportHeight = 1000; |
| 4378 const unsigned divHeight = 100; | 4446 const unsigned divHeight = 100; |
| 4379 const std::string htmlFile = "disambiguation_popup_blacklist.html"; | 4447 const std::string htmlFile = "disambiguation_popup_blacklist.html"; |
| 4380 registerMockedHttpURLLoad(htmlFile); | 4448 registerMockedHttpURLLoad(htmlFile); |
| 4381 | 4449 |
| 4382 DisambiguationPopupTestWebViewClient client; | 4450 DisambiguationPopupTestWebViewClient client; |
| 4383 | 4451 |
| (...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5796 EXPECT_EQ(200, leftRightFixed->offsetWidth()); | 5864 EXPECT_EQ(200, leftRightFixed->offsetWidth()); |
| 5797 } | 5865 } |
| 5798 | 5866 |
| 5799 TEST_F(WebFrameTest, FrameViewSetFrameRect) | 5867 TEST_F(WebFrameTest, FrameViewSetFrameRect) |
| 5800 { | 5868 { |
| 5801 FrameTestHelpers::WebViewHelper webViewHelper; | 5869 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5802 webViewHelper.initializeAndLoad("about:blank"); | 5870 webViewHelper.initializeAndLoad("about:blank"); |
| 5803 | 5871 |
| 5804 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 5872 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
| 5805 frameView->setFrameRect(IntRect(0, 0, 200, 200)); | 5873 frameView->setFrameRect(IntRect(0, 0, 200, 200)); |
| 5806 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect()); | 5874 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); |
| 5807 frameView->setFrameRect(IntRect(100, 100, 200, 200)); | 5875 frameView->setFrameRect(IntRect(100, 100, 200, 200)); |
| 5808 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect()); | 5876 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); |
| 5809 } | 5877 } |
| 5810 | 5878 |
| 5811 // FIXME(bokan) Renable once Chromium-side of patch lands | 5879 // FIXME(bokan) Renable once Chromium-side of patch lands |
| 5812 TEST_F(WebFrameTest, DISABLED_FrameViewScrollAccountsForTopControls) | 5880 TEST_F(WebFrameTest, DISABLED_FrameViewScrollAccountsForTopControls) |
| 5813 { | 5881 { |
| 5814 FrameTestHelpers::WebViewHelper webViewHelper; | 5882 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5815 webViewHelper.initializeAndLoad("about:blank"); | 5883 webViewHelper.initializeAndLoad("about:blank"); |
| 5816 | 5884 |
| 5817 WebViewImpl* webView = webViewHelper.webViewImpl(); | 5885 WebViewImpl* webView = webViewHelper.webViewImpl(); |
| 5818 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 5886 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6412 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6480 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 6413 | 6481 |
| 6414 // Neither should a page reload. | 6482 // Neither should a page reload. |
| 6415 localFrame->reload(); | 6483 localFrame->reload(); |
| 6416 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6484 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
| 6417 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6485 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 6418 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6486 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 6419 } | 6487 } |
| 6420 | 6488 |
| 6421 } // namespace | 6489 } // namespace |
| OLD | NEW |