OLD | NEW |
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 webView->setBaseBackgroundColor(kTranslucentPutty); | 256 webView->setBaseBackgroundColor(kTranslucentPutty); |
257 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. | 257 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. |
258 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); | 258 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); |
259 | 259 |
260 webView->setBaseBackgroundColor(kTransparent); | 260 webView->setBaseBackgroundColor(kTransparent); |
261 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:transparent}</style></head></html>", baseURL); | 261 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:transparent}</style></head></html>", baseURL); |
262 // Expected: transparent on top of kTransparent will still be transparent. | 262 // Expected: transparent on top of kTransparent will still be transparent. |
263 EXPECT_EQ(kTransparent, webView->backgroundColor()); | 263 EXPECT_EQ(kTransparent, webView->backgroundColor()); |
264 | 264 |
265 WebCore::LocalFrame* frame = webView->mainFrameImpl()->frame(); | 265 blink::LocalFrame* frame = webView->mainFrameImpl()->frame(); |
266 | 266 |
267 // Creating a new frame view with the background color having 0 alpha. | 267 // Creating a new frame view with the background color having 0 alpha. |
268 frame->createView(WebCore::IntSize(1024, 768), WebCore::Color::transparent,
true); | 268 frame->createView(blink::IntSize(1024, 768), blink::Color::transparent, true
); |
269 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); | 269 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); |
270 | 270 |
271 WebCore::Color kTransparentRed(100, 0, 0, 0); | 271 blink::Color kTransparentRed(100, 0, 0, 0); |
272 frame->createView(WebCore::IntSize(1024, 768), kTransparentRed, true); | 272 frame->createView(blink::IntSize(1024, 768), kTransparentRed, true); |
273 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); | 273 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); |
274 } | 274 } |
275 | 275 |
276 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) | 276 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
277 { | 277 { |
278 const WebColor kBlue = 0xFF0000FF; | 278 const WebColor kBlue = 0xFF0000FF; |
279 WebView* webView = WebViewImpl::create(0); | 279 WebView* webView = WebViewImpl::create(0); |
280 EXPECT_NE(kBlue, webView->backgroundColor()); | 280 EXPECT_NE(kBlue, webView->backgroundColor()); |
281 // webView does not have a frame yet, but we should still be able to set the
background color. | 281 // webView does not have a frame yet, but we should still be able to set the
background color. |
282 webView->setBaseBackgroundColor(kBlue); | 282 webView->setBaseBackgroundColor(kBlue); |
(...skipping 16 matching lines...) Expand all Loading... |
299 webView->settings()->setShouldClearDocumentBackground(false); | 299 webView->settings()->setShouldClearDocumentBackground(false); |
300 webView->resize(WebSize(kWidth, kHeight)); | 300 webView->resize(WebSize(kWidth, kHeight)); |
301 webView->layout(); | 301 webView->layout(); |
302 | 302 |
303 // Set canvas background to red with alpha. | 303 // Set canvas background to red with alpha. |
304 SkBitmap bitmap; | 304 SkBitmap bitmap; |
305 ASSERT_TRUE(bitmap.allocN32Pixels(kWidth, kHeight)); | 305 ASSERT_TRUE(bitmap.allocN32Pixels(kWidth, kHeight)); |
306 SkCanvas canvas(bitmap); | 306 SkCanvas canvas(bitmap); |
307 canvas.clear(kAlphaRed); | 307 canvas.clear(kAlphaRed); |
308 | 308 |
309 WebCore::GraphicsContext context(&canvas); | 309 blink::GraphicsContext context(&canvas); |
310 | 310 |
311 // Paint the root of the main frame in the way that CompositedLayerMapping w
ould. | 311 // Paint the root of the main frame in the way that CompositedLayerMapping w
ould. |
312 WebCore::FrameView* view = m_webViewHelper.webViewImpl()->mainFrameImpl()->f
rameView(); | 312 blink::FrameView* view = m_webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView(); |
313 WebCore::RenderLayer* rootLayer = view->renderView()->layer(); | 313 blink::RenderLayer* rootLayer = view->renderView()->layer(); |
314 WebCore::IntRect paintRect(0, 0, kWidth, kHeight); | 314 blink::IntRect paintRect(0, 0, kWidth, kHeight); |
315 WebCore::LayerPaintingInfo paintingInfo(rootLayer, paintRect, WebCore::Paint
BehaviorNormal, WebCore::LayoutSize()); | 315 blink::LayerPaintingInfo paintingInfo(rootLayer, paintRect, blink::PaintBeha
viorNormal, blink::LayoutSize()); |
316 rootLayer->paintLayerContents(&context, paintingInfo, WebCore::PaintLayerPai
ntingCompositingAllPhases); | 316 rootLayer->paintLayerContents(&context, paintingInfo, blink::PaintLayerPaint
ingCompositingAllPhases); |
317 | 317 |
318 // The result should be a blend of red and green. | 318 // The result should be a blend of red and green. |
319 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); | 319 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); |
320 EXPECT_TRUE(WebCore::redChannel(color)); | 320 EXPECT_TRUE(blink::redChannel(color)); |
321 EXPECT_TRUE(WebCore::greenChannel(color)); | 321 EXPECT_TRUE(blink::greenChannel(color)); |
322 } | 322 } |
323 | 323 |
324 TEST_F(WebViewTest, FocusIsInactive) | 324 TEST_F(WebViewTest, FocusIsInactive) |
325 { | 325 { |
326 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "visible_iframe.html"); | 326 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "visible_iframe.html"); |
327 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if
rame.html"); | 327 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if
rame.html"); |
328 | 328 |
329 webView->setFocus(true); | 329 webView->setFocus(true); |
330 webView->setIsActive(true); | 330 webView->setIsActive(true); |
331 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 331 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
332 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 332 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
333 | 333 |
334 WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
cument()); | 334 blink::HTMLDocument* document = blink::toHTMLDocument(frame->frame()->docume
nt()); |
335 EXPECT_TRUE(document->hasFocus()); | 335 EXPECT_TRUE(document->hasFocus()); |
336 webView->setFocus(false); | 336 webView->setFocus(false); |
337 webView->setIsActive(false); | 337 webView->setIsActive(false); |
338 EXPECT_FALSE(document->hasFocus()); | 338 EXPECT_FALSE(document->hasFocus()); |
339 webView->setFocus(true); | 339 webView->setFocus(true); |
340 webView->setIsActive(true); | 340 webView->setIsActive(true); |
341 EXPECT_TRUE(document->hasFocus()); | 341 EXPECT_TRUE(document->hasFocus()); |
342 webView->setFocus(true); | 342 webView->setFocus(true); |
343 webView->setIsActive(false); | 343 webView->setIsActive(false); |
344 EXPECT_FALSE(document->hasFocus()); | 344 EXPECT_FALSE(document->hasFocus()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 int expectedWidth, int expectedHeight, | 391 int expectedWidth, int expectedHeight, |
392 HorizontalScrollbarState expectedHorizontalStat
e, VerticalScrollbarState expectedVerticalState) | 392 HorizontalScrollbarState expectedHorizontalStat
e, VerticalScrollbarState expectedVerticalState) |
393 { | 393 { |
394 AutoResizeWebViewClient client; | 394 AutoResizeWebViewClient client; |
395 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageH
eight; | 395 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageH
eight; |
396 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); | 396 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); |
397 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); | 397 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); |
398 client.testData().setWebView(webView); | 398 client.testData().setWebView(webView); |
399 | 399 |
400 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 400 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
401 WebCore::FrameView* frameView = frame->frame()->view(); | 401 blink::FrameView* frameView = frame->frame()->view(); |
402 frameView->layout(); | 402 frameView->layout(); |
403 EXPECT_FALSE(frameView->layoutPending()); | 403 EXPECT_FALSE(frameView->layoutPending()); |
404 EXPECT_FALSE(frameView->needsLayout()); | 404 EXPECT_FALSE(frameView->needsLayout()); |
405 | 405 |
406 webView->enableAutoResizeMode(minAutoResize, maxAutoResize); | 406 webView->enableAutoResizeMode(minAutoResize, maxAutoResize); |
407 EXPECT_TRUE(frameView->layoutPending()); | 407 EXPECT_TRUE(frameView->layoutPending()); |
408 EXPECT_TRUE(frameView->needsLayout()); | 408 EXPECT_TRUE(frameView->needsLayout()); |
409 frameView->layout(); | 409 frameView->layout(); |
410 | 410 |
411 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 411 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 webViewImpl->layout(); | 815 webViewImpl->layout(); |
816 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 816 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
817 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 817 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
818 | 818 |
819 // Make the page scale and scroll with the given paremeters. | 819 // Make the page scale and scroll with the given paremeters. |
820 webViewImpl->setPageScaleFactor(2.0f); | 820 webViewImpl->setPageScaleFactor(2.0f); |
821 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); | 821 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); |
822 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 822 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
823 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 823 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
824 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 824 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
825 WebCore::LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->main
Frame()); | 825 blink::LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFr
ame()); |
826 mainFrameLocal->loader().saveScrollState(); | 826 mainFrameLocal->loader().saveScrollState(); |
827 EXPECT_EQ(2.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); | 827 EXPECT_EQ(2.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); |
828 EXPECT_EQ(116, mainFrameLocal->loader().currentItem()->scrollPoint().x()); | 828 EXPECT_EQ(116, mainFrameLocal->loader().currentItem()->scrollPoint().x()); |
829 EXPECT_EQ(84, mainFrameLocal->loader().currentItem()->scrollPoint().y()); | 829 EXPECT_EQ(84, mainFrameLocal->loader().currentItem()->scrollPoint().y()); |
830 | 830 |
831 // Confirm that resetting the page state resets the saved scroll position. | 831 // Confirm that resetting the page state resets the saved scroll position. |
832 // The HistoryController treats a page scale factor of 0.0f as special and a
voids | 832 // The HistoryController treats a page scale factor of 0.0f as special and a
voids |
833 // restoring it to the WebView. | 833 // restoring it to the WebView. |
834 webViewImpl->resetScrollAndScaleState(); | 834 webViewImpl->resetScrollAndScaleState(); |
835 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 835 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
836 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 836 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
837 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 837 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
838 EXPECT_EQ(0.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); | 838 EXPECT_EQ(0.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); |
839 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x()); | 839 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x()); |
840 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y()); | 840 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y()); |
841 } | 841 } |
842 | 842 |
843 TEST_F(WebViewTest, BackForwardRestoreScroll) | 843 TEST_F(WebViewTest, BackForwardRestoreScroll) |
844 { | 844 { |
845 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("back_forward_restore_scroll.html")); | 845 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("back_forward_restore_scroll.html")); |
846 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba
ck_forward_restore_scroll.html"); | 846 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba
ck_forward_restore_scroll.html"); |
847 webViewImpl->resize(WebSize(640, 480)); | 847 webViewImpl->resize(WebSize(640, 480)); |
848 webViewImpl->layout(); | 848 webViewImpl->layout(); |
849 | 849 |
850 // Emulate a user scroll | 850 // Emulate a user scroll |
851 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 900)); | 851 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 900)); |
852 WebCore::LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->main
Frame()); | 852 blink::LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFr
ame()); |
853 RefPtr<WebCore::HistoryItem> item1 = mainFrameLocal->loader().currentItem(); | 853 RefPtr<blink::HistoryItem> item1 = mainFrameLocal->loader().currentItem(); |
854 | 854 |
855 // Click an anchor | 855 // Click an anchor |
856 mainFrameLocal->loader().load(WebCore::FrameLoadRequest(mainFrameLocal->docu
ment(), WebCore::ResourceRequest(mainFrameLocal->document()->completeURL("#a")))
); | 856 mainFrameLocal->loader().load(blink::FrameLoadRequest(mainFrameLocal->docume
nt(), blink::ResourceRequest(mainFrameLocal->document()->completeURL("#a")))); |
857 RefPtr<WebCore::HistoryItem> item2 = mainFrameLocal->loader().currentItem(); | 857 RefPtr<blink::HistoryItem> item2 = mainFrameLocal->loader().currentItem(); |
858 | 858 |
859 // Go back, then forward, then back again. | 859 // Go back, then forward, then back again. |
860 mainFrameLocal->loader().loadHistoryItem(item1.get(), WebCore::HistorySameDo
cumentLoad); | 860 mainFrameLocal->loader().loadHistoryItem(item1.get(), blink::HistorySameDocu
mentLoad); |
861 mainFrameLocal->loader().loadHistoryItem(item2.get(), WebCore::HistorySameDo
cumentLoad); | 861 mainFrameLocal->loader().loadHistoryItem(item2.get(), blink::HistorySameDocu
mentLoad); |
862 mainFrameLocal->loader().loadHistoryItem(item1.get(), WebCore::HistorySameDo
cumentLoad); | 862 mainFrameLocal->loader().loadHistoryItem(item1.get(), blink::HistorySameDocu
mentLoad); |
863 | 863 |
864 // Click a different anchor | 864 // Click a different anchor |
865 mainFrameLocal->loader().load(WebCore::FrameLoadRequest(mainFrameLocal->docu
ment(), WebCore::ResourceRequest(mainFrameLocal->document()->completeURL("#b")))
); | 865 mainFrameLocal->loader().load(blink::FrameLoadRequest(mainFrameLocal->docume
nt(), blink::ResourceRequest(mainFrameLocal->document()->completeURL("#b")))); |
866 RefPtr<WebCore::HistoryItem> item3 = mainFrameLocal->loader().currentItem(); | 866 RefPtr<blink::HistoryItem> item3 = mainFrameLocal->loader().currentItem(); |
867 | 867 |
868 // Go back, then forward. The scroll position should be properly set on the
forward navigation. | 868 // Go back, then forward. The scroll position should be properly set on the
forward navigation. |
869 mainFrameLocal->loader().loadHistoryItem(item1.get(), WebCore::HistorySameDo
cumentLoad); | 869 mainFrameLocal->loader().loadHistoryItem(item1.get(), blink::HistorySameDocu
mentLoad); |
870 mainFrameLocal->loader().loadHistoryItem(item3.get(), WebCore::HistorySameDo
cumentLoad); | 870 mainFrameLocal->loader().loadHistoryItem(item3.get(), blink::HistorySameDocu
mentLoad); |
871 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 871 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
872 EXPECT_GT(webViewImpl->mainFrame()->scrollOffset().height, 2000); | 872 EXPECT_GT(webViewImpl->mainFrame()->scrollOffset().height, 2000); |
873 } | 873 } |
874 | 874 |
875 class EnterFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 875 class EnterFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
876 public: | 876 public: |
877 // WebViewClient methods | 877 // WebViewClient methods |
878 virtual bool enterFullScreen() { return true; } | 878 virtual bool enterFullScreen() { return true; } |
879 virtual void exitFullScreen() { } | 879 virtual void exitFullScreen() { } |
880 }; | 880 }; |
881 | 881 |
882 | 882 |
883 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) | 883 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) |
884 { | 884 { |
885 EnterFullscreenWebViewClient client; | 885 EnterFullscreenWebViewClient client; |
886 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("hello_world.html")); | 886 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("hello_world.html")); |
887 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
llo_world.html", true, 0, &client); | 887 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
llo_world.html", true, 0, &client); |
888 webViewImpl->resize(WebSize(640, 480)); | 888 webViewImpl->resize(WebSize(640, 480)); |
889 webViewImpl->layout(); | 889 webViewImpl->layout(); |
890 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 890 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
891 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 891 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
892 | 892 |
893 // Make the page scale and scroll with the given paremeters. | 893 // Make the page scale and scroll with the given paremeters. |
894 webViewImpl->setPageScaleFactor(2.0f); | 894 webViewImpl->setPageScaleFactor(2.0f); |
895 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); | 895 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); |
896 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 896 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
897 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 897 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
898 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 898 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
899 | 899 |
900 RefPtrWillBeRawPtr<WebCore::Element> element = static_cast<PassRefPtrWillBeR
awPtr<WebCore::Element> >(webViewImpl->mainFrame()->document().body()); | 900 RefPtrWillBeRawPtr<blink::Element> element = static_cast<PassRefPtrWillBeRaw
Ptr<blink::Element> >(webViewImpl->mainFrame()->document().body()); |
901 webViewImpl->enterFullScreenForElement(element.get()); | 901 webViewImpl->enterFullScreenForElement(element.get()); |
902 webViewImpl->willEnterFullScreen(); | 902 webViewImpl->willEnterFullScreen(); |
903 webViewImpl->didEnterFullScreen(); | 903 webViewImpl->didEnterFullScreen(); |
904 | 904 |
905 // Page scale factor must be 1.0 during fullscreen for elements to be sized | 905 // Page scale factor must be 1.0 during fullscreen for elements to be sized |
906 // properly. | 906 // properly. |
907 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 907 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
908 | 908 |
909 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. | 909 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. |
910 RefPtrWillBeRawPtr<WebCore::Element> otherElement = static_cast<PassRefPtrWi
llBeRawPtr<WebCore::Element> >(webViewImpl->mainFrame()->document().head()); | 910 RefPtrWillBeRawPtr<blink::Element> otherElement = static_cast<PassRefPtrWill
BeRawPtr<blink::Element> >(webViewImpl->mainFrame()->document().head()); |
911 webViewImpl->enterFullScreenForElement(otherElement.get()); | 911 webViewImpl->enterFullScreenForElement(otherElement.get()); |
912 | 912 |
913 // Confirm that exiting fullscreen restores the parameters. | 913 // Confirm that exiting fullscreen restores the parameters. |
914 webViewImpl->willExitFullScreen(); | 914 webViewImpl->willExitFullScreen(); |
915 webViewImpl->didExitFullScreen(); | 915 webViewImpl->didExitFullScreen(); |
916 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 916 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
917 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 917 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
918 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 918 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
919 | 919 |
920 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 920 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
(...skipping 18 matching lines...) Expand all Loading... |
939 bool m_printCalled; | 939 bool m_printCalled; |
940 }; | 940 }; |
941 | 941 |
942 | 942 |
943 TEST_F(WebViewTest, PrintWithXHRInFlight) | 943 TEST_F(WebViewTest, PrintWithXHRInFlight) |
944 { | 944 { |
945 PrintWebViewClient client; | 945 PrintWebViewClient client; |
946 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("print_with_xhr_inflight.html")); | 946 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("print_with_xhr_inflight.html")); |
947 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr
int_with_xhr_inflight.html", true, 0, &client); | 947 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr
int_with_xhr_inflight.html", true, 0, &client); |
948 | 948 |
949 ASSERT_EQ(WebCore::FrameStateComplete, toLocalFrame(webViewImpl->page()->mai
nFrame())->loader().state()); | 949 ASSERT_EQ(blink::FrameStateComplete, toLocalFrame(webViewImpl->page()->mainF
rame())->loader().state()); |
950 EXPECT_TRUE(client.printCalled()); | 950 EXPECT_TRUE(client.printCalled()); |
951 m_webViewHelper.reset(); | 951 m_webViewHelper.reset(); |
952 } | 952 } |
953 | 953 |
954 class DropTask : public WebThread::Task { | 954 class DropTask : public WebThread::Task { |
955 public: | 955 public: |
956 explicit DropTask(WebView* webView) : m_webView(webView) | 956 explicit DropTask(WebView* webView) : m_webView(webView) |
957 { | 957 { |
958 } | 958 } |
959 | 959 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 private: | 1049 private: |
1050 bool m_contentDetectionRequested; | 1050 bool m_contentDetectionRequested; |
1051 bool m_pendingIntentsCancelled; | 1051 bool m_pendingIntentsCancelled; |
1052 WebURL m_scheduledIntentURL; | 1052 WebURL m_scheduledIntentURL; |
1053 WebContentDetectionResult m_contentDetectionResult; | 1053 WebContentDetectionResult m_contentDetectionResult; |
1054 }; | 1054 }; |
1055 | 1055 |
1056 static bool tapElementById(WebView* webView, WebInputEvent::Type type, const Web
String& id) | 1056 static bool tapElementById(WebView* webView, WebInputEvent::Type type, const Web
String& id) |
1057 { | 1057 { |
1058 ASSERT(webView); | 1058 ASSERT(webView); |
1059 RefPtrWillBeRawPtr<WebCore::Element> element = static_cast<PassRefPtrWillBeR
awPtr<WebCore::Element> >(webView->mainFrame()->document().getElementById(id)); | 1059 RefPtrWillBeRawPtr<blink::Element> element = static_cast<PassRefPtrWillBeRaw
Ptr<blink::Element> >(webView->mainFrame()->document().getElementById(id)); |
1060 if (!element) | 1060 if (!element) |
1061 return false; | 1061 return false; |
1062 | 1062 |
1063 element->scrollIntoViewIfNeeded(); | 1063 element->scrollIntoViewIfNeeded(); |
1064 WebCore::IntPoint center = element->screenRect().center(); | 1064 blink::IntPoint center = element->screenRect().center(); |
1065 | 1065 |
1066 WebGestureEvent event; | 1066 WebGestureEvent event; |
1067 event.type = type; | 1067 event.type = type; |
1068 event.x = center.x(); | 1068 event.x = center.x(); |
1069 event.y = center.y(); | 1069 event.y = center.y(); |
1070 | 1070 |
1071 webView->handleInputEvent(event); | 1071 webView->handleInputEvent(event); |
1072 runPendingTasks(); | 1072 runPendingTasks(); |
1073 return true; | 1073 return true; |
1074 } | 1074 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 ViewCreatingWebViewClient client; | 1415 ViewCreatingWebViewClient client; |
1416 FrameTestHelpers::WebViewHelper m_webViewHelper; | 1416 FrameTestHelpers::WebViewHelper m_webViewHelper; |
1417 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); | 1417 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); |
1418 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); | 1418 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); |
1419 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | 1419 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); |
1420 frame->setName("_start"); | 1420 frame->setName("_start"); |
1421 | 1421 |
1422 // Make a request that will open a new window | 1422 // Make a request that will open a new window |
1423 WebURLRequest webURLRequest; | 1423 WebURLRequest webURLRequest; |
1424 webURLRequest.initialize(); | 1424 webURLRequest.initialize(); |
1425 WebCore::FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_bl
ank"); | 1425 blink::FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blan
k"); |
1426 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); | 1426 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); |
1427 ASSERT_TRUE(client.createdWebView()); | 1427 ASSERT_TRUE(client.createdWebView()); |
1428 EXPECT_FALSE(client.didFocusCalled()); | 1428 EXPECT_FALSE(client.didFocusCalled()); |
1429 | 1429 |
1430 // Make a request from the new window that will navigate the original window
. The original window should be focused. | 1430 // Make a request from the new window that will navigate the original window
. The original window should be focused. |
1431 WebURLRequest webURLRequestWithTargetStart; | 1431 WebURLRequest webURLRequestWithTargetStart; |
1432 webURLRequestWithTargetStart.initialize(); | 1432 webURLRequestWithTargetStart.initialize(); |
1433 WebCore::FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetS
tart.toResourceRequest(), "_start"); | 1433 blink::FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetSta
rt.toResourceRequest(), "_start"); |
1434 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame())->l
oader().load(requestWithTargetStart); | 1434 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame())->l
oader().load(requestWithTargetStart); |
1435 EXPECT_TRUE(client.didFocusCalled()); | 1435 EXPECT_TRUE(client.didFocusCalled()); |
1436 | 1436 |
1437 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 1437 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
1438 } | 1438 } |
1439 | 1439 |
1440 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) | 1440 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) |
1441 { | 1441 { |
1442 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "focusout_focusin_events.html"); | 1442 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "focusout_focusin_events.html"); |
1443 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_f
ocusin_events.html", true, 0); | 1443 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_f
ocusin_events.html", true, 0); |
(...skipping 13 matching lines...) Expand all Loading... |
1457 | 1457 |
1458 webView->setFocus(true); | 1458 webView->setFocus(true); |
1459 webView->setFocus(false); | 1459 webView->setFocus(false); |
1460 webView->setFocus(true); | 1460 webView->setFocus(true); |
1461 | 1461 |
1462 WebElement element = webView->mainFrame()->document().getElementById("messag
e"); | 1462 WebElement element = webView->mainFrame()->document().getElementById("messag
e"); |
1463 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); | 1463 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); |
1464 } | 1464 } |
1465 | 1465 |
1466 #if !ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 1466 #if !ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
1467 static void openDateTimeChooser(WebView* webView, WebCore::HTMLInputElement* inp
utElement) | 1467 static void openDateTimeChooser(WebView* webView, blink::HTMLInputElement* input
Element) |
1468 { | 1468 { |
1469 inputElement->focus(); | 1469 inputElement->focus(); |
1470 | 1470 |
1471 WebKeyboardEvent keyEvent; | 1471 WebKeyboardEvent keyEvent; |
1472 keyEvent.windowsKeyCode = WebCore::VKEY_SPACE; | 1472 keyEvent.windowsKeyCode = blink::VKEY_SPACE; |
1473 keyEvent.type = WebInputEvent::RawKeyDown; | 1473 keyEvent.type = WebInputEvent::RawKeyDown; |
1474 keyEvent.setKeyIdentifierFromWindowsKeyCode(); | 1474 keyEvent.setKeyIdentifierFromWindowsKeyCode(); |
1475 webView->handleInputEvent(keyEvent); | 1475 webView->handleInputEvent(keyEvent); |
1476 | 1476 |
1477 keyEvent.type = WebInputEvent::KeyUp; | 1477 keyEvent.type = WebInputEvent::KeyUp; |
1478 webView->handleInputEvent(keyEvent); | 1478 webView->handleInputEvent(keyEvent); |
1479 } | 1479 } |
1480 | 1480 |
1481 TEST_F(WebViewTest, ChooseValueFromDateTimeChooser) | 1481 TEST_F(WebViewTest, ChooseValueFromDateTimeChooser) |
1482 { | 1482 { |
1483 DateTimeChooserWebViewClient client; | 1483 DateTimeChooserWebViewClient client; |
1484 std::string url = m_baseURL + "date_time_chooser.html"; | 1484 std::string url = m_baseURL + "date_time_chooser.html"; |
1485 URLTestHelpers::registerMockedURLLoad(toKURL(url), "date_time_chooser.html")
; | 1485 URLTestHelpers::registerMockedURLLoad(toKURL(url), "date_time_chooser.html")
; |
1486 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); | 1486 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); |
1487 | 1487 |
1488 WebCore::Document* document = webViewImpl->mainFrameImpl()->frame()->documen
t(); | 1488 blink::Document* document = webViewImpl->mainFrameImpl()->frame()->document(
); |
1489 | 1489 |
1490 WebCore::HTMLInputElement* inputElement; | 1490 blink::HTMLInputElement* inputElement; |
1491 | 1491 |
1492 inputElement = toHTMLInputElement(document->getElementById("date")); | 1492 inputElement = toHTMLInputElement(document->getElementById("date")); |
1493 openDateTimeChooser(webViewImpl, inputElement); | 1493 openDateTimeChooser(webViewImpl, inputElement); |
1494 client.chooserCompletion()->didChooseValue(0); | 1494 client.chooserCompletion()->didChooseValue(0); |
1495 client.clearChooserCompletion(); | 1495 client.clearChooserCompletion(); |
1496 EXPECT_STREQ("1970-01-01", inputElement->value().utf8().data()); | 1496 EXPECT_STREQ("1970-01-01", inputElement->value().utf8().data()); |
1497 | 1497 |
1498 openDateTimeChooser(webViewImpl, inputElement); | 1498 openDateTimeChooser(webViewImpl, inputElement); |
1499 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie
t_NaN()); | 1499 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie
t_NaN()); |
1500 client.clearChooserCompletion(); | 1500 client.clearChooserCompletion(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); | 1690 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); |
1691 | 1691 |
1692 // The page is initialized with at least one no-handlers call. | 1692 // The page is initialized with at least one no-handlers call. |
1693 // In practice we get two such calls because WebViewHelper::initializeAndLoa
d first | 1693 // In practice we get two such calls because WebViewHelper::initializeAndLoa
d first |
1694 // initializes and empty frame, and then loads a document into it, so there
are two | 1694 // initializes and empty frame, and then loads a document into it, so there
are two |
1695 // FrameLoader::commitProvisionalLoad calls. | 1695 // FrameLoader::commitProvisionalLoad calls. |
1696 EXPECT_GE(client.getAndResetHasTouchEventHandlerCallCount(false), 1); | 1696 EXPECT_GE(client.getAndResetHasTouchEventHandlerCallCount(false), 1); |
1697 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1697 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1698 | 1698 |
1699 // Adding the first document handler results in a has-handlers call. | 1699 // Adding the first document handler results in a has-handlers call. |
1700 WebCore::Document* document = webViewImpl->mainFrameImpl()->frame()->documen
t(); | 1700 blink::Document* document = webViewImpl->mainFrameImpl()->frame()->document(
); |
1701 document->didAddTouchEventHandler(document); | 1701 document->didAddTouchEventHandler(document); |
1702 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1702 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1703 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1703 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1704 | 1704 |
1705 // Adding another handler has no effect. | 1705 // Adding another handler has no effect. |
1706 document->didAddTouchEventHandler(document); | 1706 document->didAddTouchEventHandler(document); |
1707 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1707 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1708 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1708 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1709 | 1709 |
1710 // Removing the duplicate handler has no effect. | 1710 // Removing the duplicate handler has no effect. |
1711 document->didRemoveTouchEventHandler(document); | 1711 document->didRemoveTouchEventHandler(document); |
1712 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1712 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1713 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1713 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1714 | 1714 |
1715 // Removing the final handler results in a no-handlers call. | 1715 // Removing the final handler results in a no-handlers call. |
1716 document->didRemoveTouchEventHandler(document); | 1716 document->didRemoveTouchEventHandler(document); |
1717 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1717 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1718 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1718 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1719 | 1719 |
1720 // Adding a handler on a div results in a has-handlers call. | 1720 // Adding a handler on a div results in a has-handlers call. |
1721 WebCore::Element* parentDiv = document->getElementById("parentdiv"); | 1721 blink::Element* parentDiv = document->getElementById("parentdiv"); |
1722 ASSERT(parentDiv); | 1722 ASSERT(parentDiv); |
1723 document->didAddTouchEventHandler(parentDiv); | 1723 document->didAddTouchEventHandler(parentDiv); |
1724 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1724 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1725 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1725 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1726 | 1726 |
1727 // Adding a duplicate handler on the div, clearing all document handlers | 1727 // Adding a duplicate handler on the div, clearing all document handlers |
1728 // (of which there are none) and removing the extra handler on the div | 1728 // (of which there are none) and removing the extra handler on the div |
1729 // all have no effect. | 1729 // all have no effect. |
1730 document->didAddTouchEventHandler(parentDiv); | 1730 document->didAddTouchEventHandler(parentDiv); |
1731 document->didClearTouchEventHandlers(document); | 1731 document->didClearTouchEventHandlers(document); |
(...skipping 12 matching lines...) Expand all Loading... |
1744 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1744 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1745 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1745 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1746 document->didAddTouchEventHandler(parentDiv); | 1746 document->didAddTouchEventHandler(parentDiv); |
1747 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1747 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1748 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1748 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1749 document->didClearTouchEventHandlers(parentDiv); | 1749 document->didClearTouchEventHandlers(parentDiv); |
1750 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1750 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1751 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1751 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1752 | 1752 |
1753 // Adding a handler inside of a child iframe results in a has-handlers call. | 1753 // Adding a handler inside of a child iframe results in a has-handlers call. |
1754 WebCore::Element* childFrame = document->getElementById("childframe"); | 1754 blink::Element* childFrame = document->getElementById("childframe"); |
1755 ASSERT(childFrame); | 1755 ASSERT(childFrame); |
1756 WebCore::Document* childDocument = toHTMLIFrameElement(childFrame)->contentD
ocument(); | 1756 blink::Document* childDocument = toHTMLIFrameElement(childFrame)->contentDoc
ument(); |
1757 WebCore::Element* childDiv = childDocument->getElementById("childdiv"); | 1757 blink::Element* childDiv = childDocument->getElementById("childdiv"); |
1758 ASSERT(childDiv); | 1758 ASSERT(childDiv); |
1759 childDocument->didAddTouchEventHandler(childDiv); | 1759 childDocument->didAddTouchEventHandler(childDiv); |
1760 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 1760 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
1761 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 1761 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
1762 | 1762 |
1763 // Adding and clearing handlers in the parent doc or elsewhere in the child
doc | 1763 // Adding and clearing handlers in the parent doc or elsewhere in the child
doc |
1764 // has no impact. | 1764 // has no impact. |
1765 document->didAddTouchEventHandler(document); | 1765 document->didAddTouchEventHandler(document); |
1766 document->didAddTouchEventHandler(childFrame); | 1766 document->didAddTouchEventHandler(childFrame); |
1767 childDocument->didAddTouchEventHandler(childDocument); | 1767 childDocument->didAddTouchEventHandler(childDocument); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 // This test checks that deleting nodes which have only non-JS-registered touch | 1802 // This test checks that deleting nodes which have only non-JS-registered touch |
1803 // handlers also removes them from the event handler registry. Note that this | 1803 // handlers also removes them from the event handler registry. Note that this |
1804 // is different from detaching and re-attaching the same node, which is covered | 1804 // is different from detaching and re-attaching the same node, which is covered |
1805 // by layout tests under fast/events/. | 1805 // by layout tests under fast/events/. |
1806 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler) | 1806 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler) |
1807 { | 1807 { |
1808 std::string url = m_baseURL + "simple_div.html"; | 1808 std::string url = m_baseURL + "simple_div.html"; |
1809 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html"); | 1809 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html"); |
1810 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); | 1810 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); |
1811 | 1811 |
1812 RefPtrWillBePersistent<WebCore::Document> document = webViewImpl->mainFrameI
mpl()->frame()->document(); | 1812 RefPtrWillBePersistent<blink::Document> document = webViewImpl->mainFrameImp
l()->frame()->document(); |
1813 WebCore::Element* div = document->getElementById("div"); | 1813 blink::Element* div = document->getElementById("div"); |
1814 WebCore::EventHandlerRegistry& registry = document->frameHost()->eventHandle
rRegistry(); | 1814 blink::EventHandlerRegistry& registry = document->frameHost()->eventHandlerR
egistry(); |
1815 | 1815 |
1816 registry.didAddEventHandler(*div, WebCore::EventHandlerRegistry::ScrollEvent
); | 1816 registry.didAddEventHandler(*div, blink::EventHandlerRegistry::ScrollEvent); |
1817 EXPECT_TRUE(registry.hasEventHandlers(WebCore::EventHandlerRegistry::ScrollE
vent)); | 1817 EXPECT_TRUE(registry.hasEventHandlers(blink::EventHandlerRegistry::ScrollEve
nt)); |
1818 | 1818 |
1819 WebCore::TrackExceptionState exceptionState; | 1819 blink::TrackExceptionState exceptionState; |
1820 div->remove(exceptionState); | 1820 div->remove(exceptionState); |
1821 #if ENABLE(OILPAN) | 1821 #if ENABLE(OILPAN) |
1822 // For oilpan we have to force a GC to ensure the event handlers have been r
emoved when | 1822 // For oilpan we have to force a GC to ensure the event handlers have been r
emoved when |
1823 // checking below. We do a precise GC (collectAllGarbage does not scan the s
tack) | 1823 // checking below. We do a precise GC (collectAllGarbage does not scan the s
tack) |
1824 // to ensure the div element dies. This is also why the Document is in a Per
sistent | 1824 // to ensure the div element dies. This is also why the Document is in a Per
sistent |
1825 // since we want that to stay around. | 1825 // since we want that to stay around. |
1826 Heap::collectAllGarbage(); | 1826 Heap::collectAllGarbage(); |
1827 #endif | 1827 #endif |
1828 EXPECT_FALSE(registry.hasEventHandlers(WebCore::EventHandlerRegistry::Scroll
Event)); | 1828 EXPECT_FALSE(registry.hasEventHandlers(blink::EventHandlerRegistry::ScrollEv
ent)); |
1829 } | 1829 } |
1830 | 1830 |
1831 static WebRect ExpectedRootBounds(WebCore::Document* document, float scaleFactor
) | 1831 static WebRect ExpectedRootBounds(blink::Document* document, float scaleFactor) |
1832 { | 1832 { |
1833 WebCore::Element* element = document->getElementById("root"); | 1833 blink::Element* element = document->getElementById("root"); |
1834 if (!element) | 1834 if (!element) |
1835 element = document->getElementById("target"); | 1835 element = document->getElementById("target"); |
1836 if (element->hasTagName(WebCore::HTMLNames::iframeTag)) | 1836 if (element->hasTagName(blink::HTMLNames::iframeTag)) |
1837 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument(
), scaleFactor); | 1837 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument(
), scaleFactor); |
1838 | 1838 |
1839 WebCore::IntRect boundingBox; | 1839 blink::IntRect boundingBox; |
1840 if (element->hasTagName(WebCore::HTMLNames::htmlTag)) | 1840 if (element->hasTagName(blink::HTMLNames::htmlTag)) |
1841 boundingBox = WebCore::IntRect(WebCore::IntPoint(0, 0), document->frame(
)->view()->contentsSize()); | 1841 boundingBox = blink::IntRect(blink::IntPoint(0, 0), document->frame()->v
iew()->contentsSize()); |
1842 else | 1842 else |
1843 boundingBox = element->pixelSnappedBoundingBox(); | 1843 boundingBox = element->pixelSnappedBoundingBox(); |
1844 boundingBox = document->frame()->view()->contentsToWindow(boundingBox); | 1844 boundingBox = document->frame()->view()->contentsToWindow(boundingBox); |
1845 boundingBox.scale(scaleFactor); | 1845 boundingBox.scale(scaleFactor); |
1846 return boundingBox; | 1846 return boundingBox; |
1847 } | 1847 } |
1848 | 1848 |
1849 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
actor) | 1849 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
actor) |
1850 { | 1850 { |
1851 std::string url = m_baseURL + htmlFile; | 1851 std::string url = m_baseURL + htmlFile; |
1852 | 1852 |
1853 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 1853 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); |
1854 webView->resize(WebSize(640, 480)); | 1854 webView->resize(WebSize(640, 480)); |
1855 webView->setPageScaleFactor(pageScaleFactor); | 1855 webView->setPageScaleFactor(pageScaleFactor); |
1856 webView->layout(); | 1856 webView->layout(); |
1857 runPendingTasks(); | 1857 runPendingTasks(); |
1858 | 1858 |
1859 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1859 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
1860 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 1860 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
1861 WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
cument()); | 1861 blink::HTMLDocument* document = blink::toHTMLDocument(frame->frame()->docume
nt()); |
1862 | 1862 |
1863 WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
Factor()); | 1863 WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
Factor()); |
1864 WebRect actualRootBounds; | 1864 WebRect actualRootBounds; |
1865 webView->getSelectionRootBounds(actualRootBounds); | 1865 webView->getSelectionRootBounds(actualRootBounds); |
1866 ASSERT_EQ(expectedRootBounds, actualRootBounds); | 1866 ASSERT_EQ(expectedRootBounds, actualRootBounds); |
1867 | 1867 |
1868 WebRect anchor, focus; | 1868 WebRect anchor, focus; |
1869 webView->selectionBounds(anchor, focus); | 1869 webView->selectionBounds(anchor, focus); |
1870 WebCore::IntRect expectedIntRect = expectedRootBounds; | 1870 blink::IntRect expectedIntRect = expectedRootBounds; |
1871 ASSERT_TRUE(expectedIntRect.contains(anchor)); | 1871 ASSERT_TRUE(expectedIntRect.contains(anchor)); |
1872 // The "overflow" tests have the focus boundary outside of the element box. | 1872 // The "overflow" tests have the focus boundary outside of the element box. |
1873 ASSERT_EQ(url.find("overflow") == std::string::npos, expectedIntRect.contain
s(focus)); | 1873 ASSERT_EQ(url.find("overflow") == std::string::npos, expectedIntRect.contain
s(focus)); |
1874 } | 1874 } |
1875 | 1875 |
1876 TEST_F(WebViewTest, GetSelectionRootBounds) | 1876 TEST_F(WebViewTest, GetSelectionRootBounds) |
1877 { | 1877 { |
1878 // Register all the pages we will be using. | 1878 // Register all the pages we will be using. |
1879 registerMockedHttpURLLoad("select_range_basic.html"); | 1879 registerMockedHttpURLLoad("select_range_basic.html"); |
1880 registerMockedHttpURLLoad("select_range_div_editable.html"); | 1880 registerMockedHttpURLLoad("select_range_div_editable.html"); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 // called iff value of a focused element is modified via script. | 1969 // called iff value of a focused element is modified via script. |
1970 TEST_F(WebViewTest, NonUserInputTextUpdate) | 1970 TEST_F(WebViewTest, NonUserInputTextUpdate) |
1971 { | 1971 { |
1972 NonUserInputTextUpdateWebViewClient client; | 1972 NonUserInputTextUpdateWebViewClient client; |
1973 std::string url = m_baseURL + "non_user_input_text_update.html"; | 1973 std::string url = m_baseURL + "non_user_input_text_update.html"; |
1974 URLTestHelpers::registerMockedURLLoad(toKURL(url), "non_user_input_text_upda
te.html"); | 1974 URLTestHelpers::registerMockedURLLoad(toKURL(url), "non_user_input_text_upda
te.html"); |
1975 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); | 1975 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); |
1976 webViewImpl->setInitialFocus(false); | 1976 webViewImpl->setInitialFocus(false); |
1977 | 1977 |
1978 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | 1978 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); |
1979 WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
cument()); | 1979 blink::HTMLDocument* document = blink::toHTMLDocument(frame->frame()->docume
nt()); |
1980 | 1980 |
1981 // (A) <input> | 1981 // (A) <input> |
1982 // (A.1) Focused and value is changed by script. | 1982 // (A.1) Focused and value is changed by script. |
1983 client.reset(); | 1983 client.reset(); |
1984 EXPECT_FALSE(client.textIsUpdated()); | 1984 EXPECT_FALSE(client.textIsUpdated()); |
1985 | 1985 |
1986 WebCore::HTMLInputElement* inputElement = toHTMLInputElement(document->getEl
ementById("input")); | 1986 blink::HTMLInputElement* inputElement = toHTMLInputElement(document->getElem
entById("input")); |
1987 document->setFocusedElement(inputElement); | 1987 document->setFocusedElement(inputElement); |
1988 webViewImpl->setFocus(true); | 1988 webViewImpl->setFocus(true); |
1989 EXPECT_EQ(document->focusedElement(), static_cast<WebCore::Element*>(inputEl
ement)); | 1989 EXPECT_EQ(document->focusedElement(), static_cast<blink::Element*>(inputElem
ent)); |
1990 | 1990 |
1991 // Emulate value change from script. | 1991 // Emulate value change from script. |
1992 inputElement->setValue("testA"); | 1992 inputElement->setValue("testA"); |
1993 EXPECT_TRUE(client.textIsUpdated()); | 1993 EXPECT_TRUE(client.textIsUpdated()); |
1994 WebTextInputInfo info = webViewImpl->textInputInfo(); | 1994 WebTextInputInfo info = webViewImpl->textInputInfo(); |
1995 EXPECT_EQ("testA", std::string(info.value.utf8().data())); | 1995 EXPECT_EQ("testA", std::string(info.value.utf8().data())); |
1996 | 1996 |
1997 // (A.2) Focused and user input modifies value. | 1997 // (A.2) Focused and user input modifies value. |
1998 client.reset(); | 1998 client.reset(); |
1999 EXPECT_FALSE(client.textIsUpdated()); | 1999 EXPECT_FALSE(client.textIsUpdated()); |
2000 | 2000 |
2001 WebVector<WebCompositionUnderline> emptyUnderlines; | 2001 WebVector<WebCompositionUnderline> emptyUnderlines; |
2002 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; | 2002 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; |
2003 webViewImpl->confirmComposition(WebWidget::KeepSelection); | 2003 webViewImpl->confirmComposition(WebWidget::KeepSelection); |
2004 EXPECT_FALSE(client.textIsUpdated()); | 2004 EXPECT_FALSE(client.textIsUpdated()); |
2005 info = webViewImpl->textInputInfo(); | 2005 info = webViewImpl->textInputInfo(); |
2006 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); | 2006 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); |
2007 | 2007 |
2008 // (A.3) Unfocused and value is changed by script. | 2008 // (A.3) Unfocused and value is changed by script. |
2009 client.reset(); | 2009 client.reset(); |
2010 EXPECT_FALSE(client.textIsUpdated()); | 2010 EXPECT_FALSE(client.textIsUpdated()); |
2011 document->setFocusedElement(nullptr); | 2011 document->setFocusedElement(nullptr); |
2012 webViewImpl->setFocus(false); | 2012 webViewImpl->setFocus(false); |
2013 EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(inputEl
ement)); | 2013 EXPECT_NE(document->focusedElement(), static_cast<blink::Element*>(inputElem
ent)); |
2014 inputElement->setValue("testA3"); | 2014 inputElement->setValue("testA3"); |
2015 EXPECT_FALSE(client.textIsUpdated()); | 2015 EXPECT_FALSE(client.textIsUpdated()); |
2016 | 2016 |
2017 // (B) <textarea> | 2017 // (B) <textarea> |
2018 // (B.1) Focused and value is changed by script. | 2018 // (B.1) Focused and value is changed by script. |
2019 client.reset(); | 2019 client.reset(); |
2020 EXPECT_FALSE(client.textIsUpdated()); | 2020 EXPECT_FALSE(client.textIsUpdated()); |
2021 WebCore::HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(docume
nt->getElementById("textarea")); | 2021 blink::HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(document
->getElementById("textarea")); |
2022 document->setFocusedElement(textAreaElement); | 2022 document->setFocusedElement(textAreaElement); |
2023 webViewImpl->setFocus(true); | 2023 webViewImpl->setFocus(true); |
2024 EXPECT_EQ(document->focusedElement(), static_cast<WebCore::Element*>(textAre
aElement)); | 2024 EXPECT_EQ(document->focusedElement(), static_cast<blink::Element*>(textAreaE
lement)); |
2025 textAreaElement->setValue("testB"); | 2025 textAreaElement->setValue("testB"); |
2026 EXPECT_TRUE(client.textIsUpdated()); | 2026 EXPECT_TRUE(client.textIsUpdated()); |
2027 info = webViewImpl->textInputInfo(); | 2027 info = webViewImpl->textInputInfo(); |
2028 EXPECT_EQ("testB", std::string(info.value.utf8().data())); | 2028 EXPECT_EQ("testB", std::string(info.value.utf8().data())); |
2029 | 2029 |
2030 // (B.2) Focused and user input modifies value. | 2030 // (B.2) Focused and user input modifies value. |
2031 client.reset(); | 2031 client.reset(); |
2032 EXPECT_FALSE(client.textIsUpdated()); | 2032 EXPECT_FALSE(client.textIsUpdated()); |
2033 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; | 2033 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; |
2034 webViewImpl->confirmComposition(WebWidget::KeepSelection); | 2034 webViewImpl->confirmComposition(WebWidget::KeepSelection); |
2035 info = webViewImpl->textInputInfo(); | 2035 info = webViewImpl->textInputInfo(); |
2036 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); | 2036 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); |
2037 | 2037 |
2038 // (B.3) Unfocused and value is changed by script. | 2038 // (B.3) Unfocused and value is changed by script. |
2039 client.reset(); | 2039 client.reset(); |
2040 EXPECT_FALSE(client.textIsUpdated()); | 2040 EXPECT_FALSE(client.textIsUpdated()); |
2041 document->setFocusedElement(nullptr); | 2041 document->setFocusedElement(nullptr); |
2042 webViewImpl->setFocus(false); | 2042 webViewImpl->setFocus(false); |
2043 EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
aElement)); | 2043 EXPECT_NE(document->focusedElement(), static_cast<blink::Element*>(textAreaE
lement)); |
2044 inputElement->setValue("testB3"); | 2044 inputElement->setValue("testB3"); |
2045 EXPECT_FALSE(client.textIsUpdated()); | 2045 EXPECT_FALSE(client.textIsUpdated()); |
2046 | 2046 |
2047 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. | 2047 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. |
2048 m_webViewHelper.reset(); | 2048 m_webViewHelper.reset(); |
2049 } | 2049 } |
2050 | 2050 |
2051 // Check that the WebAutofillClient is correctly notified about first user | 2051 // Check that the WebAutofillClient is correctly notified about first user |
2052 // gestures after load, following various input events. | 2052 // gestures after load, following various input events. |
2053 TEST_F(WebViewTest, FirstUserGestureObservedKeyEvent) | 2053 TEST_F(WebViewTest, FirstUserGestureObservedKeyEvent) |
2054 { | 2054 { |
2055 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); | 2055 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); |
2056 MockAutofillClient client; | 2056 MockAutofillClient client; |
2057 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html"
, true); | 2057 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html"
, true); |
2058 webView->setAutofillClient(&client); | 2058 webView->setAutofillClient(&client); |
2059 webView->setInitialFocus(false); | 2059 webView->setInitialFocus(false); |
2060 | 2060 |
2061 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 2061 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
2062 | 2062 |
2063 WebKeyboardEvent keyEvent; | 2063 WebKeyboardEvent keyEvent; |
2064 keyEvent.windowsKeyCode = WebCore::VKEY_SPACE; | 2064 keyEvent.windowsKeyCode = blink::VKEY_SPACE; |
2065 keyEvent.type = WebInputEvent::RawKeyDown; | 2065 keyEvent.type = WebInputEvent::RawKeyDown; |
2066 keyEvent.setKeyIdentifierFromWindowsKeyCode(); | 2066 keyEvent.setKeyIdentifierFromWindowsKeyCode(); |
2067 webView->handleInputEvent(keyEvent); | 2067 webView->handleInputEvent(keyEvent); |
2068 keyEvent.type = WebInputEvent::KeyUp; | 2068 keyEvent.type = WebInputEvent::KeyUp; |
2069 webView->handleInputEvent(keyEvent); | 2069 webView->handleInputEvent(keyEvent); |
2070 | 2070 |
2071 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2071 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
2072 webView->setAutofillClient(0); | 2072 webView->setAutofillClient(0); |
2073 } | 2073 } |
2074 | 2074 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 | 2106 |
2107 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 2107 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
2108 | 2108 |
2109 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 2109 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
2110 | 2110 |
2111 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2111 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
2112 webView->setAutofillClient(0); | 2112 webView->setAutofillClient(0); |
2113 } | 2113 } |
2114 | 2114 |
2115 } // namespace | 2115 } // namespace |
OLD | NEW |