| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 EXPECT_EQ(transparentRed, frame->view()->baseBackgroundColor()); | 412 EXPECT_EQ(transparentRed, frame->view()->baseBackgroundColor()); |
| 413 frame->view()->dispose(); | 413 frame->view()->dispose(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) { | 416 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) { |
| 417 const WebColor kBlue = 0xFF0000FF; | 417 const WebColor kBlue = 0xFF0000FF; |
| 418 FrameTestHelpers::TestWebViewClient webViewClient; | 418 FrameTestHelpers::TestWebViewClient webViewClient; |
| 419 WebViewImpl* webView = | 419 WebViewImpl* webView = |
| 420 WebViewImpl::create(&webViewClient, WebPageVisibilityStateVisible); | 420 WebViewImpl::create(&webViewClient, WebPageVisibilityStateVisible); |
| 421 EXPECT_NE(kBlue, webView->backgroundColor()); | 421 EXPECT_NE(kBlue, webView->backgroundColor()); |
| 422 // webView does not have a frame yet, but we should still be able to set the b
ackground color. | 422 // webView does not have a frame yet, but we should still be able to set the |
| 423 // background color. |
| 423 webView->setBaseBackgroundColor(kBlue); | 424 webView->setBaseBackgroundColor(kBlue); |
| 424 EXPECT_EQ(kBlue, webView->backgroundColor()); | 425 EXPECT_EQ(kBlue, webView->backgroundColor()); |
| 425 FrameTestHelpers::TestWebFrameClient webFrameClient; | 426 FrameTestHelpers::TestWebFrameClient webFrameClient; |
| 426 WebLocalFrame* frame = | 427 WebLocalFrame* frame = |
| 427 WebLocalFrame::create(WebTreeScopeType::Document, &webFrameClient); | 428 WebLocalFrame::create(WebTreeScopeType::Document, &webFrameClient); |
| 428 webView->setMainFrame(frame); | 429 webView->setMainFrame(frame); |
| 429 webView->close(); | 430 webView->close(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) { | 433 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 444 webView->updateAllLifecyclePhases(); | 445 webView->updateAllLifecyclePhases(); |
| 445 | 446 |
| 446 // Set canvas background to red with alpha. | 447 // Set canvas background to red with alpha. |
| 447 SkBitmap bitmap; | 448 SkBitmap bitmap; |
| 448 bitmap.allocN32Pixels(kWidth, kHeight); | 449 bitmap.allocN32Pixels(kWidth, kHeight); |
| 449 SkCanvas canvas(bitmap); | 450 SkCanvas canvas(bitmap); |
| 450 canvas.clear(kAlphaRed); | 451 canvas.clear(kAlphaRed); |
| 451 | 452 |
| 452 SkPictureBuilder pictureBuilder(FloatRect(0, 0, kWidth, kHeight)); | 453 SkPictureBuilder pictureBuilder(FloatRect(0, 0, kWidth, kHeight)); |
| 453 | 454 |
| 454 // Paint the root of the main frame in the way that CompositedLayerMapping wou
ld. | 455 // Paint the root of the main frame in the way that CompositedLayerMapping |
| 456 // would. |
| 455 FrameView* view = m_webViewHelper.webView()->mainFrameImpl()->frameView(); | 457 FrameView* view = m_webViewHelper.webView()->mainFrameImpl()->frameView(); |
| 456 PaintLayer* rootLayer = view->layoutViewItem().layer(); | 458 PaintLayer* rootLayer = view->layoutViewItem().layer(); |
| 457 LayoutRect paintRect(0, 0, kWidth, kHeight); | 459 LayoutRect paintRect(0, 0, kWidth, kHeight); |
| 458 PaintLayerPaintingInfo paintingInfo(rootLayer, paintRect, | 460 PaintLayerPaintingInfo paintingInfo(rootLayer, paintRect, |
| 459 GlobalPaintNormalPhase, LayoutSize()); | 461 GlobalPaintNormalPhase, LayoutSize()); |
| 460 PaintLayerPainter(*rootLayer) | 462 PaintLayerPainter(*rootLayer) |
| 461 .paintLayerContents(pictureBuilder.context(), paintingInfo, | 463 .paintLayerContents(pictureBuilder.context(), paintingInfo, |
| 462 PaintLayerPaintingCompositingAllPhases); | 464 PaintLayerPaintingCompositingAllPhases); |
| 463 | 465 |
| 464 pictureBuilder.endRecording()->playback(&canvas); | 466 pictureBuilder.endRecording()->playback(&canvas); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 EXPECT_EQ(expectedHeight, client.testData().height()); | 651 EXPECT_EQ(expectedHeight, client.testData().height()); |
| 650 | 652 |
| 651 // Android disables main frame scrollbars. | 653 // Android disables main frame scrollbars. |
| 652 #if !OS(ANDROID) | 654 #if !OS(ANDROID) |
| 653 EXPECT_EQ(expectedHorizontalState, | 655 EXPECT_EQ(expectedHorizontalState, |
| 654 client.testData().getHorizontalScrollbarState()); | 656 client.testData().getHorizontalScrollbarState()); |
| 655 EXPECT_EQ(expectedVerticalState, | 657 EXPECT_EQ(expectedVerticalState, |
| 656 client.testData().getVerticalScrollbarState()); | 658 client.testData().getVerticalScrollbarState()); |
| 657 #endif | 659 #endif |
| 658 | 660 |
| 659 m_webViewHelper | 661 // Explicitly reset to break dependency on locally scoped client. |
| 660 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | 662 m_webViewHelper.reset(); |
| 661 } | 663 } |
| 662 | 664 |
| 663 TEST_F(WebViewTest, AutoResizeMinimumSize) { | 665 TEST_F(WebViewTest, AutoResizeMinimumSize) { |
| 664 WebSize minAutoResize(91, 56); | 666 WebSize minAutoResize(91, 56); |
| 665 WebSize maxAutoResize(403, 302); | 667 WebSize maxAutoResize(403, 302); |
| 666 std::string pageWidth = "91px"; | 668 std::string pageWidth = "91px"; |
| 667 std::string pageHeight = "56px"; | 669 std::string pageHeight = "56px"; |
| 668 int expectedWidth = 91; | 670 int expectedWidth = 91; |
| 669 int expectedHeight = 56; | 671 int expectedHeight = 56; |
| 670 testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight, | 672 testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 testTextInputType(WebTextInputTypeURL, "input_field_url.html"); | 762 testTextInputType(WebTextInputTypeURL, "input_field_url.html"); |
| 761 } | 763 } |
| 762 | 764 |
| 763 TEST_F(WebViewTest, TextInputInfoUpdateStyleAndLayout) { | 765 TEST_F(WebViewTest, TextInputInfoUpdateStyleAndLayout) { |
| 764 FrameTestHelpers::TestWebViewClient client; | 766 FrameTestHelpers::TestWebViewClient client; |
| 765 FrameTestHelpers::WebViewHelper m_webViewHelper; | 767 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 766 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); | 768 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); |
| 767 | 769 |
| 768 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); | 770 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
| 769 // Here, we need to construct a document that has a special property: | 771 // Here, we need to construct a document that has a special property: |
| 770 // Adding id="foo" to the <path> element will trigger creation of an SVG insta
nce tree | 772 // Adding id="foo" to the <path> element will trigger creation of an SVG |
| 771 // for the use <use> element. | 773 // instance tree for the use <use> element. |
| 772 // This is significant, because SVG instance trees are actually created lazily | 774 // This is significant, because SVG instance trees are actually created lazily |
| 773 // during Document::updateStyleAndLayout code, thus incrementing the DOM tree
version | 775 // during Document::updateStyleAndLayout code, thus incrementing the DOM tree |
| 774 // and freaking out the EphemeralRange (invalidating it). | 776 // version and freaking out the EphemeralRange (invalidating it). |
| 775 FrameTestHelpers::loadHTMLString( | 777 FrameTestHelpers::loadHTMLString( |
| 776 webViewImpl->mainFrame(), | 778 webViewImpl->mainFrame(), |
| 777 "<svg height='100%' version='1.1' viewBox='0 0 14 14' width='100%'>" | 779 "<svg height='100%' version='1.1' viewBox='0 0 14 14' width='100%'>" |
| 778 "<use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#foo'></use>" | 780 "<use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#foo'></use>" |
| 779 "<path d='M 100 100 L 300 100 L 200 300 z' fill='#000'></path>" | 781 "<path d='M 100 100 L 300 100 L 200 300 z' fill='#000'></path>" |
| 780 "</svg>" | 782 "</svg>" |
| 781 "<input>", | 783 "<input>", |
| 782 baseURL); | 784 baseURL); |
| 783 webViewImpl->setInitialFocus(false); | 785 webViewImpl->setInitialFocus(false); |
| 784 | 786 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1521 nullptr, FrameLoader::resourceRequestFromHistoryItem( |
| 1520 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), | 1522 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), |
| 1521 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); | 1523 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); |
| 1522 | 1524 |
| 1523 // Click a different anchor | 1525 // Click a different anchor |
| 1524 mainFrameLocal->loader().load(FrameLoadRequest( | 1526 mainFrameLocal->loader().load(FrameLoadRequest( |
| 1525 mainFrameLocal->document(), | 1527 mainFrameLocal->document(), |
| 1526 ResourceRequest(mainFrameLocal->document()->completeURL("#b")))); | 1528 ResourceRequest(mainFrameLocal->document()->completeURL("#b")))); |
| 1527 Persistent<HistoryItem> item3 = mainFrameLocal->loader().currentItem(); | 1529 Persistent<HistoryItem> item3 = mainFrameLocal->loader().currentItem(); |
| 1528 | 1530 |
| 1529 // Go back, then forward. The scroll position should be properly set on the fo
rward navigation. | 1531 // Go back, then forward. The scroll position should be properly set on the |
| 1532 // forward navigation. |
| 1530 mainFrameLocal->loader().load( | 1533 mainFrameLocal->loader().load( |
| 1531 FrameLoadRequest( | 1534 FrameLoadRequest( |
| 1532 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1535 nullptr, FrameLoader::resourceRequestFromHistoryItem( |
| 1533 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), | 1536 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), |
| 1534 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); | 1537 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); |
| 1535 mainFrameLocal->loader().load( | 1538 mainFrameLocal->loader().load( |
| 1536 FrameLoadRequest( | 1539 FrameLoadRequest( |
| 1537 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 1540 nullptr, FrameLoader::resourceRequestFromHistoryItem( |
| 1538 item3.get(), WebCachePolicy::UseProtocolCachePolicy)), | 1541 item3.get(), WebCachePolicy::UseProtocolCachePolicy)), |
| 1539 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); | 1542 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 DragAndDropURL(webView, barUrl); | 1744 DragAndDropURL(webView, barUrl); |
| 1742 EXPECT_EQ(barUrl, webView->mainFrame()->document().url().string().utf8()); | 1745 EXPECT_EQ(barUrl, webView->mainFrame()->document().url().string().utf8()); |
| 1743 | 1746 |
| 1744 // Drag and drop fooUrl and verify that we've navigated back to it. | 1747 // Drag and drop fooUrl and verify that we've navigated back to it. |
| 1745 DragAndDropURL(webView, fooUrl); | 1748 DragAndDropURL(webView, fooUrl); |
| 1746 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); | 1749 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); |
| 1747 | 1750 |
| 1748 // Disable navigation on drag-and-drop. | 1751 // Disable navigation on drag-and-drop. |
| 1749 webView->settingsImpl()->setNavigateOnDragDrop(false); | 1752 webView->settingsImpl()->setNavigateOnDragDrop(false); |
| 1750 | 1753 |
| 1751 // Attempt to drag and drop to barUrl and verify that no navigation has occurr
ed. | 1754 // Attempt to drag and drop to barUrl and verify that no navigation has |
| 1755 // occurred. |
| 1752 DragAndDropURL(webView, barUrl); | 1756 DragAndDropURL(webView, barUrl); |
| 1753 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); | 1757 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); |
| 1754 } | 1758 } |
| 1755 | 1759 |
| 1756 class ContentDetectorClient : public FrameTestHelpers::TestWebViewClient { | 1760 class ContentDetectorClient : public FrameTestHelpers::TestWebViewClient { |
| 1757 public: | 1761 public: |
| 1758 ContentDetectorClient() { reset(); } | 1762 ContentDetectorClient() { reset(); } |
| 1759 | 1763 |
| 1760 WebURL detectContentIntentAt(const WebHitTestResult& hitTest) override { | 1764 WebURL detectContentIntentAt(const WebHitTestResult& hitTest) override { |
| 1761 m_contentDetectionRequested = true; | 1765 m_contentDetectionRequested = true; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 WebURL m_contentDetectionResult; | 1799 WebURL m_contentDetectionResult; |
| 1796 }; | 1800 }; |
| 1797 | 1801 |
| 1798 bool WebViewTest::tapElement(WebInputEvent::Type type, Element* element) { | 1802 bool WebViewTest::tapElement(WebInputEvent::Type type, Element* element) { |
| 1799 if (!element || !element->layoutObject()) | 1803 if (!element || !element->layoutObject()) |
| 1800 return false; | 1804 return false; |
| 1801 | 1805 |
| 1802 DCHECK(m_webViewHelper.webView()); | 1806 DCHECK(m_webViewHelper.webView()); |
| 1803 element->scrollIntoViewIfNeeded(); | 1807 element->scrollIntoViewIfNeeded(); |
| 1804 | 1808 |
| 1805 // TODO(bokan): Technically incorrect, event positions should be in viewport s
pace. crbug.com/371902. | 1809 // TODO(bokan): Technically incorrect, event positions should be in viewport |
| 1810 // space. crbug.com/371902. |
| 1806 IntPoint center = | 1811 IntPoint center = |
| 1807 m_webViewHelper.webView() | 1812 m_webViewHelper.webView() |
| 1808 ->mainFrameImpl() | 1813 ->mainFrameImpl() |
| 1809 ->frameView() | 1814 ->frameView() |
| 1810 ->contentsToScreen(element->layoutObject()->absoluteBoundingBoxRect()) | 1815 ->contentsToScreen(element->layoutObject()->absoluteBoundingBoxRect()) |
| 1811 .center(); | 1816 .center(); |
| 1812 | 1817 |
| 1813 WebGestureEvent event; | 1818 WebGestureEvent event; |
| 1814 event.type = type; | 1819 event.type = type; |
| 1815 event.sourceDevice = WebGestureDeviceTouchscreen; | 1820 event.sourceDevice = WebGestureDeviceTouchscreen; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 EXPECT_TRUE(client.wasInMainFrame()); | 1879 EXPECT_TRUE(client.wasInMainFrame()); |
| 1875 | 1880 |
| 1876 // Tapping elsewhere should cancel the scheduled intent. | 1881 // Tapping elsewhere should cancel the scheduled intent. |
| 1877 WebGestureEvent event; | 1882 WebGestureEvent event; |
| 1878 event.type = WebInputEvent::GestureTap; | 1883 event.type = WebInputEvent::GestureTap; |
| 1879 event.sourceDevice = WebGestureDeviceTouchscreen; | 1884 event.sourceDevice = WebGestureDeviceTouchscreen; |
| 1880 webView->handleInputEvent(event); | 1885 webView->handleInputEvent(event); |
| 1881 runPendingTasks(); | 1886 runPendingTasks(); |
| 1882 EXPECT_TRUE(client.pendingIntentsCancelled()); | 1887 EXPECT_TRUE(client.pendingIntentsCancelled()); |
| 1883 | 1888 |
| 1884 m_webViewHelper | 1889 // Explicitly reset to break dependency on locally scoped client. |
| 1885 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | 1890 m_webViewHelper.reset(); |
| 1886 } | 1891 } |
| 1887 | 1892 |
| 1888 TEST_F(WebViewTest, ContentDetectionInIframe) { | 1893 TEST_F(WebViewTest, ContentDetectionInIframe) { |
| 1889 URLTestHelpers::registerMockedURLFromBaseURL( | 1894 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1890 WebString::fromUTF8(m_baseURL.c_str()), | 1895 WebString::fromUTF8(m_baseURL.c_str()), |
| 1891 WebString::fromUTF8("content_listeners_iframe.html")); | 1896 WebString::fromUTF8("content_listeners_iframe.html")); |
| 1892 | 1897 |
| 1893 ContentDetectorClient client; | 1898 ContentDetectorClient client; |
| 1894 WebView* webView = m_webViewHelper.initializeAndLoad( | 1899 WebView* webView = m_webViewHelper.initializeAndLoad( |
| 1895 m_baseURL + "content_listeners_iframe.html", true, 0, &client); | 1900 m_baseURL + "content_listeners_iframe.html", true, 0, &client); |
| 1896 webView->resize(WebSize(500, 300)); | 1901 webView->resize(WebSize(500, 300)); |
| 1897 webView->updateAllLifecyclePhases(); | 1902 webView->updateAllLifecyclePhases(); |
| 1898 runPendingTasks(); | 1903 runPendingTasks(); |
| 1899 | 1904 |
| 1900 WebString noListener = WebString::fromUTF8("noListener"); | 1905 WebString noListener = WebString::fromUTF8("noListener"); |
| 1901 WebString frameName = WebString::fromUTF8("innerFrame"); | 1906 WebString frameName = WebString::fromUTF8("innerFrame"); |
| 1902 | 1907 |
| 1903 WebURL intentURL = toKURL(m_baseURL); | 1908 WebURL intentURL = toKURL(m_baseURL); |
| 1904 client.setContentDetectionResult(intentURL); | 1909 client.setContentDetectionResult(intentURL); |
| 1905 Element* element = static_cast<Element*>( | 1910 Element* element = static_cast<Element*>( |
| 1906 webView->findFrameByName(frameName)->document().getElementById( | 1911 webView->findFrameByName(frameName)->document().getElementById( |
| 1907 noListener)); | 1912 noListener)); |
| 1908 EXPECT_TRUE(tapElement(WebInputEvent::GestureTap, element)); | 1913 EXPECT_TRUE(tapElement(WebInputEvent::GestureTap, element)); |
| 1909 EXPECT_TRUE(client.scheduledIntentURL() == intentURL); | 1914 EXPECT_TRUE(client.scheduledIntentURL() == intentURL); |
| 1910 EXPECT_FALSE(client.wasInMainFrame()); | 1915 EXPECT_FALSE(client.wasInMainFrame()); |
| 1911 | 1916 |
| 1912 m_webViewHelper | 1917 // Explicitly reset to break dependency on locally scoped client. |
| 1913 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | 1918 m_webViewHelper.reset(); |
| 1914 } | 1919 } |
| 1915 | 1920 |
| 1916 TEST_F(WebViewTest, ClientTapHandling) { | 1921 TEST_F(WebViewTest, ClientTapHandling) { |
| 1917 TapHandlingWebViewClient client; | 1922 TapHandlingWebViewClient client; |
| 1918 client.reset(); | 1923 client.reset(); |
| 1919 WebView* webView = | 1924 WebView* webView = |
| 1920 m_webViewHelper.initializeAndLoad("about:blank", true, 0, &client); | 1925 m_webViewHelper.initializeAndLoad("about:blank", true, 0, &client); |
| 1921 WebGestureEvent event; | 1926 WebGestureEvent event; |
| 1922 event.type = WebInputEvent::GestureTap; | 1927 event.type = WebInputEvent::GestureTap; |
| 1923 event.sourceDevice = WebGestureDeviceTouchscreen; | 1928 event.sourceDevice = WebGestureDeviceTouchscreen; |
| 1924 event.x = 3; | 1929 event.x = 3; |
| 1925 event.y = 8; | 1930 event.y = 8; |
| 1926 webView->handleInputEvent(event); | 1931 webView->handleInputEvent(event); |
| 1927 runPendingTasks(); | 1932 runPendingTasks(); |
| 1928 EXPECT_EQ(3, client.tapX()); | 1933 EXPECT_EQ(3, client.tapX()); |
| 1929 EXPECT_EQ(8, client.tapY()); | 1934 EXPECT_EQ(8, client.tapY()); |
| 1930 client.reset(); | 1935 client.reset(); |
| 1931 event.type = WebInputEvent::GestureLongPress; | 1936 event.type = WebInputEvent::GestureLongPress; |
| 1932 event.x = 25; | 1937 event.x = 25; |
| 1933 event.y = 7; | 1938 event.y = 7; |
| 1934 webView->handleInputEvent(event); | 1939 webView->handleInputEvent(event); |
| 1935 runPendingTasks(); | 1940 runPendingTasks(); |
| 1936 EXPECT_EQ(25, client.longpressX()); | 1941 EXPECT_EQ(25, client.longpressX()); |
| 1937 EXPECT_EQ(7, client.longpressY()); | 1942 EXPECT_EQ(7, client.longpressY()); |
| 1938 | 1943 |
| 1939 m_webViewHelper | 1944 // Explicitly reset to break dependency on locally scoped client. |
| 1940 .reset(); // Explicitly reset to break dependency on locally scoped clien
t. | 1945 m_webViewHelper.reset(); |
| 1941 } | 1946 } |
| 1942 | 1947 |
| 1943 TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient) { | 1948 TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient) { |
| 1944 WebViewImpl* webView = | 1949 WebViewImpl* webView = |
| 1945 WebViewImpl::create(nullptr, WebPageVisibilityStateVisible); | 1950 WebViewImpl::create(nullptr, WebPageVisibilityStateVisible); |
| 1946 FrameTestHelpers::TestWebFrameClient webFrameClient; | 1951 FrameTestHelpers::TestWebFrameClient webFrameClient; |
| 1947 WebLocalFrame* localFrame = | 1952 WebLocalFrame* localFrame = |
| 1948 WebLocalFrame::create(WebTreeScopeType::Document, &webFrameClient); | 1953 WebLocalFrame::create(WebTreeScopeType::Document, &webFrameClient); |
| 1949 webView->setMainFrame(localFrame); | 1954 webView->setMainFrame(localFrame); |
| 1950 WebGestureEvent event; | 1955 WebGestureEvent event; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 // Set up a composition that needs to be committed. | 2452 // Set up a composition that needs to be committed. |
| 2448 WebVector<WebCompositionUnderline> emptyUnderlines; | 2453 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2449 frame->setEditableSelectionOffsets(4, 10); | 2454 frame->setEditableSelectionOffsets(4, 10); |
| 2450 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 2455 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 2451 WebTextInputInfo info = webView->textInputInfo(); | 2456 WebTextInputInfo info = webView->textInputInfo(); |
| 2452 EXPECT_EQ(4, info.selectionStart); | 2457 EXPECT_EQ(4, info.selectionStart); |
| 2453 EXPECT_EQ(10, info.selectionEnd); | 2458 EXPECT_EQ(10, info.selectionEnd); |
| 2454 EXPECT_EQ(8, info.compositionStart); | 2459 EXPECT_EQ(8, info.compositionStart); |
| 2455 EXPECT_EQ(12, info.compositionEnd); | 2460 EXPECT_EQ(12, info.compositionEnd); |
| 2456 | 2461 |
| 2457 // Clear the focus and track that the subsequent composition commit does not t
rigger a | 2462 // Clear the focus and track that the subsequent composition commit does not |
| 2458 // text changed notification for autofill. | 2463 // trigger a text changed notification for autofill. |
| 2459 client.clearChangeCounts(); | 2464 client.clearChangeCounts(); |
| 2460 webView->setFocus(false); | 2465 webView->setFocus(false); |
| 2461 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); | 2466 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); |
| 2462 | 2467 |
| 2463 frame->setAutofillClient(0); | 2468 frame->setAutofillClient(0); |
| 2464 } | 2469 } |
| 2465 | 2470 |
| 2466 static void verifySelectionAndComposition(WebView* webView, | 2471 static void verifySelectionAndComposition(WebView* webView, |
| 2467 int selectionStart, | 2472 int selectionStart, |
| 2468 int selectionEnd, | 2473 int selectionEnd, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2489 | 2494 |
| 2490 // Test both input elements. | 2495 // Test both input elements. |
| 2491 for (int i = 0; i < 2; ++i) { | 2496 for (int i = 0; i < 2; ++i) { |
| 2492 // Select composition and do sanity check. | 2497 // Select composition and do sanity check. |
| 2493 WebVector<WebCompositionUnderline> emptyUnderlines; | 2498 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2494 frame->setEditableSelectionOffsets(6, 6); | 2499 frame->setEditableSelectionOffsets(6, 6); |
| 2495 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); | 2500 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); |
| 2496 frame->setEditableSelectionOffsets(11, 11); | 2501 frame->setEditableSelectionOffsets(11, 11); |
| 2497 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); | 2502 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); |
| 2498 | 2503 |
| 2499 // Press Backspace and verify composition didn't get cancelled. This is to v
erify the fix | 2504 // Press Backspace and verify composition didn't get cancelled. This is to |
| 2500 // for crbug.com/429916. | 2505 // verify the fix for crbug.com/429916. |
| 2501 WebKeyboardEvent keyEvent; | 2506 WebKeyboardEvent keyEvent; |
| 2502 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); | 2507 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); |
| 2503 keyEvent.windowsKeyCode = VKEY_BACK; | 2508 keyEvent.windowsKeyCode = VKEY_BACK; |
| 2504 keyEvent.type = WebInputEvent::RawKeyDown; | 2509 keyEvent.type = WebInputEvent::RawKeyDown; |
| 2505 webView->handleInputEvent(keyEvent); | 2510 webView->handleInputEvent(keyEvent); |
| 2506 | 2511 |
| 2507 frame->setEditableSelectionOffsets(6, 6); | 2512 frame->setEditableSelectionOffsets(6, 6); |
| 2508 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); | 2513 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); |
| 2509 frame->setEditableSelectionOffsets(10, 10); | 2514 frame->setEditableSelectionOffsets(10, 10); |
| 2510 verifySelectionAndComposition(webView, 10, 10, 6, 10, | 2515 verifySelectionAndComposition(webView, 10, 10, 6, 10, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2643 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); | 2648 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
| 2644 frame->setName("_start"); | 2649 frame->setName("_start"); |
| 2645 | 2650 |
| 2646 // Make a request that will open a new window | 2651 // Make a request that will open a new window |
| 2647 WebURLRequest webURLRequest; | 2652 WebURLRequest webURLRequest; |
| 2648 FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blank"); | 2653 FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blank"); |
| 2649 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); | 2654 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); |
| 2650 ASSERT_TRUE(client.createdWebView()); | 2655 ASSERT_TRUE(client.createdWebView()); |
| 2651 EXPECT_FALSE(client.didFocusCalled()); | 2656 EXPECT_FALSE(client.didFocusCalled()); |
| 2652 | 2657 |
| 2653 // Make a request from the new window that will navigate the original window.
The original window should be focused. | 2658 // Make a request from the new window that will navigate the original window. |
| 2659 // The original window should be focused. |
| 2654 WebURLRequest webURLRequestWithTargetStart; | 2660 WebURLRequest webURLRequestWithTargetStart; |
| 2655 FrameLoadRequest requestWithTargetStart( | 2661 FrameLoadRequest requestWithTargetStart( |
| 2656 0, webURLRequestWithTargetStart.toResourceRequest(), "_start"); | 2662 0, webURLRequestWithTargetStart.toResourceRequest(), "_start"); |
| 2657 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame()) | 2663 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame()) |
| 2658 ->loader() | 2664 ->loader() |
| 2659 .load(requestWithTargetStart); | 2665 .load(requestWithTargetStart); |
| 2660 EXPECT_TRUE(client.didFocusCalled()); | 2666 EXPECT_TRUE(client.didFocusCalled()); |
| 2661 | 2667 |
| 2662 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2668 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 2663 } | 2669 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2781 client.chooserCompletion()->didChooseValue(0); | 2787 client.chooserCompletion()->didChooseValue(0); |
| 2782 client.clearChooserCompletion(); | 2788 client.clearChooserCompletion(); |
| 2783 EXPECT_STREQ("1970-W01", inputElement->value().utf8().data()); | 2789 EXPECT_STREQ("1970-W01", inputElement->value().utf8().data()); |
| 2784 | 2790 |
| 2785 openDateTimeChooser(webViewImpl, inputElement); | 2791 openDateTimeChooser(webViewImpl, inputElement); |
| 2786 client.chooserCompletion()->didChooseValue( | 2792 client.chooserCompletion()->didChooseValue( |
| 2787 std::numeric_limits<double>::quiet_NaN()); | 2793 std::numeric_limits<double>::quiet_NaN()); |
| 2788 client.clearChooserCompletion(); | 2794 client.clearChooserCompletion(); |
| 2789 EXPECT_STREQ("", inputElement->value().utf8().data()); | 2795 EXPECT_STREQ("", inputElement->value().utf8().data()); |
| 2790 | 2796 |
| 2791 // Clear the WebViewClient from the webViewHelper to avoid use-after-free in t
he | 2797 // Clear the WebViewClient from the webViewHelper to avoid use-after-free in |
| 2792 // WebViewHelper destructor. | 2798 // the WebViewHelper destructor. |
| 2793 m_webViewHelper.reset(); | 2799 m_webViewHelper.reset(); |
| 2794 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled( | 2800 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled( |
| 2795 originalMultipleFieldsFlag); | 2801 originalMultipleFieldsFlag); |
| 2796 } | 2802 } |
| 2797 | 2803 |
| 2798 TEST_F(WebViewTest, DispatchesFocusBlurOnViewToggle) { | 2804 TEST_F(WebViewTest, DispatchesFocusBlurOnViewToggle) { |
| 2799 URLTestHelpers::registerMockedURLFromBaseURL( | 2805 URLTestHelpers::registerMockedURLFromBaseURL( |
| 2800 WebString::fromUTF8(m_baseURL.c_str()), "focus_blur_events.html"); | 2806 WebString::fromUTF8(m_baseURL.c_str()), "focus_blur_events.html"); |
| 2801 WebView* webView = m_webViewHelper.initializeAndLoad( | 2807 WebView* webView = m_webViewHelper.initializeAndLoad( |
| 2802 m_baseURL + "focus_blur_events.html", true, 0); | 2808 m_baseURL + "focus_blur_events.html", true, 0); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 TouchEventHandlerWebViewClient client; | 3064 TouchEventHandlerWebViewClient client; |
| 3059 std::string url = m_baseURL + "has_touch_event_handlers.html"; | 3065 std::string url = m_baseURL + "has_touch_event_handlers.html"; |
| 3060 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 3066 URLTestHelpers::registerMockedURLLoad(toKURL(url), |
| 3061 "has_touch_event_handlers.html"); | 3067 "has_touch_event_handlers.html"); |
| 3062 WebViewImpl* webViewImpl = | 3068 WebViewImpl* webViewImpl = |
| 3063 m_webViewHelper.initializeAndLoad(url, true, 0, &client); | 3069 m_webViewHelper.initializeAndLoad(url, true, 0, &client); |
| 3064 const EventHandlerRegistry::EventHandlerClass touchEvent = | 3070 const EventHandlerRegistry::EventHandlerClass touchEvent = |
| 3065 EventHandlerRegistry::TouchStartOrMoveEventBlocking; | 3071 EventHandlerRegistry::TouchStartOrMoveEventBlocking; |
| 3066 | 3072 |
| 3067 // The page is initialized with at least one no-handlers call. | 3073 // The page is initialized with at least one no-handlers call. |
| 3068 // In practice we get two such calls because WebViewHelper::initializeAndLoad
first | 3074 // In practice we get two such calls because WebViewHelper::initializeAndLoad |
| 3069 // initializes and empty frame, and then loads a document into it, so there ar
e two | 3075 // first initializes and empty frame, and then loads a document into it, so |
| 3070 // FrameLoader::commitProvisionalLoad calls. | 3076 // there are two FrameLoader::commitProvisionalLoad calls. |
| 3071 EXPECT_GE(client.getAndResetHasTouchEventHandlerCallCount(false), 1); | 3077 EXPECT_GE(client.getAndResetHasTouchEventHandlerCallCount(false), 1); |
| 3072 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3078 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3073 | 3079 |
| 3074 // Adding the first document handler results in a has-handlers call. | 3080 // Adding the first document handler results in a has-handlers call. |
| 3075 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 3081 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 3076 EventHandlerRegistry* registry = | 3082 EventHandlerRegistry* registry = |
| 3077 &document->frameHost()->eventHandlerRegistry(); | 3083 &document->frameHost()->eventHandlerRegistry(); |
| 3078 registry->didAddEventHandler(*document, touchEvent); | 3084 registry->didAddEventHandler(*document, touchEvent); |
| 3079 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3085 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3080 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3086 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 // Adding a handler inside of a child iframe results in a has-handlers call. | 3136 // Adding a handler inside of a child iframe results in a has-handlers call. |
| 3131 Element* childFrame = document->getElementById("childframe"); | 3137 Element* childFrame = document->getElementById("childframe"); |
| 3132 DCHECK(childFrame); | 3138 DCHECK(childFrame); |
| 3133 Document* childDocument = toHTMLIFrameElement(childFrame)->contentDocument(); | 3139 Document* childDocument = toHTMLIFrameElement(childFrame)->contentDocument(); |
| 3134 Element* childDiv = childDocument->getElementById("childdiv"); | 3140 Element* childDiv = childDocument->getElementById("childdiv"); |
| 3135 DCHECK(childDiv); | 3141 DCHECK(childDiv); |
| 3136 registry->didAddEventHandler(*childDiv, touchEvent); | 3142 registry->didAddEventHandler(*childDiv, touchEvent); |
| 3137 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3143 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3138 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3144 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3139 | 3145 |
| 3140 // Adding and clearing handlers in the parent doc or elsewhere in the child do
c | 3146 // Adding and clearing handlers in the parent doc or elsewhere in the child |
| 3141 // has no impact. | 3147 // doc has no impact. |
| 3142 registry->didAddEventHandler(*document, touchEvent); | 3148 registry->didAddEventHandler(*document, touchEvent); |
| 3143 registry->didAddEventHandler(*childFrame, touchEvent); | 3149 registry->didAddEventHandler(*childFrame, touchEvent); |
| 3144 registry->didAddEventHandler(*childDocument, touchEvent); | 3150 registry->didAddEventHandler(*childDocument, touchEvent); |
| 3145 registry->didRemoveAllEventHandlers(*document); | 3151 registry->didRemoveAllEventHandlers(*document); |
| 3146 registry->didRemoveAllEventHandlers(*childFrame); | 3152 registry->didRemoveAllEventHandlers(*childFrame); |
| 3147 registry->didRemoveAllEventHandlers(*childDocument); | 3153 registry->didRemoveAllEventHandlers(*childDocument); |
| 3148 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3154 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3149 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3155 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3150 | 3156 |
| 3151 // Removing the final handler inside the child frame results in a no-handlers
call. | 3157 // Removing the final handler inside the child frame results in a no-handlers |
| 3158 // call. |
| 3152 registry->didRemoveAllEventHandlers(*childDiv); | 3159 registry->didRemoveAllEventHandlers(*childDiv); |
| 3153 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3160 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3154 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3161 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3155 | 3162 |
| 3156 // Adding a handler inside the child frame results in a has-handlers call. | 3163 // Adding a handler inside the child frame results in a has-handlers call. |
| 3157 registry->didAddEventHandler(*childDocument, touchEvent); | 3164 registry->didAddEventHandler(*childDocument, touchEvent); |
| 3158 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3165 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3159 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3166 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3160 | 3167 |
| 3161 // Adding a handler in the parent document and removing the one in the frame | 3168 // Adding a handler in the parent document and removing the one in the frame |
| 3162 // has no effect. | 3169 // has no effect. |
| 3163 registry->didAddEventHandler(*childFrame, touchEvent); | 3170 registry->didAddEventHandler(*childFrame, touchEvent); |
| 3164 registry->didRemoveEventHandler(*childDocument, touchEvent); | 3171 registry->didRemoveEventHandler(*childDocument, touchEvent); |
| 3165 registry->didRemoveAllEventHandlers(*childDocument); | 3172 registry->didRemoveAllEventHandlers(*childDocument); |
| 3166 registry->didRemoveAllEventHandlers(*document); | 3173 registry->didRemoveAllEventHandlers(*document); |
| 3167 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3174 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3168 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3175 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3169 | 3176 |
| 3170 // Now removing the handler in the parent document results in a no-handlers ca
ll. | 3177 // Now removing the handler in the parent document results in a no-handlers |
| 3178 // call. |
| 3171 registry->didRemoveEventHandler(*childFrame, touchEvent); | 3179 registry->didRemoveEventHandler(*childFrame, touchEvent); |
| 3172 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3180 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3173 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3181 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3174 | 3182 |
| 3175 // Free the webView before the TouchEventHandlerWebViewClient gets freed. | 3183 // Free the webView before the TouchEventHandlerWebViewClient gets freed. |
| 3176 m_webViewHelper.reset(); | 3184 m_webViewHelper.reset(); |
| 3177 } | 3185 } |
| 3178 | 3186 |
| 3179 // This test checks that deleting nodes which have only non-JS-registered touch | 3187 // This test checks that deleting nodes which have only non-JS-registered touch |
| 3180 // handlers also removes them from the event handler registry. Note that this | 3188 // handlers also removes them from the event handler registry. Note that this |
| 3181 // is different from detaching and re-attaching the same node, which is covered | 3189 // is different from detaching and re-attaching the same node, which is covered |
| 3182 // by layout tests under fast/events/. | 3190 // by layout tests under fast/events/. |
| 3183 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler) { | 3191 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler) { |
| 3184 std::string url = m_baseURL + "simple_div.html"; | 3192 std::string url = m_baseURL + "simple_div.html"; |
| 3185 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html"); | 3193 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html"); |
| 3186 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); | 3194 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); |
| 3187 | 3195 |
| 3188 Persistent<Document> document = | 3196 Persistent<Document> document = |
| 3189 webViewImpl->mainFrameImpl()->frame()->document(); | 3197 webViewImpl->mainFrameImpl()->frame()->document(); |
| 3190 Element* div = document->getElementById("div"); | 3198 Element* div = document->getElementById("div"); |
| 3191 EventHandlerRegistry& registry = | 3199 EventHandlerRegistry& registry = |
| 3192 document->frameHost()->eventHandlerRegistry(); | 3200 document->frameHost()->eventHandlerRegistry(); |
| 3193 | 3201 |
| 3194 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent); | 3202 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent); |
| 3195 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); | 3203 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); |
| 3196 | 3204 |
| 3197 TrackExceptionState exceptionState; | 3205 TrackExceptionState exceptionState; |
| 3198 div->remove(exceptionState); | 3206 div->remove(exceptionState); |
| 3199 | 3207 |
| 3200 // For oilpan we have to force a GC to ensure the event handlers have been rem
oved when | 3208 // For oilpan we have to force a GC to ensure the event handlers have been |
| 3201 // checking below. We do a precise GC (collectAllGarbage does not scan the sta
ck) | 3209 // removed when checking below. We do a precise GC (collectAllGarbage does not |
| 3202 // to ensure the div element dies. This is also why the Document is in a Persi
stent | 3210 // scan the stack) to ensure the div element dies. This is also why the |
| 3203 // since we want that to stay around. | 3211 // Document is in a Persistent since we want that to stay around. |
| 3204 ThreadState::current()->collectAllGarbage(); | 3212 ThreadState::current()->collectAllGarbage(); |
| 3205 | 3213 |
| 3206 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); | 3214 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); |
| 3207 } | 3215 } |
| 3208 | 3216 |
| 3209 class NonUserInputTextUpdateWebWidgetClient | 3217 class NonUserInputTextUpdateWebWidgetClient |
| 3210 : public FrameTestHelpers::TestWebWidgetClient { | 3218 : public FrameTestHelpers::TestWebWidgetClient { |
| 3211 public: | 3219 public: |
| 3212 NonUserInputTextUpdateWebWidgetClient() : m_textIsUpdated(false) {} | 3220 NonUserInputTextUpdateWebWidgetClient() : m_textIsUpdated(false) {} |
| 3213 | 3221 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 EXPECT_EQ(WebTextInputFlagAutocapitalizeSentences, info3.flags); | 3282 EXPECT_EQ(WebTextInputFlagAutocapitalizeSentences, info3.flags); |
| 3275 | 3283 |
| 3276 // (C) Verifies the WebTextInputInfo's don't equal. | 3284 // (C) Verifies the WebTextInputInfo's don't equal. |
| 3277 EXPECT_FALSE(info1.equals(info2)); | 3285 EXPECT_FALSE(info1.equals(info2)); |
| 3278 EXPECT_FALSE(info2.equals(info3)); | 3286 EXPECT_FALSE(info2.equals(info3)); |
| 3279 | 3287 |
| 3280 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. | 3288 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. |
| 3281 m_webViewHelper.reset(); | 3289 m_webViewHelper.reset(); |
| 3282 } | 3290 } |
| 3283 | 3291 |
| 3284 // This test verifies that WebWidgetClient::didUpdateTextOfFocusedElementByNonUs
erInput is | 3292 // This test verifies that |
| 3285 // called iff value of a focused element is modified via script. | 3293 // WebWidgetClient::didUpdateTextOfFocusedElementByNonUserInput is called iff |
| 3294 // value of a focused element is modified via script. |
| 3286 TEST_F(WebViewTest, NonUserInputTextUpdate) { | 3295 TEST_F(WebViewTest, NonUserInputTextUpdate) { |
| 3287 NonUserInputTextUpdateWebWidgetClient client; | 3296 NonUserInputTextUpdateWebWidgetClient client; |
| 3288 std::string url = m_baseURL + "non_user_input_text_update.html"; | 3297 std::string url = m_baseURL + "non_user_input_text_update.html"; |
| 3289 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 3298 URLTestHelpers::registerMockedURLLoad(toKURL(url), |
| 3290 "non_user_input_text_update.html"); | 3299 "non_user_input_text_update.html"); |
| 3291 WebViewImpl* webViewImpl = | 3300 WebViewImpl* webViewImpl = |
| 3292 m_webViewHelper.initializeAndLoad(url, true, nullptr, nullptr, &client); | 3301 m_webViewHelper.initializeAndLoad(url, true, nullptr, nullptr, &client); |
| 3293 webViewImpl->setInitialFocus(false); | 3302 webViewImpl->setInitialFocus(false); |
| 3294 | 3303 |
| 3295 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); | 3304 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 std::string url = m_baseURL + "subtree-layout.html"; | 3496 std::string url = m_baseURL + "subtree-layout.html"; |
| 3488 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html"); | 3497 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html"); |
| 3489 WebView* webView = m_webViewHelper.initialize(true); | 3498 WebView* webView = m_webViewHelper.initialize(true); |
| 3490 | 3499 |
| 3491 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); | 3500 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); |
| 3492 loadFrame(webView->mainFrame(), url); | 3501 loadFrame(webView->mainFrame(), url); |
| 3493 | 3502 |
| 3494 FrameView* frameView = | 3503 FrameView* frameView = |
| 3495 m_webViewHelper.webView()->mainFrameImpl()->frameView(); | 3504 m_webViewHelper.webView()->mainFrameImpl()->frameView(); |
| 3496 | 3505 |
| 3497 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. Thi
s EXPECT is | 3506 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. |
| 3498 // merely a dummy. The real test is that we don't trigger asserts in debug bui
lds. | 3507 // This EXPECT is merely a dummy. The real test is that we don't trigger |
| 3508 // asserts in debug builds. |
| 3499 EXPECT_FALSE(frameView->needsLayout()); | 3509 EXPECT_FALSE(frameView->needsLayout()); |
| 3500 }; | 3510 }; |
| 3501 | 3511 |
| 3502 TEST_F(WebViewTest, PreferredSize) { | 3512 TEST_F(WebViewTest, PreferredSize) { |
| 3503 std::string url = m_baseURL + "specify_size.html?100px:100px"; | 3513 std::string url = m_baseURL + "specify_size.html?100px:100px"; |
| 3504 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); | 3514 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); |
| 3505 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 3515 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); |
| 3506 | 3516 |
| 3507 WebSize size = webView->contentsPreferredMinimumSize(); | 3517 WebSize size = webView->contentsPreferredMinimumSize(); |
| 3508 EXPECT_EQ(100, size.width); | 3518 EXPECT_EQ(100, size.width); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3589 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); | 3599 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); |
| 3590 URLTestHelpers::registerMockedURLFromBaseURL( | 3600 URLTestHelpers::registerMockedURLFromBaseURL( |
| 3591 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(testFile)); | 3601 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(testFile)); |
| 3592 UnhandledTapWebViewClient client; | 3602 UnhandledTapWebViewClient client; |
| 3593 WebView* webView = | 3603 WebView* webView = |
| 3594 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client); | 3604 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client); |
| 3595 webView->resize(WebSize(500, 300)); | 3605 webView->resize(WebSize(500, 300)); |
| 3596 webView->updateAllLifecyclePhases(); | 3606 webView->updateAllLifecyclePhases(); |
| 3597 runPendingTasks(); | 3607 runPendingTasks(); |
| 3598 | 3608 |
| 3599 // Scroll the bottom into view so we can distinguish window coordinates from d
ocument coordinates. | 3609 // Scroll the bottom into view so we can distinguish window coordinates from |
| 3610 // document coordinates. |
| 3600 EXPECT_TRUE( | 3611 EXPECT_TRUE( |
| 3601 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("bottom"))); | 3612 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("bottom"))); |
| 3602 EXPECT_TRUE(client.getWasCalled()); | 3613 EXPECT_TRUE(client.getWasCalled()); |
| 3603 EXPECT_EQ(64, client.getTappedXPos()); | 3614 EXPECT_EQ(64, client.getTappedXPos()); |
| 3604 EXPECT_EQ(278, client.getTappedYPos()); | 3615 EXPECT_EQ(278, client.getTappedYPos()); |
| 3605 EXPECT_FALSE(client.isTappedNodeNull()); | 3616 EXPECT_FALSE(client.isTappedNodeNull()); |
| 3606 EXPECT_TRUE(client.getWebNode().isTextNode()); | 3617 EXPECT_TRUE(client.getWebNode().isTextNode()); |
| 3607 | 3618 |
| 3608 // Test basic tap handling and notification. | 3619 // Test basic tap handling and notification. |
| 3609 client.reset(); | 3620 client.reset(); |
| 3610 EXPECT_TRUE( | 3621 EXPECT_TRUE( |
| 3611 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); | 3622 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); |
| 3612 EXPECT_TRUE(client.getWasCalled()); | 3623 EXPECT_TRUE(client.getWasCalled()); |
| 3613 EXPECT_EQ(144, client.getTappedXPos()); | 3624 EXPECT_EQ(144, client.getTappedXPos()); |
| 3614 EXPECT_EQ(82, client.getTappedYPos()); | 3625 EXPECT_EQ(82, client.getTappedYPos()); |
| 3615 EXPECT_FALSE(client.isTappedNodeNull()); | 3626 EXPECT_FALSE(client.isTappedNodeNull()); |
| 3616 EXPECT_TRUE(client.getWebNode().isTextNode()); | 3627 EXPECT_TRUE(client.getWebNode().isTextNode()); |
| 3617 // Make sure the returned text node has the parent element that was our target
. | 3628 // Make sure the returned text node has the parent element that was our |
| 3629 // target. |
| 3618 EXPECT_EQ(webView->mainFrame()->document().getElementById("target"), | 3630 EXPECT_EQ(webView->mainFrame()->document().getElementById("target"), |
| 3619 client.getWebNode().parentNode()); | 3631 client.getWebNode().parentNode()); |
| 3620 | 3632 |
| 3621 // Test correct conversion of coordinates to viewport space under pinch-zoom. | 3633 // Test correct conversion of coordinates to viewport space under pinch-zoom. |
| 3622 webView->setPageScaleFactor(2); | 3634 webView->setPageScaleFactor(2); |
| 3623 webView->setVisualViewportOffset(WebFloatPoint(50, 20)); | 3635 webView->setVisualViewportOffset(WebFloatPoint(50, 20)); |
| 3624 client.reset(); | 3636 client.reset(); |
| 3625 EXPECT_TRUE( | 3637 EXPECT_TRUE( |
| 3626 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); | 3638 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); |
| 3627 EXPECT_TRUE(client.getWasCalled()); | 3639 EXPECT_TRUE(client.getWasCalled()); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4060 .translate(-50, -55) | 4072 .translate(-50, -55) |
| 4061 .translate(50, 55) | 4073 .translate(50, 55) |
| 4062 .scale(1. / 2.f); | 4074 .scale(1. / 2.f); |
| 4063 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting()); | 4075 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting()); |
| 4064 // visibleContentRect doesn't change. | 4076 // visibleContentRect doesn't change. |
| 4065 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4077 EXPECT_EQ(IntRect(50, 55, 50, 75), |
| 4066 *devToolsEmulator->visibleContentRectForPainting()); | 4078 *devToolsEmulator->visibleContentRectForPainting()); |
| 4067 } | 4079 } |
| 4068 | 4080 |
| 4069 } // namespace blink | 4081 } // namespace blink |
| OLD | NEW |