| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 // Set canvas background to red with alpha. | 433 // Set canvas background to red with alpha. |
| 434 SkBitmap bitmap; | 434 SkBitmap bitmap; |
| 435 bitmap.allocN32Pixels(kWidth, kHeight); | 435 bitmap.allocN32Pixels(kWidth, kHeight); |
| 436 SkCanvas canvas(bitmap); | 436 SkCanvas canvas(bitmap); |
| 437 canvas.clear(kAlphaRed); | 437 canvas.clear(kAlphaRed); |
| 438 | 438 |
| 439 SkPictureBuilder pictureBuilder(FloatRect(0, 0, kWidth, kHeight)); | 439 SkPictureBuilder pictureBuilder(FloatRect(0, 0, kWidth, kHeight)); |
| 440 | 440 |
| 441 // Paint the root of the main frame in the way that CompositedLayerMapping w
ould. | 441 // Paint the root of the main frame in the way that CompositedLayerMapping w
ould. |
| 442 FrameView* view = m_webViewHelper.webViewImpl()->mainFrameImpl()->frameView(
); | 442 FrameView* view = m_webViewHelper.webView()->mainFrameImpl()->frameView(); |
| 443 PaintLayer* rootLayer = view->layoutViewItem().layer(); | 443 PaintLayer* rootLayer = view->layoutViewItem().layer(); |
| 444 LayoutRect paintRect(0, 0, kWidth, kHeight); | 444 LayoutRect paintRect(0, 0, kWidth, kHeight); |
| 445 PaintLayerPaintingInfo paintingInfo(rootLayer, paintRect, GlobalPaintNormalP
hase, LayoutSize()); | 445 PaintLayerPaintingInfo paintingInfo(rootLayer, paintRect, GlobalPaintNormalP
hase, LayoutSize()); |
| 446 PaintLayerPainter(*rootLayer).paintLayerContents(pictureBuilder.context(), p
aintingInfo, PaintLayerPaintingCompositingAllPhases); | 446 PaintLayerPainter(*rootLayer).paintLayerContents(pictureBuilder.context(), p
aintingInfo, PaintLayerPaintingCompositingAllPhases); |
| 447 | 447 |
| 448 pictureBuilder.endRecording()->playback(&canvas); | 448 pictureBuilder.endRecording()->playback(&canvas); |
| 449 | 449 |
| 450 // The result should be a blend of red and green. | 450 // The result should be a blend of red and green. |
| 451 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); | 451 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); |
| 452 EXPECT_TRUE(redChannel(color)); | 452 EXPECT_TRUE(redChannel(color)); |
| 453 EXPECT_TRUE(greenChannel(color)); | 453 EXPECT_TRUE(greenChannel(color)); |
| 454 } | 454 } |
| 455 | 455 |
| 456 TEST_F(WebViewTest, FocusIsInactive) | 456 TEST_F(WebViewTest, FocusIsInactive) |
| 457 { | 457 { |
| 458 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "visible_iframe.html"); | 458 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "visible_iframe.html"); |
| 459 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if
rame.html"); | 459 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visibl
e_iframe.html"); |
| 460 | 460 |
| 461 webView->setFocus(true); | 461 webView->setFocus(true); |
| 462 webView->setIsActive(true); | 462 webView->setIsActive(true); |
| 463 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 463 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 464 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 464 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
| 465 | 465 |
| 466 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); | 466 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); |
| 467 EXPECT_TRUE(document->hasFocus()); | 467 EXPECT_TRUE(document->hasFocus()); |
| 468 webView->setFocus(false); | 468 webView->setFocus(false); |
| 469 webView->setIsActive(false); | 469 webView->setIsActive(false); |
| 470 EXPECT_FALSE(document->hasFocus()); | 470 EXPECT_FALSE(document->hasFocus()); |
| 471 webView->setFocus(true); | 471 webView->setFocus(true); |
| 472 webView->setIsActive(true); | 472 webView->setIsActive(true); |
| 473 EXPECT_TRUE(document->hasFocus()); | 473 EXPECT_TRUE(document->hasFocus()); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 } | 598 } |
| 599 | 599 |
| 600 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
xAutoResize, | 600 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
xAutoResize, |
| 601 const std::string& pageWidth, const std::string
& pageHeight, | 601 const std::string& pageWidth, const std::string
& pageHeight, |
| 602 int expectedWidth, int expectedHeight, | 602 int expectedWidth, int expectedHeight, |
| 603 HorizontalScrollbarState expectedHorizontalStat
e, VerticalScrollbarState expectedVerticalState) | 603 HorizontalScrollbarState expectedHorizontalStat
e, VerticalScrollbarState expectedVerticalState) |
| 604 { | 604 { |
| 605 AutoResizeWebViewClient client; | 605 AutoResizeWebViewClient client; |
| 606 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageH
eight; | 606 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageH
eight; |
| 607 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); | 607 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); |
| 608 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); | 608 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &clie
nt); |
| 609 client.testData().setWebView(webView); | 609 client.testData().setWebView(webView); |
| 610 | 610 |
| 611 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 611 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 612 FrameView* frameView = frame->frame()->view(); | 612 FrameView* frameView = frame->frame()->view(); |
| 613 frameView->layout(); | 613 frameView->layout(); |
| 614 EXPECT_FALSE(frameView->layoutPending()); | 614 EXPECT_FALSE(frameView->layoutPending()); |
| 615 EXPECT_FALSE(frameView->needsLayout()); | 615 EXPECT_FALSE(frameView->needsLayout()); |
| 616 | 616 |
| 617 webView->enableAutoResizeMode(minAutoResize, maxAutoResize); | 617 webView->enableAutoResizeMode(minAutoResize, maxAutoResize); |
| 618 EXPECT_TRUE(frameView->layoutPending()); | 618 EXPECT_TRUE(frameView->layoutPending()); |
| 619 EXPECT_TRUE(frameView->needsLayout()); | 619 EXPECT_TRUE(frameView->needsLayout()); |
| 620 frameView->layout(); | 620 frameView->layout(); |
| 621 | 621 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 WebView* webView = m_webViewHelper.initializeAndLoad(url); | 759 WebView* webView = m_webViewHelper.initializeAndLoad(url); |
| 760 webView->setInitialFocus(false); | 760 webView->setInitialFocus(false); |
| 761 WebTextInputInfo info = webView->textInputInfo(); | 761 WebTextInputInfo info = webView->textInputInfo(); |
| 762 | 762 |
| 763 EXPECT_EQ("foo\xef\xbf\xbc", info.value.utf8()); | 763 EXPECT_EQ("foo\xef\xbf\xbc", info.value.utf8()); |
| 764 } | 764 } |
| 765 | 765 |
| 766 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) | 766 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) |
| 767 { | 767 { |
| 768 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 768 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 769 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 769 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 770 webView->setInitialFocus(false); | 770 webView->setInitialFocus(false); |
| 771 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 771 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 772 frame->setEditableSelectionOffsets(5, 13); | 772 frame->setEditableSelectionOffsets(5, 13); |
| 773 EXPECT_EQ("56789abc", frame->selectionAsText()); | 773 EXPECT_EQ("56789abc", frame->selectionAsText()); |
| 774 WebTextInputInfo info = webView->textInputInfo(); | 774 WebTextInputInfo info = webView->textInputInfo(); |
| 775 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 775 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 776 EXPECT_EQ(5, info.selectionStart); | 776 EXPECT_EQ(5, info.selectionStart); |
| 777 EXPECT_EQ(13, info.selectionEnd); | 777 EXPECT_EQ(13, info.selectionEnd); |
| 778 EXPECT_EQ(-1, info.compositionStart); | 778 EXPECT_EQ(-1, info.compositionStart); |
| 779 EXPECT_EQ(-1, info.compositionEnd); | 779 EXPECT_EQ(-1, info.compositionEnd); |
| 780 | 780 |
| 781 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); | 781 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); |
| 782 webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_po
pulated.html"); | 782 webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_po
pulated.html"); |
| 783 webView->setInitialFocus(false); | 783 webView->setInitialFocus(false); |
| 784 frame = toWebLocalFrameImpl(webView->mainFrame()); | 784 frame = webView->mainFrameImpl(); |
| 785 frame->setEditableSelectionOffsets(8, 19); | 785 frame->setEditableSelectionOffsets(8, 19); |
| 786 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); | 786 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); |
| 787 info = webView->textInputInfo(); | 787 info = webView->textInputInfo(); |
| 788 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 788 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 789 EXPECT_EQ(8, info.selectionStart); | 789 EXPECT_EQ(8, info.selectionStart); |
| 790 EXPECT_EQ(19, info.selectionEnd); | 790 EXPECT_EQ(19, info.selectionEnd); |
| 791 EXPECT_EQ(-1, info.compositionStart); | 791 EXPECT_EQ(-1, info.compositionStart); |
| 792 EXPECT_EQ(-1, info.compositionEnd); | 792 EXPECT_EQ(-1, info.compositionEnd); |
| 793 } | 793 } |
| 794 | 794 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 { | 838 { |
| 839 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form_with_input.html")); | 839 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form_with_input.html")); |
| 840 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form_w
ith_input.html"); | 840 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form_w
ith_input.html"); |
| 841 webView->resize(WebSize(800, 600)); | 841 webView->resize(WebSize(800, 600)); |
| 842 webView->setInitialFocus(false); | 842 webView->setInitialFocus(false); |
| 843 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 843 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 844 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().height); | 844 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().height); |
| 845 | 845 |
| 846 // Set up a composition from existing text that needs to be committed. | 846 // Set up a composition from existing text that needs to be committed. |
| 847 Vector<CompositionUnderline> emptyUnderlines; | 847 Vector<CompositionUnderline> emptyUnderlines; |
| 848 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 848 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 849 frame->frame()->inputMethodController().setCompositionFromExistingText(empty
Underlines, 3, 3); | 849 frame->frame()->inputMethodController().setCompositionFromExistingText(empty
Underlines, 3, 3); |
| 850 | 850 |
| 851 // Scroll the input field out of the viewport. | 851 // Scroll the input field out of the viewport. |
| 852 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge
tElementById("btn")); | 852 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge
tElementById("btn")); |
| 853 element->scrollIntoView(); | 853 element->scrollIntoView(); |
| 854 float offsetHeight = webView->mainFrame()->scrollOffset().height; | 854 float offsetHeight = webView->mainFrame()->scrollOffset().height; |
| 855 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 855 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 856 EXPECT_LT(0, offsetHeight); | 856 EXPECT_LT(0, offsetHeight); |
| 857 | 857 |
| 858 WebTextInputInfo info = webView->textInputInfo(); | 858 WebTextInputInfo info = webView->textInputInfo(); |
| 859 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 859 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 860 | 860 |
| 861 // Verify that the input field is not scrolled back into the viewport. | 861 // Verify that the input field is not scrolled back into the viewport. |
| 862 webView->confirmComposition(WebWidget::DoNotKeepSelection); | 862 webView->confirmComposition(WebWidget::DoNotKeepSelection); |
| 863 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 863 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 864 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); | 864 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); |
| 865 } | 865 } |
| 866 | 866 |
| 867 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) | 867 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) |
| 868 { | 868 { |
| 869 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 869 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 870 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); | 870 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 871 webView->setInitialFocus(false); | 871 webView->setInitialFocus(false); |
| 872 | 872 |
| 873 WebVector<WebCompositionUnderline> emptyUnderlines; | 873 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 874 | 874 |
| 875 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 875 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 876 frame->setEditableSelectionOffsets(4, 4); | 876 frame->setEditableSelectionOffsets(4, 4); |
| 877 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 877 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 878 | 878 |
| 879 WebTextInputInfo info = webView->textInputInfo(); | 879 WebTextInputInfo info = webView->textInputInfo(); |
| 880 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); | 880 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); |
| 881 EXPECT_EQ(4, info.selectionStart); | 881 EXPECT_EQ(4, info.selectionStart); |
| 882 EXPECT_EQ(4, info.selectionEnd); | 882 EXPECT_EQ(4, info.selectionEnd); |
| 883 EXPECT_EQ(8, info.compositionStart); | 883 EXPECT_EQ(8, info.compositionStart); |
| 884 EXPECT_EQ(12, info.compositionEnd); | 884 EXPECT_EQ(12, info.compositionEnd); |
| 885 | 885 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 896 EXPECT_EQ(5, info.selectionStart); | 896 EXPECT_EQ(5, info.selectionStart); |
| 897 EXPECT_EQ(5, info.selectionEnd); | 897 EXPECT_EQ(5, info.selectionEnd); |
| 898 EXPECT_EQ(-1, info.compositionStart); | 898 EXPECT_EQ(-1, info.compositionStart); |
| 899 EXPECT_EQ(-1, info.compositionEnd); | 899 EXPECT_EQ(-1, info.compositionEnd); |
| 900 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); | 900 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 901 } | 901 } |
| 902 | 902 |
| 903 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 903 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
| 904 { | 904 { |
| 905 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 905 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 906 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 906 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 907 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 907 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 908 webView->setInitialFocus(false); | 908 webView->setInitialFocus(false); |
| 909 frame->setEditableSelectionOffsets(10, 10); | 909 frame->setEditableSelectionOffsets(10, 10); |
| 910 frame->extendSelectionAndDelete(5, 8); | 910 frame->extendSelectionAndDelete(5, 8); |
| 911 WebTextInputInfo info = webView->textInputInfo(); | 911 WebTextInputInfo info = webView->textInputInfo(); |
| 912 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 912 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 913 EXPECT_EQ(5, info.selectionStart); | 913 EXPECT_EQ(5, info.selectionStart); |
| 914 EXPECT_EQ(5, info.selectionEnd); | 914 EXPECT_EQ(5, info.selectionEnd); |
| 915 frame->extendSelectionAndDelete(10, 0); | 915 frame->extendSelectionAndDelete(10, 0); |
| 916 info = webView->textInputInfo(); | 916 info = webView->textInputInfo(); |
| 917 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 917 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 918 } | 918 } |
| 919 | 919 |
| 920 TEST_F(WebViewTest, SetCompositionFromExistingText) | 920 TEST_F(WebViewTest, SetCompositionFromExistingText) |
| 921 { | 921 { |
| 922 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 922 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 923 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 923 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 924 webView->setInitialFocus(false); | 924 webView->setInitialFocus(false); |
| 925 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 925 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 926 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 926 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 927 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 927 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 928 frame->setEditableSelectionOffsets(4, 10); | 928 frame->setEditableSelectionOffsets(4, 10); |
| 929 frame->setCompositionFromExistingText(8, 12, underlines); | 929 frame->setCompositionFromExistingText(8, 12, underlines); |
| 930 WebTextInputInfo info = webView->textInputInfo(); | 930 WebTextInputInfo info = webView->textInputInfo(); |
| 931 EXPECT_EQ(4, info.selectionStart); | 931 EXPECT_EQ(4, info.selectionStart); |
| 932 EXPECT_EQ(10, info.selectionEnd); | 932 EXPECT_EQ(10, info.selectionEnd); |
| 933 EXPECT_EQ(8, info.compositionStart); | 933 EXPECT_EQ(8, info.compositionStart); |
| 934 EXPECT_EQ(12, info.compositionEnd); | 934 EXPECT_EQ(12, info.compositionEnd); |
| 935 WebVector<WebCompositionUnderline> emptyUnderlines; | 935 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 936 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); | 936 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); |
| 937 info = webView->textInputInfo(); | 937 info = webView->textInputInfo(); |
| 938 EXPECT_EQ(4, info.selectionStart); | 938 EXPECT_EQ(4, info.selectionStart); |
| 939 EXPECT_EQ(10, info.selectionEnd); | 939 EXPECT_EQ(10, info.selectionEnd); |
| 940 EXPECT_EQ(-1, info.compositionStart); | 940 EXPECT_EQ(-1, info.compositionStart); |
| 941 EXPECT_EQ(-1, info.compositionEnd); | 941 EXPECT_EQ(-1, info.compositionEnd); |
| 942 } | 942 } |
| 943 | 943 |
| 944 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 944 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 945 { | 945 { |
| 946 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 946 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 947 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); | 947 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 948 webView->setInitialFocus(false); | 948 webView->setInitialFocus(false); |
| 949 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 949 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 950 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 950 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 951 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 951 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 952 frame->setEditableSelectionOffsets(27, 27); | 952 frame->setEditableSelectionOffsets(27, 27); |
| 953 std::string newLineText("\n"); | 953 std::string newLineText("\n"); |
| 954 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 954 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); |
| 955 WebTextInputInfo info = webView->textInputInfo(); | 955 WebTextInputInfo info = webView->textInputInfo(); |
| 956 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 956 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 957 | 957 |
| 958 frame->setEditableSelectionOffsets(31, 31); | 958 frame->setEditableSelectionOffsets(31, 31); |
| 959 frame->setCompositionFromExistingText(30, 34, underlines); | 959 frame->setCompositionFromExistingText(30, 34, underlines); |
| 960 info = webView->textInputInfo(); | 960 info = webView->textInputInfo(); |
| 961 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 961 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 962 EXPECT_EQ(31, info.selectionStart); | 962 EXPECT_EQ(31, info.selectionStart); |
| 963 EXPECT_EQ(31, info.selectionEnd); | 963 EXPECT_EQ(31, info.selectionEnd); |
| 964 EXPECT_EQ(30, info.compositionStart); | 964 EXPECT_EQ(30, info.compositionStart); |
| 965 EXPECT_EQ(34, info.compositionEnd); | 965 EXPECT_EQ(34, info.compositionEnd); |
| 966 | 966 |
| 967 std::string compositionText("yolo"); | 967 std::string compositionText("yolo"); |
| 968 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 968 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); |
| 969 info = webView->textInputInfo(); | 969 info = webView->textInputInfo(); |
| 970 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); | 970 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); |
| 971 EXPECT_EQ(34, info.selectionStart); | 971 EXPECT_EQ(34, info.selectionStart); |
| 972 EXPECT_EQ(34, info.selectionEnd); | 972 EXPECT_EQ(34, info.selectionEnd); |
| 973 EXPECT_EQ(-1, info.compositionStart); | 973 EXPECT_EQ(-1, info.compositionStart); |
| 974 EXPECT_EQ(-1, info.compositionEnd); | 974 EXPECT_EQ(-1, info.compositionEnd); |
| 975 } | 975 } |
| 976 | 976 |
| 977 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) | 977 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
| 978 { | 978 { |
| 979 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_rich_text.html")); | 979 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_rich_text.html")); |
| 980 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_ed
itable_rich_text.html"); | 980 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "conten
t_editable_rich_text.html"); |
| 981 webView->setInitialFocus(false); | 981 webView->setInitialFocus(false); |
| 982 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 982 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 983 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 983 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 984 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 984 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 985 frame->setEditableSelectionOffsets(1, 1); | 985 frame->setEditableSelectionOffsets(1, 1); |
| 986 WebDocument document = webView->mainFrame()->document(); | 986 WebDocument document = webView->mainFrame()->document(); |
| 987 EXPECT_FALSE(document.getElementById("bold").isNull()); | 987 EXPECT_FALSE(document.getElementById("bold").isNull()); |
| 988 frame->setCompositionFromExistingText(0, 4, underlines); | 988 frame->setCompositionFromExistingText(0, 4, underlines); |
| 989 EXPECT_FALSE(document.getElementById("bold").isNull()); | 989 EXPECT_FALSE(document.getElementById("bold").isNull()); |
| 990 } | 990 } |
| 991 | 991 |
| 992 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 992 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
| 993 { | 993 { |
| 994 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 994 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 995 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 995 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 996 webView->setInitialFocus(false); | 996 webView->setInitialFocus(false); |
| 997 | 997 |
| 998 std::string compositionTextFirst("hello "); | 998 std::string compositionTextFirst("hello "); |
| 999 std::string compositionTextSecond("world"); | 999 std::string compositionTextSecond("world"); |
| 1000 WebVector<WebCompositionUnderline> emptyUnderlines; | 1000 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1001 | 1001 |
| 1002 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
)); | 1002 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
)); |
| 1003 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); | 1003 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); |
| 1004 | 1004 |
| 1005 WebTextInputInfo info = webView->textInputInfo(); | 1005 WebTextInputInfo info = webView->textInputInfo(); |
| 1006 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1006 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1007 EXPECT_EQ(11, info.selectionStart); | 1007 EXPECT_EQ(11, info.selectionStart); |
| 1008 EXPECT_EQ(11, info.selectionEnd); | 1008 EXPECT_EQ(11, info.selectionEnd); |
| 1009 EXPECT_EQ(6, info.compositionStart); | 1009 EXPECT_EQ(6, info.compositionStart); |
| 1010 EXPECT_EQ(11, info.compositionEnd); | 1010 EXPECT_EQ(11, info.compositionEnd); |
| 1011 | 1011 |
| 1012 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1012 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1013 frame->setEditableSelectionOffsets(6, 6); | 1013 frame->setEditableSelectionOffsets(6, 6); |
| 1014 info = webView->textInputInfo(); | 1014 info = webView->textInputInfo(); |
| 1015 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1015 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1016 EXPECT_EQ(6, info.selectionStart); | 1016 EXPECT_EQ(6, info.selectionStart); |
| 1017 EXPECT_EQ(6, info.selectionEnd); | 1017 EXPECT_EQ(6, info.selectionEnd); |
| 1018 EXPECT_EQ(6, info.compositionStart); | 1018 EXPECT_EQ(6, info.compositionStart); |
| 1019 EXPECT_EQ(11, info.compositionEnd); | 1019 EXPECT_EQ(11, info.compositionEnd); |
| 1020 | 1020 |
| 1021 frame->setEditableSelectionOffsets(8, 8); | 1021 frame->setEditableSelectionOffsets(8, 8); |
| 1022 info = webView->textInputInfo(); | 1022 info = webView->textInputInfo(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1047 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1047 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1048 EXPECT_EQ(2, info.selectionStart); | 1048 EXPECT_EQ(2, info.selectionStart); |
| 1049 EXPECT_EQ(2, info.selectionEnd); | 1049 EXPECT_EQ(2, info.selectionEnd); |
| 1050 EXPECT_EQ(-1, info.compositionStart); | 1050 EXPECT_EQ(-1, info.compositionStart); |
| 1051 EXPECT_EQ(-1, info.compositionEnd); | 1051 EXPECT_EQ(-1, info.compositionEnd); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 TEST_F(WebViewTest, IsSelectionAnchorFirst) | 1054 TEST_F(WebViewTest, IsSelectionAnchorFirst) |
| 1055 { | 1055 { |
| 1056 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1056 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1057 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 1057 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 1058 WebLocalFrame* frame = webView->mainFrame()->toWebLocalFrame(); | 1058 WebLocalFrame* frame = webView->mainFrameImpl(); |
| 1059 | 1059 |
| 1060 webView->setInitialFocus(false); | 1060 webView->setInitialFocus(false); |
| 1061 frame->setEditableSelectionOffsets(4, 10); | 1061 frame->setEditableSelectionOffsets(4, 10); |
| 1062 EXPECT_TRUE(webView->isSelectionAnchorFirst()); | 1062 EXPECT_TRUE(webView->isSelectionAnchorFirst()); |
| 1063 WebRect anchor; | 1063 WebRect anchor; |
| 1064 WebRect focus; | 1064 WebRect focus; |
| 1065 webView->selectionBounds(anchor, focus); | 1065 webView->selectionBounds(anchor, focus); |
| 1066 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y))
; | 1066 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y))
; |
| 1067 EXPECT_FALSE(webView->isSelectionAnchorFirst()); | 1067 EXPECT_FALSE(webView->isSelectionAnchorFirst()); |
| 1068 } | 1068 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 | 1414 |
| 1415 bool WebViewTest::tapElement(WebInputEvent::Type type, Element* element) | 1415 bool WebViewTest::tapElement(WebInputEvent::Type type, Element* element) |
| 1416 { | 1416 { |
| 1417 if (!element || !element->layoutObject()) | 1417 if (!element || !element->layoutObject()) |
| 1418 return false; | 1418 return false; |
| 1419 | 1419 |
| 1420 DCHECK(m_webViewHelper.webView()); | 1420 DCHECK(m_webViewHelper.webView()); |
| 1421 element->scrollIntoViewIfNeeded(); | 1421 element->scrollIntoViewIfNeeded(); |
| 1422 | 1422 |
| 1423 // TODO(bokan): Technically incorrect, event positions should be in viewport
space. crbug.com/371902. | 1423 // TODO(bokan): Technically incorrect, event positions should be in viewport
space. crbug.com/371902. |
| 1424 IntPoint center = m_webViewHelper.webViewImpl()->mainFrameImpl()->frameView(
)->contentsToScreen( | 1424 IntPoint center = m_webViewHelper.webView()->mainFrameImpl()->frameView()->c
ontentsToScreen( |
| 1425 element->layoutObject()->absoluteBoundingBoxRect()).center(); | 1425 element->layoutObject()->absoluteBoundingBoxRect()).center(); |
| 1426 | 1426 |
| 1427 WebGestureEvent event; | 1427 WebGestureEvent event; |
| 1428 event.type = type; | 1428 event.type = type; |
| 1429 event.sourceDevice = WebGestureDeviceTouchscreen; | 1429 event.sourceDevice = WebGestureDeviceTouchscreen; |
| 1430 event.x = center.x(); | 1430 event.x = center.x(); |
| 1431 event.y = center.y(); | 1431 event.y = center.y(); |
| 1432 | 1432 |
| 1433 m_webViewHelper.webView()->handleInputEvent(event); | 1433 m_webViewHelper.webView()->handleInputEvent(event); |
| 1434 runPendingTasks(); | 1434 runPendingTasks(); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "long_p
ress_image.html", true); | 1735 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "long_p
ress_image.html", true); |
| 1736 webView->resize(WebSize(500, 500)); | 1736 webView->resize(WebSize(500, 500)); |
| 1737 webView->updateAllLifecyclePhases(); | 1737 webView->updateAllLifecyclePhases(); |
| 1738 runPendingTasks(); | 1738 runPendingTasks(); |
| 1739 | 1739 |
| 1740 WebGestureEvent event; | 1740 WebGestureEvent event; |
| 1741 event.type = WebInputEvent::GestureLongPress; | 1741 event.type = WebInputEvent::GestureLongPress; |
| 1742 event.sourceDevice = WebGestureDeviceTouchscreen; | 1742 event.sourceDevice = WebGestureDeviceTouchscreen; |
| 1743 event.x = 300; | 1743 event.x = 300; |
| 1744 event.y = 300; | 1744 event.y = 300; |
| 1745 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1745 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1746 | 1746 |
| 1747 EXPECT_EQ(WebInputEventResult::HandledSystem, webView->handleInputEvent(even
t)); | 1747 EXPECT_EQ(WebInputEventResult::HandledSystem, webView->handleInputEvent(even
t)); |
| 1748 EXPECT_TRUE(frame->selectionAsText().isEmpty()); | 1748 EXPECT_TRUE(frame->selectionAsText().isEmpty()); |
| 1749 } | 1749 } |
| 1750 | 1750 |
| 1751 TEST_F(WebViewTest, LongPressSelection) | 1751 TEST_F(WebViewTest, LongPressSelection) |
| 1752 { | 1752 { |
| 1753 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); | 1753 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); |
| 1754 | 1754 |
| 1755 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_
selection.html", true); | 1755 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpr
ess_selection.html", true); |
| 1756 webView->resize(WebSize(500, 300)); | 1756 webView->resize(WebSize(500, 300)); |
| 1757 webView->updateAllLifecyclePhases(); | 1757 webView->updateAllLifecyclePhases(); |
| 1758 runPendingTasks(); | 1758 runPendingTasks(); |
| 1759 | 1759 |
| 1760 WebString target = WebString::fromUTF8("target"); | 1760 WebString target = WebString::fromUTF8("target"); |
| 1761 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); | 1761 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); |
| 1762 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1762 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1763 | 1763 |
| 1764 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, onselectstartfal
se)); | 1764 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, onselectstartfal
se)); |
| 1765 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); | 1765 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); |
| 1766 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); | 1766 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); |
| 1767 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); | 1767 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); |
| 1768 } | 1768 } |
| 1769 | 1769 |
| 1770 #if !OS(MACOSX) | 1770 #if !OS(MACOSX) |
| 1771 TEST_F(WebViewTest, TouchDoesntSelectEmptyTextarea) | 1771 TEST_F(WebViewTest, TouchDoesntSelectEmptyTextarea) |
| 1772 { | 1772 { |
| 1773 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_textarea.html")); | 1773 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_textarea.html")); |
| 1774 | 1774 |
| 1775 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_
textarea.html", true); | 1775 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpr
ess_textarea.html", true); |
| 1776 webView->resize(WebSize(500, 300)); | 1776 webView->resize(WebSize(500, 300)); |
| 1777 webView->updateAllLifecyclePhases(); | 1777 webView->updateAllLifecyclePhases(); |
| 1778 runPendingTasks(); | 1778 runPendingTasks(); |
| 1779 | 1779 |
| 1780 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox"); | 1780 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox"); |
| 1781 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1781 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1782 | 1782 |
| 1783 // Long-press on carriage returns. | 1783 // Long-press on carriage returns. |
| 1784 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, blanklinestextbo
x)); | 1784 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, blanklinestextbo
x)); |
| 1785 EXPECT_TRUE(frame->selectionAsText().isEmpty()); | 1785 EXPECT_TRUE(frame->selectionAsText().isEmpty()); |
| 1786 | 1786 |
| 1787 // Double-tap on carriage returns. | 1787 // Double-tap on carriage returns. |
| 1788 WebGestureEvent event; | 1788 WebGestureEvent event; |
| 1789 event.type = WebInputEvent::GestureTap; | 1789 event.type = WebInputEvent::GestureTap; |
| 1790 event.sourceDevice = WebGestureDeviceTouchscreen; | 1790 event.sourceDevice = WebGestureDeviceTouchscreen; |
| 1791 event.x = 100; | 1791 event.x = 100; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1805 // Double-tap past last word of textbox. | 1805 // Double-tap past last word of textbox. |
| 1806 webView->handleInputEvent(event); | 1806 webView->handleInputEvent(event); |
| 1807 EXPECT_TRUE(frame->selectionAsText().isEmpty()); | 1807 EXPECT_TRUE(frame->selectionAsText().isEmpty()); |
| 1808 } | 1808 } |
| 1809 #endif | 1809 #endif |
| 1810 | 1810 |
| 1811 TEST_F(WebViewTest, LongPressImageTextarea) | 1811 TEST_F(WebViewTest, LongPressImageTextarea) |
| 1812 { | 1812 { |
| 1813 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_image_contenteditable.html")); | 1813 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_image_contenteditable.html")); |
| 1814 | 1814 |
| 1815 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_
image_contenteditable.html", true); | 1815 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpr
ess_image_contenteditable.html", true); |
| 1816 webView->resize(WebSize(500, 300)); | 1816 webView->resize(WebSize(500, 300)); |
| 1817 webView->updateAllLifecyclePhases(); | 1817 webView->updateAllLifecyclePhases(); |
| 1818 runPendingTasks(); | 1818 runPendingTasks(); |
| 1819 | 1819 |
| 1820 WebString image = WebString::fromUTF8("purpleimage"); | 1820 WebString image = WebString::fromUTF8("purpleimage"); |
| 1821 | 1821 |
| 1822 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, image)); | 1822 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, image)); |
| 1823 size_t location, length; | 1823 size_t location, length; |
| 1824 EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length
)); | 1824 EXPECT_TRUE(webView->caretOrSelectionRange(&location, &length)); |
| 1825 EXPECT_EQ(0UL, location); | 1825 EXPECT_EQ(0UL, location); |
| 1826 EXPECT_EQ(1UL, length); | 1826 EXPECT_EQ(1UL, length); |
| 1827 } | 1827 } |
| 1828 | 1828 |
| 1829 TEST_F(WebViewTest, BlinkCaretAfterLongPress) | 1829 TEST_F(WebViewTest, BlinkCaretAfterLongPress) |
| 1830 { | 1830 { |
| 1831 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html")); | 1831 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html")); |
| 1832 | 1832 |
| 1833 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care
t_on_typing_after_long_press.html", true); | 1833 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_
caret_on_typing_after_long_press.html", true); |
| 1834 webView->resize(WebSize(640, 480)); | 1834 webView->resize(WebSize(640, 480)); |
| 1835 webView->updateAllLifecyclePhases(); | 1835 webView->updateAllLifecyclePhases(); |
| 1836 runPendingTasks(); | 1836 runPendingTasks(); |
| 1837 | 1837 |
| 1838 WebString target = WebString::fromUTF8("target"); | 1838 WebString target = WebString::fromUTF8("target"); |
| 1839 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webView->mainFrame()); | 1839 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); |
| 1840 | 1840 |
| 1841 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); | 1841 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); |
| 1842 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); | 1842 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 TEST_F(WebViewTest, BlinkCaretOnClosingContextMenu) | 1845 TEST_F(WebViewTest, BlinkCaretOnClosingContextMenu) |
| 1846 { | 1846 { |
| 1847 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); | 1847 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); |
| 1848 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html"
, true); | 1848 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.h
tml", true); |
| 1849 | 1849 |
| 1850 webView->setInitialFocus(false); | 1850 webView->setInitialFocus(false); |
| 1851 runPendingTasks(); | 1851 runPendingTasks(); |
| 1852 | 1852 |
| 1853 // We suspend caret blinking when pressing with mouse right button. | 1853 // We suspend caret blinking when pressing with mouse right button. |
| 1854 // Note that we do not send MouseUp event here since it will be consumed | 1854 // Note that we do not send MouseUp event here since it will be consumed |
| 1855 // by the context menu once it shows up. | 1855 // by the context menu once it shows up. |
| 1856 WebMouseEvent mouseEvent; | 1856 WebMouseEvent mouseEvent; |
| 1857 mouseEvent.button = WebMouseEvent::ButtonRight; | 1857 mouseEvent.button = WebMouseEvent::ButtonRight; |
| 1858 mouseEvent.x = 1; | 1858 mouseEvent.x = 1; |
| 1859 mouseEvent.y = 1; | 1859 mouseEvent.y = 1; |
| 1860 mouseEvent.clickCount = 1; | 1860 mouseEvent.clickCount = 1; |
| 1861 mouseEvent.type = WebInputEvent::MouseDown; | 1861 mouseEvent.type = WebInputEvent::MouseDown; |
| 1862 webView->handleInputEvent(mouseEvent); | 1862 webView->handleInputEvent(mouseEvent); |
| 1863 runPendingTasks(); | 1863 runPendingTasks(); |
| 1864 | 1864 |
| 1865 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webView->mainFrame()); | 1865 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); |
| 1866 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); | 1866 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); |
| 1867 | 1867 |
| 1868 // Caret blinking is still suspended after showing context menu. | 1868 // Caret blinking is still suspended after showing context menu. |
| 1869 webView->showContextMenu(); | 1869 webView->showContextMenu(); |
| 1870 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); | 1870 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); |
| 1871 | 1871 |
| 1872 // Caret blinking will be resumed only after context menu is closed. | 1872 // Caret blinking will be resumed only after context menu is closed. |
| 1873 webView->didCloseContextMenu(); | 1873 webView->didCloseContextMenu(); |
| 1874 | 1874 |
| 1875 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); | 1875 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); |
| 1876 } | 1876 } |
| 1877 | 1877 |
| 1878 TEST_F(WebViewTest, SelectionOnReadOnlyInput) | 1878 TEST_F(WebViewTest, SelectionOnReadOnlyInput) |
| 1879 { | 1879 { |
| 1880 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("selection_readonly.html")); | 1880 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("selection_readonly.html")); |
| 1881 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "selection_
readonly.html", true); | 1881 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "select
ion_readonly.html", true); |
| 1882 webView->resize(WebSize(640, 480)); | 1882 webView->resize(WebSize(640, 480)); |
| 1883 webView->updateAllLifecyclePhases(); | 1883 webView->updateAllLifecyclePhases(); |
| 1884 runPendingTasks(); | 1884 runPendingTasks(); |
| 1885 | 1885 |
| 1886 std::string testWord = "This text should be selected."; | 1886 std::string testWord = "This text should be selected."; |
| 1887 | 1887 |
| 1888 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1888 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1889 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data())); | 1889 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data())); |
| 1890 | 1890 |
| 1891 size_t location; | 1891 size_t location; |
| 1892 size_t length; | 1892 size_t length; |
| 1893 EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length
)); | 1893 EXPECT_TRUE(webView->caretOrSelectionRange(&location, &length)); |
| 1894 EXPECT_EQ(location, 0UL); | 1894 EXPECT_EQ(location, 0UL); |
| 1895 EXPECT_EQ(length, testWord.length()); | 1895 EXPECT_EQ(length, testWord.length()); |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 static void configueCompositingWebView(WebSettings* settings) | 1898 static void configueCompositingWebView(WebSettings* settings) |
| 1899 { | 1899 { |
| 1900 settings->setAcceleratedCompositingEnabled(true); | 1900 settings->setAcceleratedCompositingEnabled(true); |
| 1901 settings->setPreferCompositingToLCDTextEnabled(true); | 1901 settings->setPreferCompositingToLCDTextEnabled(true); |
| 1902 } | 1902 } |
| 1903 | 1903 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 int m_textChangesWhileIgnored; | 1965 int m_textChangesWhileIgnored; |
| 1966 int m_textChangesWhileNotIgnored; | 1966 int m_textChangesWhileNotIgnored; |
| 1967 int m_userGestureNotificationsCount; | 1967 int m_userGestureNotificationsCount; |
| 1968 }; | 1968 }; |
| 1969 | 1969 |
| 1970 | 1970 |
| 1971 TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) | 1971 TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) |
| 1972 { | 1972 { |
| 1973 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1973 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1974 MockAutofillClient client; | 1974 MockAutofillClient client; |
| 1975 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 1975 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 1976 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1976 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1977 frame->setAutofillClient(&client); | 1977 frame->setAutofillClient(&client); |
| 1978 webView->setInitialFocus(false); | 1978 webView->setInitialFocus(false); |
| 1979 | 1979 |
| 1980 // Set up a composition that needs to be committed. | 1980 // Set up a composition that needs to be committed. |
| 1981 WebVector<WebCompositionUnderline> emptyUnderlines; | 1981 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1982 frame->setEditableSelectionOffsets(4, 10); | 1982 frame->setEditableSelectionOffsets(4, 10); |
| 1983 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1983 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 1984 WebTextInputInfo info = webView->textInputInfo(); | 1984 WebTextInputInfo info = webView->textInputInfo(); |
| 1985 EXPECT_EQ(4, info.selectionStart); | 1985 EXPECT_EQ(4, info.selectionStart); |
| 1986 EXPECT_EQ(10, info.selectionEnd); | 1986 EXPECT_EQ(10, info.selectionEnd); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2002 EXPECT_EQ(selectionStart, info.selectionStart) << failMessage; | 2002 EXPECT_EQ(selectionStart, info.selectionStart) << failMessage; |
| 2003 EXPECT_EQ(selectionEnd, info.selectionEnd) << failMessage; | 2003 EXPECT_EQ(selectionEnd, info.selectionEnd) << failMessage; |
| 2004 EXPECT_EQ(compositionStart, info.compositionStart) << failMessage; | 2004 EXPECT_EQ(compositionStart, info.compositionStart) << failMessage; |
| 2005 EXPECT_EQ(compositionEnd, info.compositionEnd) << failMessage; | 2005 EXPECT_EQ(compositionEnd, info.compositionEnd) << failMessage; |
| 2006 } | 2006 } |
| 2007 | 2007 |
| 2008 TEST_F(WebViewTest, CompositionNotCancelledByBackspace) | 2008 TEST_F(WebViewTest, CompositionNotCancelledByBackspace) |
| 2009 { | 2009 { |
| 2010 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("composition_not_cancelled_by_backspace.html")); | 2010 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("composition_not_cancelled_by_backspace.html")); |
| 2011 MockAutofillClient client; | 2011 MockAutofillClient client; |
| 2012 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "compositio
n_not_cancelled_by_backspace.html"); | 2012 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "compos
ition_not_cancelled_by_backspace.html"); |
| 2013 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2013 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2014 frame->setAutofillClient(&client); | 2014 frame->setAutofillClient(&client); |
| 2015 webView->setInitialFocus(false); | 2015 webView->setInitialFocus(false); |
| 2016 | 2016 |
| 2017 // Test both input elements. | 2017 // Test both input elements. |
| 2018 for (int i = 0; i < 2; ++i) { | 2018 for (int i = 0; i < 2; ++i) { |
| 2019 // Select composition and do sanity check. | 2019 // Select composition and do sanity check. |
| 2020 WebVector<WebCompositionUnderline> emptyUnderlines; | 2020 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2021 frame->setEditableSelectionOffsets(6, 6); | 2021 frame->setEditableSelectionOffsets(6, 6); |
| 2022 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); | 2022 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); |
| 2023 frame->setEditableSelectionOffsets(11, 11); | 2023 frame->setEditableSelectionOffsets(11, 11); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2042 webView->advanceFocus(false); | 2042 webView->advanceFocus(false); |
| 2043 } | 2043 } |
| 2044 | 2044 |
| 2045 frame->setAutofillClient(0); | 2045 frame->setAutofillClient(0); |
| 2046 } | 2046 } |
| 2047 | 2047 |
| 2048 TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange) | 2048 TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange) |
| 2049 { | 2049 { |
| 2050 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2050 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2051 MockAutofillClient client; | 2051 MockAutofillClient client; |
| 2052 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 2052 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 2053 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2053 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2054 frame->setAutofillClient(&client); | 2054 frame->setAutofillClient(&client); |
| 2055 webView->setInitialFocus(false); | 2055 webView->setInitialFocus(false); |
| 2056 | 2056 |
| 2057 // Set up a composition that needs to be committed. | 2057 // Set up a composition that needs to be committed. |
| 2058 std::string compositionText("testingtext"); | 2058 std::string compositionText("testingtext"); |
| 2059 | 2059 |
| 2060 WebVector<WebCompositionUnderline> emptyUnderlines; | 2060 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2061 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, compositionText.length()); | 2061 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, compositionText.length()); |
| 2062 | 2062 |
| 2063 WebTextInputInfo info = webView->textInputInfo(); | 2063 WebTextInputInfo info = webView->textInputInfo(); |
| 2064 EXPECT_EQ(0, info.selectionStart); | 2064 EXPECT_EQ(0, info.selectionStart); |
| 2065 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); | 2065 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); |
| 2066 EXPECT_EQ(0, info.compositionStart); | 2066 EXPECT_EQ(0, info.compositionStart); |
| 2067 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); | 2067 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); |
| 2068 | 2068 |
| 2069 client.clearChangeCounts(); | 2069 client.clearChangeCounts(); |
| 2070 webView->confirmComposition(); | 2070 webView->confirmComposition(); |
| 2071 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2071 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
| 2072 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2072 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
| 2073 | 2073 |
| 2074 frame->setAutofillClient(0); | 2074 frame->setAutofillClient(0); |
| 2075 } | 2075 } |
| 2076 | 2076 |
| 2077 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) | 2077 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) |
| 2078 { | 2078 { |
| 2079 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2079 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2080 MockAutofillClient client; | 2080 MockAutofillClient client; |
| 2081 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html", true); | 2081 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html", true); |
| 2082 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2082 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2083 frame->setAutofillClient(&client); | 2083 frame->setAutofillClient(&client); |
| 2084 webView->setInitialFocus(false); | 2084 webView->setInitialFocus(false); |
| 2085 | 2085 |
| 2086 WebVector<WebCompositionUnderline> emptyUnderlines; | 2086 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2087 | 2087 |
| 2088 client.clearChangeCounts(); | 2088 client.clearChangeCounts(); |
| 2089 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 2089 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 2090 | 2090 |
| 2091 WebTextInputInfo info = webView->textInputInfo(); | 2091 WebTextInputInfo info = webView->textInputInfo(); |
| 2092 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); | 2092 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 | 2148 |
| 2149 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2149 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 2150 } | 2150 } |
| 2151 | 2151 |
| 2152 TEST_F(WebViewTest, FocusExistingFrameOnNavigate) | 2152 TEST_F(WebViewTest, FocusExistingFrameOnNavigate) |
| 2153 { | 2153 { |
| 2154 ViewCreatingWebViewClient client; | 2154 ViewCreatingWebViewClient client; |
| 2155 FrameTestHelpers::WebViewHelper m_webViewHelper; | 2155 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 2156 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); | 2156 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); |
| 2157 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); | 2157 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); |
| 2158 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | 2158 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
| 2159 frame->setName("_start"); | 2159 frame->setName("_start"); |
| 2160 | 2160 |
| 2161 // Make a request that will open a new window | 2161 // Make a request that will open a new window |
| 2162 WebURLRequest webURLRequest; | 2162 WebURLRequest webURLRequest; |
| 2163 FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blank"); | 2163 FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blank"); |
| 2164 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); | 2164 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); |
| 2165 ASSERT_TRUE(client.createdWebView()); | 2165 ASSERT_TRUE(client.createdWebView()); |
| 2166 EXPECT_FALSE(client.didFocusCalled()); | 2166 EXPECT_FALSE(client.didFocusCalled()); |
| 2167 | 2167 |
| 2168 // Make a request from the new window that will navigate the original window
. The original window should be focused. | 2168 // Make a request from the new window that will navigate the original window
. The original window should be focused. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr
ue, &frameClient); | 2454 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr
ue, &frameClient); |
| 2455 m_webViewHelper.reset(); | 2455 m_webViewHelper.reset(); |
| 2456 EXPECT_EQ(0, frameClient.count()); | 2456 EXPECT_EQ(0, frameClient.count()); |
| 2457 } | 2457 } |
| 2458 | 2458 |
| 2459 TEST_F(WebViewTest, AddFrameInCloseURLUnload) | 2459 TEST_F(WebViewTest, AddFrameInCloseURLUnload) |
| 2460 { | 2460 { |
| 2461 CreateChildCounterFrameClient frameClient; | 2461 CreateChildCounterFrameClient frameClient; |
| 2462 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); | 2462 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); |
| 2463 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr
ue, &frameClient); | 2463 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr
ue, &frameClient); |
| 2464 m_webViewHelper.webViewImpl()->mainFrame()->dispatchUnloadEvent(); | 2464 m_webViewHelper.webView()->mainFrame()->dispatchUnloadEvent(); |
| 2465 EXPECT_EQ(0, frameClient.count()); | 2465 EXPECT_EQ(0, frameClient.count()); |
| 2466 m_webViewHelper.reset(); | 2466 m_webViewHelper.reset(); |
| 2467 } | 2467 } |
| 2468 | 2468 |
| 2469 TEST_F(WebViewTest, AddFrameInNavigateUnload) | 2469 TEST_F(WebViewTest, AddFrameInNavigateUnload) |
| 2470 { | 2470 { |
| 2471 CreateChildCounterFrameClient frameClient; | 2471 CreateChildCounterFrameClient frameClient; |
| 2472 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); | 2472 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); |
| 2473 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr
ue, &frameClient); | 2473 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr
ue, &frameClient); |
| 2474 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:b
lank"); | 2474 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:b
lank"); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 | 2689 |
| 2690 // This test verifies the text input flags are correctly exposed to script. | 2690 // This test verifies the text input flags are correctly exposed to script. |
| 2691 TEST_F(WebViewTest, TextInputFlags) | 2691 TEST_F(WebViewTest, TextInputFlags) |
| 2692 { | 2692 { |
| 2693 NonUserInputTextUpdateWebViewClient client; | 2693 NonUserInputTextUpdateWebViewClient client; |
| 2694 std::string url = m_baseURL + "text_input_flags.html"; | 2694 std::string url = m_baseURL + "text_input_flags.html"; |
| 2695 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html"); | 2695 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html"); |
| 2696 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); | 2696 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); |
| 2697 webViewImpl->setInitialFocus(false); | 2697 webViewImpl->setInitialFocus(false); |
| 2698 | 2698 |
| 2699 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | 2699 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
| 2700 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); | 2700 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); |
| 2701 | 2701 |
| 2702 // (A) <input> | 2702 // (A) <input> |
| 2703 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and | 2703 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and |
| 2704 // autocapitalize is set to none. | 2704 // autocapitalize is set to none. |
| 2705 HTMLInputElement* inputElement = toHTMLInputElement(document->getElementById
("input")); | 2705 HTMLInputElement* inputElement = toHTMLInputElement(document->getElementById
("input")); |
| 2706 document->setFocusedElement(inputElement, FocusParams(SelectionBehaviorOnFoc
us::None, WebFocusTypeNone, nullptr)); | 2706 document->setFocusedElement(inputElement, FocusParams(SelectionBehaviorOnFoc
us::None, WebFocusTypeNone, nullptr)); |
| 2707 webViewImpl->setFocus(true); | 2707 webViewImpl->setFocus(true); |
| 2708 WebTextInputInfo info1 = webViewImpl->textInputInfo(); | 2708 WebTextInputInfo info1 = webViewImpl->textInputInfo(); |
| 2709 EXPECT_EQ( | 2709 EXPECT_EQ( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2739 // This test verifies that WebWidgetClient::didUpdateTextOfFocusedElementByNonUs
erInput is | 2739 // This test verifies that WebWidgetClient::didUpdateTextOfFocusedElementByNonUs
erInput is |
| 2740 // called iff value of a focused element is modified via script. | 2740 // called iff value of a focused element is modified via script. |
| 2741 TEST_F(WebViewTest, NonUserInputTextUpdate) | 2741 TEST_F(WebViewTest, NonUserInputTextUpdate) |
| 2742 { | 2742 { |
| 2743 NonUserInputTextUpdateWebViewClient client; | 2743 NonUserInputTextUpdateWebViewClient client; |
| 2744 std::string url = m_baseURL + "non_user_input_text_update.html"; | 2744 std::string url = m_baseURL + "non_user_input_text_update.html"; |
| 2745 URLTestHelpers::registerMockedURLLoad(toKURL(url), "non_user_input_text_upda
te.html"); | 2745 URLTestHelpers::registerMockedURLLoad(toKURL(url), "non_user_input_text_upda
te.html"); |
| 2746 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); | 2746 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &
client); |
| 2747 webViewImpl->setInitialFocus(false); | 2747 webViewImpl->setInitialFocus(false); |
| 2748 | 2748 |
| 2749 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | 2749 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
| 2750 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); | 2750 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); |
| 2751 | 2751 |
| 2752 // (A) <input> | 2752 // (A) <input> |
| 2753 // (A.1) Focused and value is changed by script. | 2753 // (A.1) Focused and value is changed by script. |
| 2754 client.reset(); | 2754 client.reset(); |
| 2755 EXPECT_FALSE(client.textIsUpdated()); | 2755 EXPECT_FALSE(client.textIsUpdated()); |
| 2756 | 2756 |
| 2757 HTMLInputElement* inputElement = toHTMLInputElement(document->getElementById
("input")); | 2757 HTMLInputElement* inputElement = toHTMLInputElement(document->getElementById
("input")); |
| 2758 document->setFocusedElement(inputElement, FocusParams(SelectionBehaviorOnFoc
us::None, WebFocusTypeNone, nullptr)); | 2758 document->setFocusedElement(inputElement, FocusParams(SelectionBehaviorOnFoc
us::None, WebFocusTypeNone, nullptr)); |
| 2759 webViewImpl->setFocus(true); | 2759 webViewImpl->setFocus(true); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. | 2818 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. |
| 2819 m_webViewHelper.reset(); | 2819 m_webViewHelper.reset(); |
| 2820 } | 2820 } |
| 2821 | 2821 |
| 2822 // Check that the WebAutofillClient is correctly notified about first user | 2822 // Check that the WebAutofillClient is correctly notified about first user |
| 2823 // gestures after load, following various input events. | 2823 // gestures after load, following various input events. |
| 2824 TEST_F(WebViewTest, FirstUserGestureObservedKeyEvent) | 2824 TEST_F(WebViewTest, FirstUserGestureObservedKeyEvent) |
| 2825 { | 2825 { |
| 2826 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); | 2826 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); |
| 2827 MockAutofillClient client; | 2827 MockAutofillClient client; |
| 2828 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html"
, true); | 2828 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.h
tml", true); |
| 2829 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2829 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2830 frame->setAutofillClient(&client); | 2830 frame->setAutofillClient(&client); |
| 2831 webView->setInitialFocus(false); | 2831 webView->setInitialFocus(false); |
| 2832 | 2832 |
| 2833 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 2833 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
| 2834 | 2834 |
| 2835 WebKeyboardEvent keyEvent; | 2835 WebKeyboardEvent keyEvent; |
| 2836 keyEvent.domKey = Platform::current()->domKeyEnumFromString(" "); | 2836 keyEvent.domKey = Platform::current()->domKeyEnumFromString(" "); |
| 2837 keyEvent.windowsKeyCode = VKEY_SPACE; | 2837 keyEvent.windowsKeyCode = VKEY_SPACE; |
| 2838 keyEvent.type = WebInputEvent::RawKeyDown; | 2838 keyEvent.type = WebInputEvent::RawKeyDown; |
| 2839 webView->handleInputEvent(keyEvent); | 2839 webView->handleInputEvent(keyEvent); |
| 2840 keyEvent.type = WebInputEvent::KeyUp; | 2840 keyEvent.type = WebInputEvent::KeyUp; |
| 2841 webView->handleInputEvent(keyEvent); | 2841 webView->handleInputEvent(keyEvent); |
| 2842 | 2842 |
| 2843 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2843 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
| 2844 frame->setAutofillClient(0); | 2844 frame->setAutofillClient(0); |
| 2845 } | 2845 } |
| 2846 | 2846 |
| 2847 TEST_F(WebViewTest, FirstUserGestureObservedMouseEvent) | 2847 TEST_F(WebViewTest, FirstUserGestureObservedMouseEvent) |
| 2848 { | 2848 { |
| 2849 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); | 2849 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form.html")); |
| 2850 MockAutofillClient client; | 2850 MockAutofillClient client; |
| 2851 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html"
, true); | 2851 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.h
tml", true); |
| 2852 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2852 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2853 frame->setAutofillClient(&client); | 2853 frame->setAutofillClient(&client); |
| 2854 webView->setInitialFocus(false); | 2854 webView->setInitialFocus(false); |
| 2855 | 2855 |
| 2856 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 2856 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
| 2857 | 2857 |
| 2858 WebMouseEvent mouseEvent; | 2858 WebMouseEvent mouseEvent; |
| 2859 mouseEvent.button = WebMouseEvent::ButtonLeft; | 2859 mouseEvent.button = WebMouseEvent::ButtonLeft; |
| 2860 mouseEvent.x = 1; | 2860 mouseEvent.x = 1; |
| 2861 mouseEvent.y = 1; | 2861 mouseEvent.y = 1; |
| 2862 mouseEvent.clickCount = 1; | 2862 mouseEvent.clickCount = 1; |
| 2863 mouseEvent.type = WebInputEvent::MouseDown; | 2863 mouseEvent.type = WebInputEvent::MouseDown; |
| 2864 webView->handleInputEvent(mouseEvent); | 2864 webView->handleInputEvent(mouseEvent); |
| 2865 mouseEvent.type = WebInputEvent::MouseUp; | 2865 mouseEvent.type = WebInputEvent::MouseUp; |
| 2866 webView->handleInputEvent(mouseEvent); | 2866 webView->handleInputEvent(mouseEvent); |
| 2867 | 2867 |
| 2868 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2868 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
| 2869 frame->setAutofillClient(0); | 2869 frame->setAutofillClient(0); |
| 2870 } | 2870 } |
| 2871 | 2871 |
| 2872 TEST_F(WebViewTest, FirstUserGestureObservedGestureTap) | 2872 TEST_F(WebViewTest, FirstUserGestureObservedGestureTap) |
| 2873 { | 2873 { |
| 2874 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); | 2874 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); |
| 2875 MockAutofillClient client; | 2875 MockAutofillClient client; |
| 2876 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_
selection.html", true); | 2876 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpr
ess_selection.html", true); |
| 2877 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2877 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2878 frame->setAutofillClient(&client); | 2878 frame->setAutofillClient(&client); |
| 2879 webView->setInitialFocus(false); | 2879 webView->setInitialFocus(false); |
| 2880 | 2880 |
| 2881 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 2881 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
| 2882 | 2882 |
| 2883 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); | 2883 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); |
| 2884 | 2884 |
| 2885 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2885 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
| 2886 frame->setAutofillClient(0); | 2886 frame->setAutofillClient(0); |
| 2887 } | 2887 } |
| 2888 | 2888 |
| 2889 TEST_F(WebViewTest, CompositionIsUserGesture) | 2889 TEST_F(WebViewTest, CompositionIsUserGesture) |
| 2890 { | 2890 { |
| 2891 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2891 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2892 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 2892 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 2893 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2893 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2894 MockAutofillClient client; | 2894 MockAutofillClient client; |
| 2895 frame->setAutofillClient(&client); | 2895 frame->setAutofillClient(&client); |
| 2896 webView->setInitialFocus(false); | 2896 webView->setInitialFocus(false); |
| 2897 | 2897 |
| 2898 EXPECT_TRUE(webView->setComposition(WebString::fromUTF8(std::string("hello")
.c_str()), WebVector<WebCompositionUnderline>(), 3, 3)); | 2898 EXPECT_TRUE(webView->setComposition(WebString::fromUTF8(std::string("hello")
.c_str()), WebVector<WebCompositionUnderline>(), 3, 3)); |
| 2899 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 2899 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 2900 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 2900 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 2901 EXPECT_TRUE(frame->hasMarkedText()); | 2901 EXPECT_TRUE(frame->hasMarkedText()); |
| 2902 | 2902 |
| 2903 frame->setAutofillClient(0); | 2903 frame->setAutofillClient(0); |
| 2904 } | 2904 } |
| 2905 | 2905 |
| 2906 TEST_F(WebViewTest, CompareSelectAllToContentAsText) | 2906 TEST_F(WebViewTest, CompareSelectAllToContentAsText) |
| 2907 { | 2907 { |
| 2908 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); | 2908 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); |
| 2909 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_
selection.html", true); | 2909 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpr
ess_selection.html", true); |
| 2910 | 2910 |
| 2911 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 2911 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2912 frame->executeScript(WebScriptSource(WebString::fromUTF8("document.execComma
nd('SelectAll', false, null)"))); | 2912 frame->executeScript(WebScriptSource(WebString::fromUTF8("document.execComma
nd('SelectAll', false, null)"))); |
| 2913 std::string actual = frame->selectionAsText().utf8(); | 2913 std::string actual = frame->selectionAsText().utf8(); |
| 2914 | 2914 |
| 2915 const int kMaxOutputCharacters = 1024; | 2915 const int kMaxOutputCharacters = 1024; |
| 2916 std::string expected = WebFrameContentDumper::dumpWebViewAsText(webView, kMa
xOutputCharacters).utf8(); | 2916 std::string expected = WebFrameContentDumper::dumpWebViewAsText(webView, kMa
xOutputCharacters).utf8(); |
| 2917 EXPECT_EQ(expected, actual); | 2917 EXPECT_EQ(expected, actual); |
| 2918 } | 2918 } |
| 2919 | 2919 |
| 2920 TEST_F(WebViewTest, AutoResizeSubtreeLayout) | 2920 TEST_F(WebViewTest, AutoResizeSubtreeLayout) |
| 2921 { | 2921 { |
| 2922 std::string url = m_baseURL + "subtree-layout.html"; | 2922 std::string url = m_baseURL + "subtree-layout.html"; |
| 2923 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html"); | 2923 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html"); |
| 2924 WebView* webView = m_webViewHelper.initialize(true); | 2924 WebView* webView = m_webViewHelper.initialize(true); |
| 2925 | 2925 |
| 2926 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); | 2926 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); |
| 2927 loadFrame(webView->mainFrame(), url); | 2927 loadFrame(webView->mainFrame(), url); |
| 2928 | 2928 |
| 2929 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2929 FrameView* frameView = m_webViewHelper.webView()->mainFrameImpl()->frameView
(); |
| 2930 | 2930 |
| 2931 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. T
his EXPECT is | 2931 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. T
his EXPECT is |
| 2932 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. | 2932 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. |
| 2933 EXPECT_FALSE(frameView->needsLayout()); | 2933 EXPECT_FALSE(frameView->needsLayout()); |
| 2934 }; | 2934 }; |
| 2935 | 2935 |
| 2936 TEST_F(WebViewTest, PreferredSize) | 2936 TEST_F(WebViewTest, PreferredSize) |
| 2937 { | 2937 { |
| 2938 std::string url = m_baseURL + "specify_size.html?100px:100px"; | 2938 std::string url = m_baseURL + "specify_size.html?100px:100px"; |
| 2939 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); | 2939 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3075 frame->executeScript(WebScriptSource("setTest('click-" handler "');")); \ | 3075 frame->executeScript(WebScriptSource("setTest('click-" handler "');")); \ |
| 3076 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("targe
t"))); \ | 3076 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("targe
t"))); \ |
| 3077 EXPECT_##EXPECT(client.getPageChanged()); | 3077 EXPECT_##EXPECT(client.getPageChanged()); |
| 3078 | 3078 |
| 3079 TEST_F(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateDom) | 3079 TEST_F(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateDom) |
| 3080 { | 3080 { |
| 3081 std::string testFile = "show_unhandled_tap.html"; | 3081 std::string testFile = "show_unhandled_tap.html"; |
| 3082 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("Ahem.ttf")); | 3082 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("Ahem.ttf")); |
| 3083 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8(testFile)); | 3083 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8(testFile)); |
| 3084 UnhandledTapWebViewClient client; | 3084 UnhandledTapWebViewClient client; |
| 3085 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + testFile, t
rue, 0, &client); | 3085 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + testFil
e, true, 0, &client); |
| 3086 webView->resize(WebSize(500, 300)); | 3086 webView->resize(WebSize(500, 300)); |
| 3087 webView->updateAllLifecyclePhases(); | 3087 webView->updateAllLifecyclePhases(); |
| 3088 runPendingTasks(); | 3088 runPendingTasks(); |
| 3089 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 3089 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3090 | 3090 |
| 3091 // Test dom mutation. | 3091 // Test dom mutation. |
| 3092 TEST_EACH_MOUSEEVENT("mutateDom", TRUE); | 3092 TEST_EACH_MOUSEEVENT("mutateDom", TRUE); |
| 3093 | 3093 |
| 3094 // Test without any DOM mutation. | 3094 // Test without any DOM mutation. |
| 3095 client.reset(); | 3095 client.reset(); |
| 3096 frame->executeScript(WebScriptSource("setTest('none');")); | 3096 frame->executeScript(WebScriptSource("setTest('none');")); |
| 3097 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); | 3097 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); |
| 3098 EXPECT_FALSE(client.getPageChanged()); | 3098 EXPECT_FALSE(client.getPageChanged()); |
| 3099 | 3099 |
| 3100 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 3100 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 3101 } | 3101 } |
| 3102 | 3102 |
| 3103 TEST_F(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateStyle) | 3103 TEST_F(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateStyle) |
| 3104 { | 3104 { |
| 3105 std::string testFile = "show_unhandled_tap.html"; | 3105 std::string testFile = "show_unhandled_tap.html"; |
| 3106 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("Ahem.ttf")); | 3106 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("Ahem.ttf")); |
| 3107 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8(testFile)); | 3107 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8(testFile)); |
| 3108 UnhandledTapWebViewClient client; | 3108 UnhandledTapWebViewClient client; |
| 3109 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + testFile, t
rue, 0, &client); | 3109 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + testFil
e, true, 0, &client); |
| 3110 webView->resize(WebSize(500, 300)); | 3110 webView->resize(WebSize(500, 300)); |
| 3111 webView->updateAllLifecyclePhases(); | 3111 webView->updateAllLifecyclePhases(); |
| 3112 runPendingTasks(); | 3112 runPendingTasks(); |
| 3113 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 3113 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3114 | 3114 |
| 3115 // Test style mutation. | 3115 // Test style mutation. |
| 3116 TEST_EACH_MOUSEEVENT("mutateStyle", TRUE); | 3116 TEST_EACH_MOUSEEVENT("mutateStyle", TRUE); |
| 3117 | 3117 |
| 3118 // Test checkbox:indeterminate style mutation. | 3118 // Test checkbox:indeterminate style mutation. |
| 3119 TEST_EACH_MOUSEEVENT("mutateIndeterminate", TRUE); | 3119 TEST_EACH_MOUSEEVENT("mutateIndeterminate", TRUE); |
| 3120 | 3120 |
| 3121 // Test click div with :active style but it is not covered for now. | 3121 // Test click div with :active style but it is not covered for now. |
| 3122 client.reset(); | 3122 client.reset(); |
| 3123 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("s
tyle_active"))); | 3123 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("s
tyle_active"))); |
| 3124 EXPECT_FALSE(client.getPageChanged()); | 3124 EXPECT_FALSE(client.getPageChanged()); |
| 3125 | 3125 |
| 3126 // Test without any style mutation. | 3126 // Test without any style mutation. |
| 3127 client.reset(); | 3127 client.reset(); |
| 3128 frame->executeScript(WebScriptSource("setTest('none');")); | 3128 frame->executeScript(WebScriptSource("setTest('none');")); |
| 3129 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); | 3129 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); |
| 3130 EXPECT_FALSE(client.getPageChanged()); | 3130 EXPECT_FALSE(client.getPageChanged()); |
| 3131 | 3131 |
| 3132 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 3132 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 3133 } | 3133 } |
| 3134 | 3134 |
| 3135 TEST_F(WebViewTest, ShowUnhandledTapUIIfNeededWithPreventDefault) | 3135 TEST_F(WebViewTest, ShowUnhandledTapUIIfNeededWithPreventDefault) |
| 3136 { | 3136 { |
| 3137 std::string testFile = "show_unhandled_tap.html"; | 3137 std::string testFile = "show_unhandled_tap.html"; |
| 3138 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("Ahem.ttf")); | 3138 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("Ahem.ttf")); |
| 3139 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8(testFile)); | 3139 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8(testFile)); |
| 3140 UnhandledTapWebViewClient client; | 3140 UnhandledTapWebViewClient client; |
| 3141 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + testFile, t
rue, 0, &client); | 3141 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + testFil
e, true, 0, &client); |
| 3142 webView->resize(WebSize(500, 300)); | 3142 webView->resize(WebSize(500, 300)); |
| 3143 webView->updateAllLifecyclePhases(); | 3143 webView->updateAllLifecyclePhases(); |
| 3144 runPendingTasks(); | 3144 runPendingTasks(); |
| 3145 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 3145 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3146 | 3146 |
| 3147 // Testswallowing. | 3147 // Testswallowing. |
| 3148 TEST_EACH_MOUSEEVENT("preventDefault", FALSE); | 3148 TEST_EACH_MOUSEEVENT("preventDefault", FALSE); |
| 3149 | 3149 |
| 3150 // Test without any preventDefault. | 3150 // Test without any preventDefault. |
| 3151 client.reset(); | 3151 client.reset(); |
| 3152 frame->executeScript(WebScriptSource("setTest('none');")); | 3152 frame->executeScript(WebScriptSource("setTest('none');")); |
| 3153 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); | 3153 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); |
| 3154 EXPECT_TRUE(client.getWasCalled()); | 3154 EXPECT_TRUE(client.getWasCalled()); |
| 3155 | 3155 |
| 3156 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 3156 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 3157 } | 3157 } |
| 3158 | 3158 |
| 3159 TEST_F(WebViewTest, StopLoadingIfJavaScriptURLReturnsNoStringResult) | 3159 TEST_F(WebViewTest, StopLoadingIfJavaScriptURLReturnsNoStringResult) |
| 3160 { | 3160 { |
| 3161 ViewCreatingWebViewClient client; | 3161 ViewCreatingWebViewClient client; |
| 3162 FrameTestHelpers::WebViewHelper mainWebView; | 3162 FrameTestHelpers::WebViewHelper mainWebView; |
| 3163 mainWebView.initializeAndLoad("about:blank", true, 0, &client); | 3163 mainWebView.initializeAndLoad("about:blank", true, 0, &client); |
| 3164 mainWebView.webViewImpl()->page()->settings().setJavaScriptCanOpenWindowsAut
omatically(true); | 3164 mainWebView.webView()->page()->settings().setJavaScriptCanOpenWindowsAutomat
ically(true); |
| 3165 | 3165 |
| 3166 WebFrame* frame = mainWebView.webView()->mainFrame(); | 3166 WebFrame* frame = mainWebView.webView()->mainFrame(); |
| 3167 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3167 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 3168 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS
ource("var win = window.open('javascript:false'); win.document")); | 3168 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS
ource("var win = window.open('javascript:false'); win.document")); |
| 3169 ASSERT_TRUE(v8Value->IsObject()); | 3169 ASSERT_TRUE(v8Value->IsObject()); |
| 3170 Document* document = V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent
(), v8Value); | 3170 Document* document = V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent
(), v8Value); |
| 3171 ASSERT_TRUE(document); | 3171 ASSERT_TRUE(document); |
| 3172 EXPECT_FALSE(document->frame()->isLoading()); | 3172 EXPECT_FALSE(document->frame()->isLoading()); |
| 3173 } | 3173 } |
| 3174 | 3174 |
| 3175 #if OS(MACOSX) | 3175 #if OS(MACOSX) |
| 3176 TEST_F(WebViewTest, WebSubstringUtil) | 3176 TEST_F(WebViewTest, WebSubstringUtil) |
| 3177 { | 3177 { |
| 3178 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); | 3178 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); |
| 3179 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_ed
itable_populated.html"); | 3179 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "conten
t_editable_populated.html"); |
| 3180 webView->settings()->setDefaultFontSize(12); | 3180 webView->settings()->setDefaultFontSize(12); |
| 3181 webView->resize(WebSize(400, 400)); | 3181 webView->resize(WebSize(400, 400)); |
| 3182 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 3182 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3183 FrameView* frameView = frame->frame()->view(); | 3183 FrameView* frameView = frame->frame()->view(); |
| 3184 | 3184 |
| 3185 WebPoint baselinePoint; | 3185 WebPoint baselinePoint; |
| 3186 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); | 3186 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); |
| 3187 ASSERT_TRUE(!!result); | 3187 ASSERT_TRUE(!!result); |
| 3188 | 3188 |
| 3189 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); | 3189 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); |
| 3190 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3190 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); |
| 3191 ASSERT_TRUE(!!result); | 3191 ASSERT_TRUE(!!result); |
| 3192 | 3192 |
| 3193 webView->setZoomLevel(3); | 3193 webView->setZoomLevel(3); |
| 3194 | 3194 |
| 3195 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); | 3195 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); |
| 3196 ASSERT_TRUE(!!result); | 3196 ASSERT_TRUE(!!result); |
| 3197 | 3197 |
| 3198 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); | 3198 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); |
| 3199 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3199 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); |
| 3200 ASSERT_TRUE(!!result); | 3200 ASSERT_TRUE(!!result); |
| 3201 } | 3201 } |
| 3202 #endif | 3202 #endif |
| 3203 | 3203 |
| 3204 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3204 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
| 3205 { | 3205 { |
| 3206 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); | 3206 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); |
| 3207 MockAutofillClient client; | 3207 MockAutofillClient client; |
| 3208 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_password.html", true); | 3208 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); |
| 3209 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 3209 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3210 frame->setAutofillClient(&client); | 3210 frame->setAutofillClient(&client); |
| 3211 webView->setInitialFocus(false); | 3211 webView->setInitialFocus(false); |
| 3212 | 3212 |
| 3213 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3213 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); |
| 3214 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3214 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3215 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3215 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3216 frame->setAutofillClient(0); | 3216 frame->setAutofillClient(0); |
| 3217 } | 3217 } |
| 3218 | 3218 |
| 3219 } // namespace blink | 3219 } // namespace blink |
| OLD | NEW |