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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "core/paint/PaintLayer.h" | 59 #include "core/paint/PaintLayer.h" |
60 #include "core/paint/PaintLayerPainter.h" | 60 #include "core/paint/PaintLayerPainter.h" |
61 #include "core/timing/DOMWindowPerformance.h" | 61 #include "core/timing/DOMWindowPerformance.h" |
62 #include "core/timing/Performance.h" | 62 #include "core/timing/Performance.h" |
63 #include "platform/KeyboardCodes.h" | 63 #include "platform/KeyboardCodes.h" |
64 #include "platform/UserGestureIndicator.h" | 64 #include "platform/UserGestureIndicator.h" |
65 #include "platform/geometry/IntRect.h" | 65 #include "platform/geometry/IntRect.h" |
66 #include "platform/geometry/IntSize.h" | 66 #include "platform/geometry/IntSize.h" |
67 #include "platform/graphics/Color.h" | 67 #include "platform/graphics/Color.h" |
68 #include "platform/graphics/GraphicsContext.h" | 68 #include "platform/graphics/GraphicsContext.h" |
| 69 #include "platform/graphics/GraphicsLayer.h" |
69 #include "platform/graphics/paint/PaintRecordBuilder.h" | 70 #include "platform/graphics/paint/PaintRecordBuilder.h" |
70 #include "platform/scroll/ScrollTypes.h" | 71 #include "platform/scroll/ScrollTypes.h" |
71 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 72 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
72 #include "platform/testing/URLTestHelpers.h" | 73 #include "platform/testing/URLTestHelpers.h" |
73 #include "platform/testing/UnitTestHelpers.h" | 74 #include "platform/testing/UnitTestHelpers.h" |
74 #include "platform/wtf/PtrUtil.h" | 75 #include "platform/wtf/PtrUtil.h" |
75 #include "public/platform/Platform.h" | 76 #include "public/platform/Platform.h" |
| 77 #include "public/platform/WebCoalescedInputEvent.h" |
76 #include "public/platform/WebDisplayMode.h" | 78 #include "public/platform/WebDisplayMode.h" |
77 #include "public/platform/WebDragData.h" | 79 #include "public/platform/WebDragData.h" |
78 #include "public/platform/WebDragOperation.h" | 80 #include "public/platform/WebDragOperation.h" |
79 #include "public/platform/WebFloatPoint.h" | 81 #include "public/platform/WebFloatPoint.h" |
80 #include "public/platform/WebInputEvent.h" | 82 #include "public/platform/WebInputEvent.h" |
81 #include "public/platform/WebKeyboardEvent.h" | 83 #include "public/platform/WebKeyboardEvent.h" |
82 #include "public/platform/WebLayerTreeView.h" | 84 #include "public/platform/WebLayerTreeView.h" |
83 #include "public/platform/WebMockClipboard.h" | 85 #include "public/platform/WebMockClipboard.h" |
84 #include "public/platform/WebSize.h" | 86 #include "public/platform/WebSize.h" |
85 #include "public/platform/WebThread.h" | 87 #include "public/platform/WebThread.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 kVisibleHorizontalScrollbar, | 128 kVisibleHorizontalScrollbar, |
127 }; | 129 }; |
128 | 130 |
129 enum VerticalScrollbarState { | 131 enum VerticalScrollbarState { |
130 kNoVerticalScrollbar, | 132 kNoVerticalScrollbar, |
131 kVisibleVerticalScrollbar, | 133 kVisibleVerticalScrollbar, |
132 }; | 134 }; |
133 | 135 |
134 class TestData { | 136 class TestData { |
135 public: | 137 public: |
136 void SetWebView(WebView* web_view) { web_view_ = ToWebViewImpl(web_view); } | 138 void SetWebView(WebView* web_view) { |
| 139 web_view_ = static_cast<WebViewBase*>(web_view); |
| 140 } |
137 void SetSize(const WebSize& new_size) { size_ = new_size; } | 141 void SetSize(const WebSize& new_size) { size_ = new_size; } |
138 HorizontalScrollbarState GetHorizontalScrollbarState() const { | 142 HorizontalScrollbarState GetHorizontalScrollbarState() const { |
139 return web_view_->HasHorizontalScrollbar() ? kVisibleHorizontalScrollbar | 143 return web_view_->HasHorizontalScrollbar() ? kVisibleHorizontalScrollbar |
140 : kNoHorizontalScrollbar; | 144 : kNoHorizontalScrollbar; |
141 } | 145 } |
142 VerticalScrollbarState GetVerticalScrollbarState() const { | 146 VerticalScrollbarState GetVerticalScrollbarState() const { |
143 return web_view_->HasVerticalScrollbar() ? kVisibleVerticalScrollbar | 147 return web_view_->HasVerticalScrollbar() ? kVisibleVerticalScrollbar |
144 : kNoVerticalScrollbar; | 148 : kNoVerticalScrollbar; |
145 } | 149 } |
146 int Width() const { return size_.width; } | 150 int Width() const { return size_.width; } |
147 int Height() const { return size_.height; } | 151 int Height() const { return size_.height; } |
148 | 152 |
149 private: | 153 private: |
150 WebSize size_; | 154 WebSize size_; |
151 WebViewImpl* web_view_; | 155 WebViewBase* web_view_; |
152 }; | 156 }; |
153 | 157 |
154 class AutoResizeWebViewClient : public FrameTestHelpers::TestWebViewClient { | 158 class AutoResizeWebViewClient : public FrameTestHelpers::TestWebViewClient { |
155 public: | 159 public: |
156 // WebViewClient methods | 160 // WebViewClient methods |
157 void DidAutoResize(const WebSize& new_size) override { | 161 void DidAutoResize(const WebSize& new_size) override { |
158 test_data_.SetSize(new_size); | 162 test_data_.SetSize(new_size); |
159 } | 163 } |
160 | 164 |
161 // Local methods | 165 // Local methods |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 25, 25)); | 391 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 25, 25)); |
388 } | 392 } |
389 | 393 |
390 TEST_P(WebViewTest, SetBaseBackgroundColor) { | 394 TEST_P(WebViewTest, SetBaseBackgroundColor) { |
391 const WebColor kWhite = 0xFFFFFFFF; | 395 const WebColor kWhite = 0xFFFFFFFF; |
392 const WebColor kBlue = 0xFF0000FF; | 396 const WebColor kBlue = 0xFF0000FF; |
393 const WebColor kDarkCyan = 0xFF227788; | 397 const WebColor kDarkCyan = 0xFF227788; |
394 const WebColor kTranslucentPutty = 0x80BFB196; | 398 const WebColor kTranslucentPutty = 0x80BFB196; |
395 const WebColor kTransparent = 0x00000000; | 399 const WebColor kTransparent = 0x00000000; |
396 | 400 |
397 WebViewImpl* web_view = web_view_helper_.Initialize(); | 401 WebViewBase* web_view = web_view_helper_.Initialize(); |
398 EXPECT_EQ(kWhite, web_view->BackgroundColor()); | 402 EXPECT_EQ(kWhite, web_view->BackgroundColor()); |
399 | 403 |
400 web_view->SetBaseBackgroundColor(kBlue); | 404 web_view->SetBaseBackgroundColor(kBlue); |
401 EXPECT_EQ(kBlue, web_view->BackgroundColor()); | 405 EXPECT_EQ(kBlue, web_view->BackgroundColor()); |
402 | 406 |
403 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 407 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
404 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), | 408 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |
405 "<html><head><style>body " | 409 "<html><head><style>body " |
406 "{background-color:#227788}</style></head></" | 410 "{background-color:#227788}</style></head></" |
407 "html>", | 411 "html>", |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 445 |
442 const Color transparent_red(100, 0, 0, 0); | 446 const Color transparent_red(100, 0, 0, 0); |
443 frame->CreateView(IntSize(1024, 768), transparent_red); | 447 frame->CreateView(IntSize(1024, 768), transparent_red); |
444 EXPECT_EQ(transparent_red, frame->View()->BaseBackgroundColor()); | 448 EXPECT_EQ(transparent_red, frame->View()->BaseBackgroundColor()); |
445 frame->View()->Dispose(); | 449 frame->View()->Dispose(); |
446 } | 450 } |
447 | 451 |
448 TEST_P(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) { | 452 TEST_P(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) { |
449 const WebColor kBlue = 0xFF0000FF; | 453 const WebColor kBlue = 0xFF0000FF; |
450 FrameTestHelpers::TestWebViewClient web_view_client; | 454 FrameTestHelpers::TestWebViewClient web_view_client; |
451 WebViewImpl* web_view = | 455 WebViewBase* web_view = static_cast<WebViewBase*>( |
452 WebViewImpl::Create(&web_view_client, kWebPageVisibilityStateVisible); | 456 WebView::Create(&web_view_client, kWebPageVisibilityStateVisible)); |
453 EXPECT_NE(kBlue, web_view->BackgroundColor()); | 457 EXPECT_NE(kBlue, web_view->BackgroundColor()); |
454 // webView does not have a frame yet, but we should still be able to set the | 458 // webView does not have a frame yet, but we should still be able to set the |
455 // background color. | 459 // background color. |
456 web_view->SetBaseBackgroundColor(kBlue); | 460 web_view->SetBaseBackgroundColor(kBlue); |
457 EXPECT_EQ(kBlue, web_view->BackgroundColor()); | 461 EXPECT_EQ(kBlue, web_view->BackgroundColor()); |
458 FrameTestHelpers::TestWebFrameClient web_frame_client; | 462 FrameTestHelpers::TestWebFrameClient web_frame_client; |
459 WebLocalFrame* frame = WebLocalFrame::Create( | 463 WebLocalFrame* frame = WebLocalFrame::Create( |
460 WebTreeScopeType::kDocument, &web_frame_client, nullptr, nullptr); | 464 WebTreeScopeType::kDocument, &web_frame_client, nullptr, nullptr); |
461 web_view->SetMainFrame(frame); | 465 web_view->SetMainFrame(frame); |
462 web_view->Close(); | 466 web_view->Close(); |
463 } | 467 } |
464 | 468 |
465 TEST_P(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) { | 469 TEST_P(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) { |
466 const WebColor kAlphaRed = 0x80FF0000; | 470 const WebColor kAlphaRed = 0x80FF0000; |
467 const WebColor kAlphaGreen = 0x8000FF00; | 471 const WebColor kAlphaGreen = 0x8000FF00; |
468 const int kWidth = 100; | 472 const int kWidth = 100; |
469 const int kHeight = 100; | 473 const int kHeight = 100; |
470 | 474 |
471 WebViewImpl* web_view = web_view_helper_.Initialize(); | 475 WebViewBase* web_view = web_view_helper_.Initialize(); |
472 | 476 |
473 // Set WebView background to green with alpha. | 477 // Set WebView background to green with alpha. |
474 web_view->SetBaseBackgroundColor(kAlphaGreen); | 478 web_view->SetBaseBackgroundColor(kAlphaGreen); |
475 web_view->GetSettings()->SetShouldClearDocumentBackground(false); | 479 web_view->GetSettings()->SetShouldClearDocumentBackground(false); |
476 web_view->Resize(WebSize(kWidth, kHeight)); | 480 web_view->Resize(WebSize(kWidth, kHeight)); |
477 web_view->UpdateAllLifecyclePhases(); | 481 web_view->UpdateAllLifecyclePhases(); |
478 | 482 |
479 // Set canvas background to red with alpha. | 483 // Set canvas background to red with alpha. |
480 SkBitmap bitmap; | 484 SkBitmap bitmap; |
481 bitmap.allocN32Pixels(kWidth, kHeight); | 485 bitmap.allocN32Pixels(kWidth, kHeight); |
(...skipping 15 matching lines...) Expand all Loading... |
497 builder.EndRecording()->playback(&canvas); | 501 builder.EndRecording()->playback(&canvas); |
498 | 502 |
499 // The result should be a blend of red and green. | 503 // The result should be a blend of red and green. |
500 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); | 504 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); |
501 EXPECT_TRUE(RedChannel(color)); | 505 EXPECT_TRUE(RedChannel(color)); |
502 EXPECT_TRUE(GreenChannel(color)); | 506 EXPECT_TRUE(GreenChannel(color)); |
503 } | 507 } |
504 | 508 |
505 TEST_P(WebViewTest, FocusIsInactive) { | 509 TEST_P(WebViewTest, FocusIsInactive) { |
506 RegisterMockedHttpURLLoad("visible_iframe.html"); | 510 RegisterMockedHttpURLLoad("visible_iframe.html"); |
507 WebViewImpl* web_view = | 511 WebViewBase* web_view = |
508 web_view_helper_.InitializeAndLoad(base_url_ + "visible_iframe.html"); | 512 web_view_helper_.InitializeAndLoad(base_url_ + "visible_iframe.html"); |
509 | 513 |
510 web_view->SetFocus(true); | 514 web_view->SetFocus(true); |
511 web_view->SetIsActive(true); | 515 web_view->SetIsActive(true); |
512 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 516 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
513 EXPECT_TRUE(frame->GetFrame()->GetDocument()->IsHTMLDocument()); | 517 EXPECT_TRUE(frame->GetFrame()->GetDocument()->IsHTMLDocument()); |
514 | 518 |
515 Document* document = frame->GetFrame()->GetDocument(); | 519 Document* document = frame->GetFrame()->GetDocument(); |
516 EXPECT_TRUE(document->hasFocus()); | 520 EXPECT_TRUE(document->hasFocus()); |
517 web_view->SetFocus(false); | 521 web_view->SetFocus(false); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 const std::string& page_height, | 664 const std::string& page_height, |
661 int expected_width, | 665 int expected_width, |
662 int expected_height, | 666 int expected_height, |
663 HorizontalScrollbarState expected_horizontal_state, | 667 HorizontalScrollbarState expected_horizontal_state, |
664 VerticalScrollbarState expected_vertical_state) { | 668 VerticalScrollbarState expected_vertical_state) { |
665 AutoResizeWebViewClient client; | 669 AutoResizeWebViewClient client; |
666 std::string url = | 670 std::string url = |
667 base_url_ + "specify_size.html?" + page_width + ":" + page_height; | 671 base_url_ + "specify_size.html?" + page_width + ":" + page_height; |
668 URLTestHelpers::RegisterMockedURLLoad( | 672 URLTestHelpers::RegisterMockedURLLoad( |
669 ToKURL(url), testing::WebTestDataPath("specify_size.html")); | 673 ToKURL(url), testing::WebTestDataPath("specify_size.html")); |
670 WebViewImpl* web_view = | 674 WebViewBase* web_view = |
671 web_view_helper_.InitializeAndLoad(url, true, 0, &client); | 675 web_view_helper_.InitializeAndLoad(url, true, 0, &client); |
672 client.GetTestData().SetWebView(web_view); | 676 client.GetTestData().SetWebView(web_view); |
673 | 677 |
674 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 678 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
675 FrameView* frame_view = frame->GetFrame()->View(); | 679 FrameView* frame_view = frame->GetFrame()->View(); |
676 frame_view->UpdateLayout(); | 680 frame_view->UpdateLayout(); |
677 EXPECT_FALSE(frame_view->LayoutPending()); | 681 EXPECT_FALSE(frame_view->LayoutPending()); |
678 EXPECT_FALSE(frame_view->NeedsLayout()); | 682 EXPECT_FALSE(frame_view->NeedsLayout()); |
679 | 683 |
680 web_view->EnableAutoResizeMode(min_auto_resize, max_auto_resize); | 684 web_view->EnableAutoResizeMode(min_auto_resize, max_auto_resize); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 int expected_width = 200; | 773 int expected_width = 200; |
770 int expected_height = 300; | 774 int expected_height = 300; |
771 TestAutoResize(min_auto_resize, max_auto_resize, page_width, page_height, | 775 TestAutoResize(min_auto_resize, max_auto_resize, page_width, page_height, |
772 expected_width, expected_height, kNoHorizontalScrollbar, | 776 expected_width, expected_height, kNoHorizontalScrollbar, |
773 kNoVerticalScrollbar); | 777 kNoVerticalScrollbar); |
774 } | 778 } |
775 | 779 |
776 void WebViewTest::TestTextInputType(WebTextInputType expected_type, | 780 void WebViewTest::TestTextInputType(WebTextInputType expected_type, |
777 const std::string& html_file) { | 781 const std::string& html_file) { |
778 RegisterMockedHttpURLLoad(html_file); | 782 RegisterMockedHttpURLLoad(html_file); |
779 WebViewImpl* web_view = | 783 WebViewBase* web_view = |
780 web_view_helper_.InitializeAndLoad(base_url_ + html_file); | 784 web_view_helper_.InitializeAndLoad(base_url_ + html_file); |
781 WebInputMethodControllerImpl* controller = | 785 WebInputMethodControllerImpl* controller = |
782 web_view->MainFrameImpl()->GetInputMethodController(); | 786 web_view->MainFrameImpl()->GetInputMethodController(); |
783 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputType()); | 787 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputType()); |
784 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputInfo().type); | 788 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputInfo().type); |
785 web_view->SetInitialFocus(false); | 789 web_view->SetInitialFocus(false); |
786 EXPECT_EQ(expected_type, controller->TextInputType()); | 790 EXPECT_EQ(expected_type, controller->TextInputType()); |
787 EXPECT_EQ(expected_type, controller->TextInputInfo().type); | 791 EXPECT_EQ(expected_type, controller->TextInputInfo().type); |
788 web_view->ClearFocusedElement(); | 792 web_view->ClearFocusedElement(); |
789 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputType()); | 793 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputType()); |
790 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputInfo().type); | 794 EXPECT_EQ(kWebTextInputTypeNone, controller->TextInputInfo().type); |
791 } | 795 } |
792 | 796 |
793 TEST_P(WebViewTest, TextInputType) { | 797 TEST_P(WebViewTest, TextInputType) { |
794 TestTextInputType(kWebTextInputTypeText, "input_field_default.html"); | 798 TestTextInputType(kWebTextInputTypeText, "input_field_default.html"); |
795 TestTextInputType(kWebTextInputTypePassword, "input_field_password.html"); | 799 TestTextInputType(kWebTextInputTypePassword, "input_field_password.html"); |
796 TestTextInputType(kWebTextInputTypeEmail, "input_field_email.html"); | 800 TestTextInputType(kWebTextInputTypeEmail, "input_field_email.html"); |
797 TestTextInputType(kWebTextInputTypeSearch, "input_field_search.html"); | 801 TestTextInputType(kWebTextInputTypeSearch, "input_field_search.html"); |
798 TestTextInputType(kWebTextInputTypeNumber, "input_field_number.html"); | 802 TestTextInputType(kWebTextInputTypeNumber, "input_field_number.html"); |
799 TestTextInputType(kWebTextInputTypeTelephone, "input_field_tel.html"); | 803 TestTextInputType(kWebTextInputTypeTelephone, "input_field_tel.html"); |
800 TestTextInputType(kWebTextInputTypeURL, "input_field_url.html"); | 804 TestTextInputType(kWebTextInputTypeURL, "input_field_url.html"); |
801 } | 805 } |
802 | 806 |
803 TEST_P(WebViewTest, TextInputInfoUpdateStyleAndLayout) { | 807 TEST_P(WebViewTest, TextInputInfoUpdateStyleAndLayout) { |
804 FrameTestHelpers::TestWebViewClient client; | 808 FrameTestHelpers::TestWebViewClient client; |
805 FrameTestHelpers::WebViewHelper web_view_helper; | 809 FrameTestHelpers::WebViewHelper web_view_helper; |
806 WebViewImpl* web_view_impl = web_view_helper.Initialize(true, 0, &client); | 810 WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); |
807 | 811 |
808 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 812 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
809 // Here, we need to construct a document that has a special property: | 813 // Here, we need to construct a document that has a special property: |
810 // Adding id="foo" to the <path> element will trigger creation of an SVG | 814 // Adding id="foo" to the <path> element will trigger creation of an SVG |
811 // instance tree for the use <use> element. | 815 // instance tree for the use <use> element. |
812 // This is significant, because SVG instance trees are actually created lazily | 816 // This is significant, because SVG instance trees are actually created lazily |
813 // during Document::updateStyleAndLayout code, thus incrementing the DOM tree | 817 // during Document::updateStyleAndLayout code, thus incrementing the DOM tree |
814 // version and freaking out the EphemeralRange (invalidating it). | 818 // version and freaking out the EphemeralRange (invalidating it). |
815 FrameTestHelpers::LoadHTMLString( | 819 FrameTestHelpers::LoadHTMLString( |
816 web_view_impl->MainFrame(), | 820 web_view_impl->MainFrame(), |
(...skipping 15 matching lines...) Expand all Loading... |
832 // This should not DCHECK. | 836 // This should not DCHECK. |
833 EXPECT_EQ(kWebTextInputTypeText, web_view_impl->MainFrameImpl() | 837 EXPECT_EQ(kWebTextInputTypeText, web_view_impl->MainFrameImpl() |
834 ->GetInputMethodController() | 838 ->GetInputMethodController() |
835 ->TextInputInfo() | 839 ->TextInputInfo() |
836 .type); | 840 .type); |
837 } | 841 } |
838 | 842 |
839 void WebViewTest::TestInputMode(WebTextInputMode expected_input_mode, | 843 void WebViewTest::TestInputMode(WebTextInputMode expected_input_mode, |
840 const std::string& html_file) { | 844 const std::string& html_file) { |
841 RegisterMockedHttpURLLoad(html_file); | 845 RegisterMockedHttpURLLoad(html_file); |
842 WebViewImpl* web_view_impl = | 846 WebViewBase* web_view_impl = |
843 web_view_helper_.InitializeAndLoad(base_url_ + html_file); | 847 web_view_helper_.InitializeAndLoad(base_url_ + html_file); |
844 web_view_impl->SetInitialFocus(false); | 848 web_view_impl->SetInitialFocus(false); |
845 EXPECT_EQ(expected_input_mode, web_view_impl->MainFrameImpl() | 849 EXPECT_EQ(expected_input_mode, web_view_impl->MainFrameImpl() |
846 ->GetInputMethodController() | 850 ->GetInputMethodController() |
847 ->TextInputInfo() | 851 ->TextInputInfo() |
848 .input_mode); | 852 .input_mode); |
849 } | 853 } |
850 | 854 |
851 TEST_P(WebViewTest, InputMode) { | 855 TEST_P(WebViewTest, InputMode) { |
852 TestInputMode(WebTextInputMode::kWebTextInputModeDefault, | 856 TestInputMode(WebTextInputMode::kWebTextInputModeDefault, |
(...skipping 30 matching lines...) Expand all Loading... |
883 "input_mode_type_email.html"); | 887 "input_mode_type_email.html"); |
884 TestInputMode(WebTextInputMode::kWebTextInputModeUrl, | 888 TestInputMode(WebTextInputMode::kWebTextInputModeUrl, |
885 "input_mode_type_url.html"); | 889 "input_mode_type_url.html"); |
886 } | 890 } |
887 | 891 |
888 TEST_P(WebViewTest, TextInputInfoWithReplacedElements) { | 892 TEST_P(WebViewTest, TextInputInfoWithReplacedElements) { |
889 std::string url = RegisterMockedHttpURLLoad("div_with_image.html"); | 893 std::string url = RegisterMockedHttpURLLoad("div_with_image.html"); |
890 URLTestHelpers::RegisterMockedURLLoad( | 894 URLTestHelpers::RegisterMockedURLLoad( |
891 ToKURL("http://www.test.com/foo.png"), | 895 ToKURL("http://www.test.com/foo.png"), |
892 testing::WebTestDataPath("white-1x1.png")); | 896 testing::WebTestDataPath("white-1x1.png")); |
893 WebViewImpl* web_view_impl = web_view_helper_.InitializeAndLoad(url); | 897 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad(url); |
894 web_view_impl->SetInitialFocus(false); | 898 web_view_impl->SetInitialFocus(false); |
895 WebTextInputInfo info = web_view_impl->MainFrameImpl() | 899 WebTextInputInfo info = web_view_impl->MainFrameImpl() |
896 ->GetInputMethodController() | 900 ->GetInputMethodController() |
897 ->TextInputInfo(); | 901 ->TextInputInfo(); |
898 | 902 |
899 EXPECT_EQ("foo\xef\xbf\xbc", info.value.Utf8()); | 903 EXPECT_EQ("foo\xef\xbf\xbc", info.value.Utf8()); |
900 } | 904 } |
901 | 905 |
902 TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { | 906 TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { |
903 RegisterMockedHttpURLLoad("input_field_populated.html"); | 907 RegisterMockedHttpURLLoad("input_field_populated.html"); |
904 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 908 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
905 base_url_ + "input_field_populated.html"); | 909 base_url_ + "input_field_populated.html"); |
906 web_view->SetInitialFocus(false); | 910 web_view->SetInitialFocus(false); |
907 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 911 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
908 WebInputMethodControllerImpl* active_input_method_controller = | 912 WebInputMethodControllerImpl* active_input_method_controller = |
909 frame->GetInputMethodController(); | 913 frame->GetInputMethodController(); |
910 frame->SetEditableSelectionOffsets(5, 13); | 914 frame->SetEditableSelectionOffsets(5, 13); |
911 EXPECT_EQ("56789abc", frame->SelectionAsText()); | 915 EXPECT_EQ("56789abc", frame->SelectionAsText()); |
912 WebTextInputInfo info = active_input_method_controller->TextInputInfo(); | 916 WebTextInputInfo info = active_input_method_controller->TextInputInfo(); |
913 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 917 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
914 EXPECT_EQ(5, info.selection_start); | 918 EXPECT_EQ(5, info.selection_start); |
(...skipping 13 matching lines...) Expand all Loading... |
928 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 932 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
929 EXPECT_EQ(8, info.selection_start); | 933 EXPECT_EQ(8, info.selection_start); |
930 EXPECT_EQ(19, info.selection_end); | 934 EXPECT_EQ(19, info.selection_end); |
931 EXPECT_EQ(-1, info.composition_start); | 935 EXPECT_EQ(-1, info.composition_start); |
932 EXPECT_EQ(-1, info.composition_end); | 936 EXPECT_EQ(-1, info.composition_end); |
933 } | 937 } |
934 | 938 |
935 // Regression test for crbug.com/663645 | 939 // Regression test for crbug.com/663645 |
936 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) { | 940 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) { |
937 RegisterMockedHttpURLLoad("input_field_default.html"); | 941 RegisterMockedHttpURLLoad("input_field_default.html"); |
938 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 942 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
939 base_url_ + "input_field_default.html"); | 943 base_url_ + "input_field_default.html"); |
940 web_view->SetInitialFocus(false); | 944 web_view->SetInitialFocus(false); |
941 | 945 |
942 WebInputMethodController* active_input_method_controller = | 946 WebInputMethodController* active_input_method_controller = |
943 web_view->MainFrameImpl() | 947 web_view->MainFrameImpl() |
944 ->FrameWidget() | 948 ->FrameWidget() |
945 ->GetActiveWebInputMethodController(); | 949 ->GetActiveWebInputMethodController(); |
946 | 950 |
947 // The test requires non-empty composition. | 951 // The test requires non-empty composition. |
948 std::string composition_text("hello"); | 952 std::string composition_text("hello"); |
949 WebVector<WebCompositionUnderline> empty_underlines; | 953 WebVector<WebCompositionUnderline> empty_underlines; |
950 active_input_method_controller->SetComposition( | 954 active_input_method_controller->SetComposition( |
951 WebString::FromUTF8(composition_text.c_str()), empty_underlines, | 955 WebString::FromUTF8(composition_text.c_str()), empty_underlines, |
952 WebRange(), 5, 5); | 956 WebRange(), 5, 5); |
953 | 957 |
954 // Do arbitrary change to make layout dirty. | 958 // Do arbitrary change to make layout dirty. |
955 Document& document = *web_view->MainFrameImpl()->GetFrame()->GetDocument(); | 959 Document& document = *web_view->MainFrameImpl()->GetFrame()->GetDocument(); |
956 Element* br = document.createElement("br"); | 960 Element* br = document.createElement("br"); |
957 document.body()->AppendChild(br); | 961 document.body()->AppendChild(br); |
958 | 962 |
959 // Should not hit assertion when calling | 963 // Should not hit assertion when calling |
960 // WebInputMethodController::finishComposingText with non-empty composition | 964 // WebInputMethodController::finishComposingText with non-empty composition |
961 // and dirty layout. | 965 // and dirty layout. |
962 active_input_method_controller->FinishComposingText( | 966 active_input_method_controller->FinishComposingText( |
963 WebInputMethodController::kKeepSelection); | 967 WebInputMethodController::kKeepSelection); |
964 } | 968 } |
965 | 969 |
966 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { | 970 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { |
967 RegisterMockedHttpURLLoad("input_field_populated.html"); | 971 RegisterMockedHttpURLLoad("input_field_populated.html"); |
968 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 972 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
969 base_url_ + "input_field_populated.html"); | 973 base_url_ + "input_field_populated.html"); |
970 web_view->SetInitialFocus(false); | 974 web_view->SetInitialFocus(false); |
971 | 975 |
972 // Set up a composition that needs to be committed. | 976 // Set up a composition that needs to be committed. |
973 std::string composition_text("hello"); | 977 std::string composition_text("hello"); |
974 | 978 |
975 WebInputMethodController* active_input_method_controller = | 979 WebInputMethodController* active_input_method_controller = |
976 web_view->MainFrameImpl() | 980 web_view->MainFrameImpl() |
977 ->FrameWidget() | 981 ->FrameWidget() |
978 ->GetActiveWebInputMethodController(); | 982 ->GetActiveWebInputMethodController(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 WebInputMethodController::kDoNotKeepSelection); | 1014 WebInputMethodController::kDoNotKeepSelection); |
1011 info = active_input_method_controller->TextInputInfo(); | 1015 info = active_input_method_controller->TextInputInfo(); |
1012 EXPECT_EQ(8, info.selection_start); | 1016 EXPECT_EQ(8, info.selection_start); |
1013 EXPECT_EQ(8, info.selection_end); | 1017 EXPECT_EQ(8, info.selection_end); |
1014 EXPECT_EQ(-1, info.composition_start); | 1018 EXPECT_EQ(-1, info.composition_start); |
1015 EXPECT_EQ(-1, info.composition_end); | 1019 EXPECT_EQ(-1, info.composition_end); |
1016 } | 1020 } |
1017 | 1021 |
1018 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { | 1022 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { |
1019 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1023 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1020 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1024 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1021 base_url_ + "input_field_populated.html"); | 1025 base_url_ + "input_field_populated.html"); |
1022 web_view->SetInitialFocus(false); | 1026 web_view->SetInitialFocus(false); |
1023 WebInputMethodController* active_input_method_controller = | 1027 WebInputMethodController* active_input_method_controller = |
1024 web_view->MainFrameImpl() | 1028 web_view->MainFrameImpl() |
1025 ->FrameWidget() | 1029 ->FrameWidget() |
1026 ->GetActiveWebInputMethodController(); | 1030 ->GetActiveWebInputMethodController(); |
1027 | 1031 |
1028 WebVector<WebCompositionUnderline> empty_underlines; | 1032 WebVector<WebCompositionUnderline> empty_underlines; |
1029 | 1033 |
1030 active_input_method_controller->CommitText("hello", empty_underlines, | 1034 active_input_method_controller->CommitText("hello", empty_underlines, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 info = active_input_method_controller->TextInputInfo(); | 1130 info = active_input_method_controller->TextInputInfo(); |
1127 EXPECT_EQ("helloABCworld", std::string(info.value.Utf8().data())); | 1131 EXPECT_EQ("helloABCworld", std::string(info.value.Utf8().data())); |
1128 EXPECT_EQ(13, info.selection_start); | 1132 EXPECT_EQ(13, info.selection_start); |
1129 EXPECT_EQ(13, info.selection_end); | 1133 EXPECT_EQ(13, info.selection_end); |
1130 EXPECT_EQ(5, info.composition_start); | 1134 EXPECT_EQ(5, info.composition_start); |
1131 EXPECT_EQ(8, info.composition_end); | 1135 EXPECT_EQ(8, info.composition_end); |
1132 } | 1136 } |
1133 | 1137 |
1134 TEST_P(WebViewTest, SetCompositionWithEmptyText) { | 1138 TEST_P(WebViewTest, SetCompositionWithEmptyText) { |
1135 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1139 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1136 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1140 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1137 base_url_ + "input_field_populated.html"); | 1141 base_url_ + "input_field_populated.html"); |
1138 web_view->SetInitialFocus(false); | 1142 web_view->SetInitialFocus(false); |
1139 WebInputMethodController* active_input_method_controller = | 1143 WebInputMethodController* active_input_method_controller = |
1140 web_view->MainFrameImpl() | 1144 web_view->MainFrameImpl() |
1141 ->FrameWidget() | 1145 ->FrameWidget() |
1142 ->GetActiveWebInputMethodController(); | 1146 ->GetActiveWebInputMethodController(); |
1143 | 1147 |
1144 WebVector<WebCompositionUnderline> empty_underlines; | 1148 WebVector<WebCompositionUnderline> empty_underlines; |
1145 | 1149 |
1146 active_input_method_controller->CommitText("hello", empty_underlines, | 1150 active_input_method_controller->CommitText("hello", empty_underlines, |
(...skipping 20 matching lines...) Expand all Loading... |
1167 info = active_input_method_controller->TextInputInfo(); | 1171 info = active_input_method_controller->TextInputInfo(); |
1168 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); | 1172 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); |
1169 EXPECT_EQ(3, info.selection_start); | 1173 EXPECT_EQ(3, info.selection_start); |
1170 EXPECT_EQ(3, info.selection_end); | 1174 EXPECT_EQ(3, info.selection_end); |
1171 EXPECT_EQ(-1, info.composition_start); | 1175 EXPECT_EQ(-1, info.composition_start); |
1172 EXPECT_EQ(-1, info.composition_end); | 1176 EXPECT_EQ(-1, info.composition_end); |
1173 } | 1177 } |
1174 | 1178 |
1175 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { | 1179 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { |
1176 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1180 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1177 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1181 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1178 base_url_ + "input_field_populated.html"); | 1182 base_url_ + "input_field_populated.html"); |
1179 web_view->SetInitialFocus(false); | 1183 web_view->SetInitialFocus(false); |
1180 WebInputMethodController* active_input_method_controller = | 1184 WebInputMethodController* active_input_method_controller = |
1181 web_view->MainFrameImpl() | 1185 web_view->MainFrameImpl() |
1182 ->FrameWidget() | 1186 ->FrameWidget() |
1183 ->GetActiveWebInputMethodController(); | 1187 ->GetActiveWebInputMethodController(); |
1184 | 1188 |
1185 WebVector<WebCompositionUnderline> empty_underlines; | 1189 WebVector<WebCompositionUnderline> empty_underlines; |
1186 | 1190 |
1187 // Caret is on the left of composing text. | 1191 // Caret is on the left of composing text. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 info = active_input_method_controller->TextInputInfo(); | 1244 info = active_input_method_controller->TextInputInfo(); |
1241 EXPECT_EQ("jkgcadefbhi", std::string(info.value.Utf8().data())); | 1245 EXPECT_EQ("jkgcadefbhi", std::string(info.value.Utf8().data())); |
1242 EXPECT_EQ(11, info.selection_start); | 1246 EXPECT_EQ(11, info.selection_start); |
1243 EXPECT_EQ(11, info.selection_end); | 1247 EXPECT_EQ(11, info.selection_end); |
1244 EXPECT_EQ(-1, info.composition_start); | 1248 EXPECT_EQ(-1, info.composition_start); |
1245 EXPECT_EQ(-1, info.composition_end); | 1249 EXPECT_EQ(-1, info.composition_end); |
1246 } | 1250 } |
1247 | 1251 |
1248 TEST_P(WebViewTest, CommitTextWhileComposing) { | 1252 TEST_P(WebViewTest, CommitTextWhileComposing) { |
1249 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1253 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1250 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1254 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1251 base_url_ + "input_field_populated.html"); | 1255 base_url_ + "input_field_populated.html"); |
1252 web_view->SetInitialFocus(false); | 1256 web_view->SetInitialFocus(false); |
1253 WebInputMethodController* active_input_method_controller = | 1257 WebInputMethodController* active_input_method_controller = |
1254 web_view->MainFrameImpl() | 1258 web_view->MainFrameImpl() |
1255 ->FrameWidget() | 1259 ->FrameWidget() |
1256 ->GetActiveWebInputMethodController(); | 1260 ->GetActiveWebInputMethodController(); |
1257 | 1261 |
1258 WebVector<WebCompositionUnderline> empty_underlines; | 1262 WebVector<WebCompositionUnderline> empty_underlines; |
1259 active_input_method_controller->SetComposition( | 1263 active_input_method_controller->SetComposition( |
1260 WebString::FromUTF8("abc"), empty_underlines, WebRange(), 0, 0); | 1264 WebString::FromUTF8("abc"), empty_underlines, WebRange(), 0, 0); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 info = active_input_method_controller->TextInputInfo(); | 1315 info = active_input_method_controller->TextInputInfo(); |
1312 EXPECT_EQ("helloworld", std::string(info.value.Utf8().data())); | 1316 EXPECT_EQ("helloworld", std::string(info.value.Utf8().data())); |
1313 EXPECT_EQ(10, info.selection_start); | 1317 EXPECT_EQ(10, info.selection_start); |
1314 EXPECT_EQ(10, info.selection_end); | 1318 EXPECT_EQ(10, info.selection_end); |
1315 EXPECT_EQ(-1, info.composition_start); | 1319 EXPECT_EQ(-1, info.composition_start); |
1316 EXPECT_EQ(-1, info.composition_end); | 1320 EXPECT_EQ(-1, info.composition_end); |
1317 } | 1321 } |
1318 | 1322 |
1319 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1323 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
1320 RegisterMockedHttpURLLoad("form_with_input.html"); | 1324 RegisterMockedHttpURLLoad("form_with_input.html"); |
1321 WebViewImpl* web_view = | 1325 WebViewBase* web_view = |
1322 web_view_helper_.InitializeAndLoad(base_url_ + "form_with_input.html"); | 1326 web_view_helper_.InitializeAndLoad(base_url_ + "form_with_input.html"); |
1323 web_view->Resize(WebSize(800, 600)); | 1327 web_view->Resize(WebSize(800, 600)); |
1324 web_view->SetInitialFocus(false); | 1328 web_view->SetInitialFocus(false); |
1325 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1329 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); |
1326 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().height); | 1330 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().height); |
1327 | 1331 |
1328 // Set up a composition from existing text that needs to be committed. | 1332 // Set up a composition from existing text that needs to be committed. |
1329 Vector<CompositionUnderline> empty_underlines; | 1333 Vector<CompositionUnderline> empty_underlines; |
1330 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 1334 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
1331 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( | 1335 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( |
(...skipping 13 matching lines...) Expand all Loading... |
1345 // Verify that the input field is not scrolled back into the viewport. | 1349 // Verify that the input field is not scrolled back into the viewport. |
1346 frame->FrameWidget() | 1350 frame->FrameWidget() |
1347 ->GetActiveWebInputMethodController() | 1351 ->GetActiveWebInputMethodController() |
1348 ->FinishComposingText(WebInputMethodController::kDoNotKeepSelection); | 1352 ->FinishComposingText(WebInputMethodController::kDoNotKeepSelection); |
1349 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1353 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); |
1350 EXPECT_EQ(offset_height, web_view->MainFrame()->GetScrollOffset().height); | 1354 EXPECT_EQ(offset_height, web_view->MainFrame()->GetScrollOffset().height); |
1351 } | 1355 } |
1352 | 1356 |
1353 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { | 1357 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { |
1354 RegisterMockedHttpURLLoad("text_area_populated.html"); | 1358 RegisterMockedHttpURLLoad("text_area_populated.html"); |
1355 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1359 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1356 base_url_ + "text_area_populated.html"); | 1360 base_url_ + "text_area_populated.html"); |
1357 web_view->SetInitialFocus(false); | 1361 web_view->SetInitialFocus(false); |
1358 | 1362 |
1359 WebVector<WebCompositionUnderline> empty_underlines; | 1363 WebVector<WebCompositionUnderline> empty_underlines; |
1360 | 1364 |
1361 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 1365 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
1362 WebInputMethodController* active_input_method_controller = | 1366 WebInputMethodController* active_input_method_controller = |
1363 frame->GetInputMethodController(); | 1367 frame->GetInputMethodController(); |
1364 frame->SetEditableSelectionOffsets(4, 4); | 1368 frame->SetEditableSelectionOffsets(4, 4); |
1365 frame->SetCompositionFromExistingText(8, 12, empty_underlines); | 1369 frame->SetCompositionFromExistingText(8, 12, empty_underlines); |
(...skipping 22 matching lines...) Expand all Loading... |
1388 EXPECT_EQ(5, info.selection_start); | 1392 EXPECT_EQ(5, info.selection_start); |
1389 EXPECT_EQ(5, info.selection_end); | 1393 EXPECT_EQ(5, info.selection_end); |
1390 EXPECT_EQ(-1, info.composition_start); | 1394 EXPECT_EQ(-1, info.composition_start); |
1391 EXPECT_EQ(-1, info.composition_end); | 1395 EXPECT_EQ(-1, info.composition_end); |
1392 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", | 1396 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", |
1393 std::string(info.value.Utf8().data())); | 1397 std::string(info.value.Utf8().data())); |
1394 } | 1398 } |
1395 | 1399 |
1396 TEST_P(WebViewTest, ExtendSelectionAndDelete) { | 1400 TEST_P(WebViewTest, ExtendSelectionAndDelete) { |
1397 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1401 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1398 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1402 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1399 base_url_ + "input_field_populated.html"); | 1403 base_url_ + "input_field_populated.html"); |
1400 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 1404 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
1401 web_view->SetInitialFocus(false); | 1405 web_view->SetInitialFocus(false); |
1402 frame->SetEditableSelectionOffsets(10, 10); | 1406 frame->SetEditableSelectionOffsets(10, 10); |
1403 frame->ExtendSelectionAndDelete(5, 8); | 1407 frame->ExtendSelectionAndDelete(5, 8); |
1404 WebInputMethodController* active_input_method_controller = | 1408 WebInputMethodController* active_input_method_controller = |
1405 frame->GetInputMethodController(); | 1409 frame->GetInputMethodController(); |
1406 WebTextInputInfo info = active_input_method_controller->TextInputInfo(); | 1410 WebTextInputInfo info = active_input_method_controller->TextInputInfo(); |
1407 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.Utf8().data())); | 1411 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.Utf8().data())); |
1408 EXPECT_EQ(5, info.selection_start); | 1412 EXPECT_EQ(5, info.selection_start); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 | 1454 |
1451 frame->DeleteSurroundingText(10, 10); | 1455 frame->DeleteSurroundingText(10, 10); |
1452 info = active_input_method_controller->TextInputInfo(); | 1456 info = active_input_method_controller->TextInputInfo(); |
1453 EXPECT_EQ("", std::string(info.value.Utf8().data())); | 1457 EXPECT_EQ("", std::string(info.value.Utf8().data())); |
1454 EXPECT_EQ(0, info.selection_start); | 1458 EXPECT_EQ(0, info.selection_start); |
1455 EXPECT_EQ(0, info.selection_end); | 1459 EXPECT_EQ(0, info.selection_end); |
1456 } | 1460 } |
1457 | 1461 |
1458 TEST_P(WebViewTest, SetCompositionFromExistingText) { | 1462 TEST_P(WebViewTest, SetCompositionFromExistingText) { |
1459 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1463 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1460 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1464 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1461 base_url_ + "input_field_populated.html"); | 1465 base_url_ + "input_field_populated.html"); |
1462 web_view->SetInitialFocus(false); | 1466 web_view->SetInitialFocus(false); |
1463 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1467 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1464 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1468 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1465 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 1469 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
1466 WebInputMethodController* active_input_method_controller = | 1470 WebInputMethodController* active_input_method_controller = |
1467 frame->GetInputMethodController(); | 1471 frame->GetInputMethodController(); |
1468 frame->SetEditableSelectionOffsets(4, 10); | 1472 frame->SetEditableSelectionOffsets(4, 10); |
1469 frame->SetCompositionFromExistingText(8, 12, underlines); | 1473 frame->SetCompositionFromExistingText(8, 12, underlines); |
1470 WebTextInputInfo info = active_input_method_controller->TextInputInfo(); | 1474 WebTextInputInfo info = active_input_method_controller->TextInputInfo(); |
1471 EXPECT_EQ(4, info.selection_start); | 1475 EXPECT_EQ(4, info.selection_start); |
1472 EXPECT_EQ(10, info.selection_end); | 1476 EXPECT_EQ(10, info.selection_end); |
1473 EXPECT_EQ(8, info.composition_start); | 1477 EXPECT_EQ(8, info.composition_start); |
1474 EXPECT_EQ(12, info.composition_end); | 1478 EXPECT_EQ(12, info.composition_end); |
1475 WebVector<WebCompositionUnderline> empty_underlines; | 1479 WebVector<WebCompositionUnderline> empty_underlines; |
1476 frame->SetCompositionFromExistingText(0, 0, empty_underlines); | 1480 frame->SetCompositionFromExistingText(0, 0, empty_underlines); |
1477 info = active_input_method_controller->TextInputInfo(); | 1481 info = active_input_method_controller->TextInputInfo(); |
1478 EXPECT_EQ(4, info.selection_start); | 1482 EXPECT_EQ(4, info.selection_start); |
1479 EXPECT_EQ(10, info.selection_end); | 1483 EXPECT_EQ(10, info.selection_end); |
1480 EXPECT_EQ(-1, info.composition_start); | 1484 EXPECT_EQ(-1, info.composition_start); |
1481 EXPECT_EQ(-1, info.composition_end); | 1485 EXPECT_EQ(-1, info.composition_end); |
1482 } | 1486 } |
1483 | 1487 |
1484 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { | 1488 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { |
1485 RegisterMockedHttpURLLoad("text_area_populated.html"); | 1489 RegisterMockedHttpURLLoad("text_area_populated.html"); |
1486 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1490 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1487 base_url_ + "text_area_populated.html"); | 1491 base_url_ + "text_area_populated.html"); |
1488 web_view->SetInitialFocus(false); | 1492 web_view->SetInitialFocus(false); |
1489 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1493 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1490 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1494 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1491 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 1495 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
1492 WebInputMethodController* active_input_method_controller = | 1496 WebInputMethodController* active_input_method_controller = |
1493 frame->FrameWidget()->GetActiveWebInputMethodController(); | 1497 frame->FrameWidget()->GetActiveWebInputMethodController(); |
1494 frame->SetEditableSelectionOffsets(27, 27); | 1498 frame->SetEditableSelectionOffsets(27, 27); |
1495 std::string new_line_text("\n"); | 1499 std::string new_line_text("\n"); |
1496 WebVector<WebCompositionUnderline> empty_underlines; | 1500 WebVector<WebCompositionUnderline> empty_underlines; |
(...skipping 22 matching lines...) Expand all Loading... |
1519 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", | 1523 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", |
1520 std::string(info.value.Utf8().data())); | 1524 std::string(info.value.Utf8().data())); |
1521 EXPECT_EQ(34, info.selection_start); | 1525 EXPECT_EQ(34, info.selection_start); |
1522 EXPECT_EQ(34, info.selection_end); | 1526 EXPECT_EQ(34, info.selection_end); |
1523 EXPECT_EQ(-1, info.composition_start); | 1527 EXPECT_EQ(-1, info.composition_start); |
1524 EXPECT_EQ(-1, info.composition_end); | 1528 EXPECT_EQ(-1, info.composition_end); |
1525 } | 1529 } |
1526 | 1530 |
1527 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { | 1531 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { |
1528 RegisterMockedHttpURLLoad("content_editable_rich_text.html"); | 1532 RegisterMockedHttpURLLoad("content_editable_rich_text.html"); |
1529 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1533 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1530 base_url_ + "content_editable_rich_text.html"); | 1534 base_url_ + "content_editable_rich_text.html"); |
1531 web_view->SetInitialFocus(false); | 1535 web_view->SetInitialFocus(false); |
1532 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1536 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1533 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1537 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1534 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 1538 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
1535 frame->SetEditableSelectionOffsets(1, 1); | 1539 frame->SetEditableSelectionOffsets(1, 1); |
1536 WebDocument document = web_view->MainFrame()->GetDocument(); | 1540 WebDocument document = web_view->MainFrame()->GetDocument(); |
1537 EXPECT_FALSE(document.GetElementById("bold").IsNull()); | 1541 EXPECT_FALSE(document.GetElementById("bold").IsNull()); |
1538 frame->SetCompositionFromExistingText(0, 4, underlines); | 1542 frame->SetCompositionFromExistingText(0, 4, underlines); |
1539 EXPECT_FALSE(document.GetElementById("bold").IsNull()); | 1543 EXPECT_FALSE(document.GetElementById("bold").IsNull()); |
1540 } | 1544 } |
1541 | 1545 |
1542 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { | 1546 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { |
1543 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1547 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1544 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1548 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1545 base_url_ + "input_field_populated.html"); | 1549 base_url_ + "input_field_populated.html"); |
1546 web_view->SetInitialFocus(false); | 1550 web_view->SetInitialFocus(false); |
1547 | 1551 |
1548 std::string composition_text_first("hello "); | 1552 std::string composition_text_first("hello "); |
1549 std::string composition_text_second("world"); | 1553 std::string composition_text_second("world"); |
1550 WebVector<WebCompositionUnderline> empty_underlines; | 1554 WebVector<WebCompositionUnderline> empty_underlines; |
1551 WebInputMethodController* active_input_method_controller = | 1555 WebInputMethodController* active_input_method_controller = |
1552 web_view->MainFrameImpl() | 1556 web_view->MainFrameImpl() |
1553 ->FrameWidget() | 1557 ->FrameWidget() |
1554 ->GetActiveWebInputMethodController(); | 1558 ->GetActiveWebInputMethodController(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 EXPECT_EQ("hello world", std::string(info.value.Utf8().data())); | 1608 EXPECT_EQ("hello world", std::string(info.value.Utf8().data())); |
1605 EXPECT_EQ(2, info.selection_start); | 1609 EXPECT_EQ(2, info.selection_start); |
1606 EXPECT_EQ(2, info.selection_end); | 1610 EXPECT_EQ(2, info.selection_end); |
1607 // Composition range should be reset by browser process or keyboard apps. | 1611 // Composition range should be reset by browser process or keyboard apps. |
1608 EXPECT_EQ(6, info.composition_start); | 1612 EXPECT_EQ(6, info.composition_start); |
1609 EXPECT_EQ(11, info.composition_end); | 1613 EXPECT_EQ(11, info.composition_end); |
1610 } | 1614 } |
1611 | 1615 |
1612 TEST_P(WebViewTest, IsSelectionAnchorFirst) { | 1616 TEST_P(WebViewTest, IsSelectionAnchorFirst) { |
1613 RegisterMockedHttpURLLoad("input_field_populated.html"); | 1617 RegisterMockedHttpURLLoad("input_field_populated.html"); |
1614 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 1618 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
1615 base_url_ + "input_field_populated.html"); | 1619 base_url_ + "input_field_populated.html"); |
1616 WebLocalFrame* frame = web_view->MainFrameImpl(); | 1620 WebLocalFrame* frame = web_view->MainFrameImpl(); |
1617 | 1621 |
1618 web_view->SetInitialFocus(false); | 1622 web_view->SetInitialFocus(false); |
1619 frame->SetEditableSelectionOffsets(4, 10); | 1623 frame->SetEditableSelectionOffsets(4, 10); |
1620 EXPECT_TRUE(web_view->IsSelectionAnchorFirst()); | 1624 EXPECT_TRUE(web_view->IsSelectionAnchorFirst()); |
1621 WebRect anchor; | 1625 WebRect anchor; |
1622 WebRect focus; | 1626 WebRect focus; |
1623 web_view->SelectionBounds(anchor, focus); | 1627 web_view->SelectionBounds(anchor, focus); |
1624 frame->SelectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y)); | 1628 frame->SelectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y)); |
1625 EXPECT_FALSE(web_view->IsSelectionAnchorFirst()); | 1629 EXPECT_FALSE(web_view->IsSelectionAnchorFirst()); |
1626 } | 1630 } |
1627 | 1631 |
1628 TEST_P(WebViewTest, ExitingDeviceEmulationResetsPageScale) { | 1632 TEST_P(WebViewTest, ExitingDeviceEmulationResetsPageScale) { |
1629 RegisterMockedHttpURLLoad("200-by-300.html"); | 1633 RegisterMockedHttpURLLoad("200-by-300.html"); |
1630 WebViewImpl* web_view_impl = | 1634 WebViewBase* web_view_impl = |
1631 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1635 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
1632 web_view_impl->Resize(WebSize(200, 300)); | 1636 web_view_impl->Resize(WebSize(200, 300)); |
1633 | 1637 |
1634 float page_scale_expected = web_view_impl->PageScaleFactor(); | 1638 float page_scale_expected = web_view_impl->PageScaleFactor(); |
1635 | 1639 |
1636 WebDeviceEmulationParams params; | 1640 WebDeviceEmulationParams params; |
1637 params.screen_position = WebDeviceEmulationParams::kDesktop; | 1641 params.screen_position = WebDeviceEmulationParams::kDesktop; |
1638 params.device_scale_factor = 0; | 1642 params.device_scale_factor = 0; |
1639 params.fit_to_view = false; | 1643 params.fit_to_view = false; |
1640 params.offset = WebFloatPoint(); | 1644 params.offset = WebFloatPoint(); |
1641 params.scale = 1; | 1645 params.scale = 1; |
1642 | 1646 |
1643 web_view_impl->EnableDeviceEmulation(params); | 1647 web_view_impl->EnableDeviceEmulation(params); |
1644 | 1648 |
1645 web_view_impl->SetPageScaleFactor(2); | 1649 web_view_impl->SetPageScaleFactor(2); |
1646 | 1650 |
1647 web_view_impl->DisableDeviceEmulation(); | 1651 web_view_impl->DisableDeviceEmulation(); |
1648 | 1652 |
1649 EXPECT_EQ(page_scale_expected, web_view_impl->PageScaleFactor()); | 1653 EXPECT_EQ(page_scale_expected, web_view_impl->PageScaleFactor()); |
1650 } | 1654 } |
1651 | 1655 |
1652 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { | 1656 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { |
1653 RegisterMockedHttpURLLoad("200-by-300.html"); | 1657 RegisterMockedHttpURLLoad("200-by-300.html"); |
1654 WebViewImpl* web_view_impl = | 1658 WebViewBase* web_view_impl = |
1655 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1659 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
1656 web_view_impl->Resize(WebSize(100, 150)); | 1660 web_view_impl->Resize(WebSize(100, 150)); |
1657 web_view_impl->UpdateAllLifecyclePhases(); | 1661 web_view_impl->UpdateAllLifecyclePhases(); |
1658 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1662 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); |
1659 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1663 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); |
1660 | 1664 |
1661 // Make the page scale and scroll with the given paremeters. | 1665 // Make the page scale and scroll with the given paremeters. |
1662 web_view_impl->SetPageScaleFactor(2.0f); | 1666 web_view_impl->SetPageScaleFactor(2.0f); |
1663 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); | 1667 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); |
1664 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1668 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 .Width()); | 1702 .Width()); |
1699 EXPECT_EQ(0, main_frame_local->Loader() | 1703 EXPECT_EQ(0, main_frame_local->Loader() |
1700 .GetDocumentLoader() | 1704 .GetDocumentLoader() |
1701 ->GetHistoryItem() | 1705 ->GetHistoryItem() |
1702 ->GetScrollOffset() | 1706 ->GetScrollOffset() |
1703 .Height()); | 1707 .Height()); |
1704 } | 1708 } |
1705 | 1709 |
1706 TEST_P(WebViewTest, BackForwardRestoreScroll) { | 1710 TEST_P(WebViewTest, BackForwardRestoreScroll) { |
1707 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); | 1711 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); |
1708 WebViewImpl* web_view_impl = web_view_helper_.InitializeAndLoad( | 1712 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( |
1709 base_url_ + "back_forward_restore_scroll.html"); | 1713 base_url_ + "back_forward_restore_scroll.html"); |
1710 web_view_impl->Resize(WebSize(640, 480)); | 1714 web_view_impl->Resize(WebSize(640, 480)); |
1711 web_view_impl->UpdateAllLifecyclePhases(); | 1715 web_view_impl->UpdateAllLifecyclePhases(); |
1712 | 1716 |
1713 // Emulate a user scroll | 1717 // Emulate a user scroll |
1714 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 900)); | 1718 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 900)); |
1715 LocalFrame* main_frame_local = | 1719 LocalFrame* main_frame_local = |
1716 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); | 1720 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); |
1717 Persistent<HistoryItem> item1 = | 1721 Persistent<HistoryItem> item1 = |
1718 main_frame_local->Loader().GetDocumentLoader()->GetHistoryItem(); | 1722 main_frame_local->Loader().GetDocumentLoader()->GetHistoryItem(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 WebCachePolicy::kUseProtocolCachePolicy)), | 1760 WebCachePolicy::kUseProtocolCachePolicy)), |
1757 kFrameLoadTypeBackForward, item3.Get(), kHistorySameDocumentLoad); | 1761 kFrameLoadTypeBackForward, item3.Get(), kHistorySameDocumentLoad); |
1758 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1762 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); |
1759 EXPECT_GT(web_view_impl->MainFrame()->GetScrollOffset().height, 2000); | 1763 EXPECT_GT(web_view_impl->MainFrame()->GetScrollOffset().height, 2000); |
1760 } | 1764 } |
1761 | 1765 |
1762 // Tests that we restore scroll and scale *after* the fullscreen styles are | 1766 // Tests that we restore scroll and scale *after* the fullscreen styles are |
1763 // removed and the page is laid out. http://crbug.com/625683. | 1767 // removed and the page is laid out. http://crbug.com/625683. |
1764 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { | 1768 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { |
1765 RegisterMockedHttpURLLoad("fullscreen_style.html"); | 1769 RegisterMockedHttpURLLoad("fullscreen_style.html"); |
1766 WebViewImpl* web_view_impl = | 1770 WebViewBase* web_view_impl = |
1767 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); | 1771 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); |
1768 web_view_impl->Resize(WebSize(800, 600)); | 1772 web_view_impl->Resize(WebSize(800, 600)); |
1769 web_view_impl->UpdateAllLifecyclePhases(); | 1773 web_view_impl->UpdateAllLifecyclePhases(); |
1770 | 1774 |
1771 // Scroll the page down. | 1775 // Scroll the page down. |
1772 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 1776 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); |
1773 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1777 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); |
1774 | 1778 |
1775 // Enter fullscreen. | 1779 // Enter fullscreen. |
1776 Document* document = | 1780 Document* document = |
(...skipping 19 matching lines...) Expand all Loading... |
1796 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); | 1800 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); |
1797 web_view_impl->UpdateAllLifecyclePhases(); | 1801 web_view_impl->UpdateAllLifecyclePhases(); |
1798 | 1802 |
1799 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1803 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); |
1800 } | 1804 } |
1801 | 1805 |
1802 // Tests that exiting and immediately reentering fullscreen doesn't cause the | 1806 // Tests that exiting and immediately reentering fullscreen doesn't cause the |
1803 // scroll and scale restoration to occur when we enter fullscreen again. | 1807 // scroll and scale restoration to occur when we enter fullscreen again. |
1804 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { | 1808 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { |
1805 RegisterMockedHttpURLLoad("fullscreen_style.html"); | 1809 RegisterMockedHttpURLLoad("fullscreen_style.html"); |
1806 WebViewImpl* web_view_impl = | 1810 WebViewBase* web_view_impl = |
1807 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); | 1811 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); |
1808 web_view_impl->Resize(WebSize(800, 600)); | 1812 web_view_impl->Resize(WebSize(800, 600)); |
1809 web_view_impl->UpdateAllLifecyclePhases(); | 1813 web_view_impl->UpdateAllLifecyclePhases(); |
1810 | 1814 |
1811 // Scroll the page down. | 1815 // Scroll the page down. |
1812 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 1816 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); |
1813 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1817 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); |
1814 | 1818 |
1815 // Enter fullscreen. | 1819 // Enter fullscreen. |
1816 Document* document = | 1820 Document* document = |
(...skipping 28 matching lines...) Expand all Loading... |
1845 | 1849 |
1846 // When we exit now, we should restore the original scroll value. | 1850 // When we exit now, we should restore the original scroll value. |
1847 web_view_impl->DidExitFullscreen(); | 1851 web_view_impl->DidExitFullscreen(); |
1848 web_view_impl->UpdateAllLifecyclePhases(); | 1852 web_view_impl->UpdateAllLifecyclePhases(); |
1849 | 1853 |
1850 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1854 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); |
1851 } | 1855 } |
1852 | 1856 |
1853 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { | 1857 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { |
1854 RegisterMockedHttpURLLoad("200-by-300.html"); | 1858 RegisterMockedHttpURLLoad("200-by-300.html"); |
1855 WebViewImpl* web_view_impl = | 1859 WebViewBase* web_view_impl = |
1856 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1860 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
1857 web_view_impl->Resize(WebSize(100, 150)); | 1861 web_view_impl->Resize(WebSize(100, 150)); |
1858 web_view_impl->UpdateAllLifecyclePhases(); | 1862 web_view_impl->UpdateAllLifecyclePhases(); |
1859 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1863 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); |
1860 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1864 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); |
1861 | 1865 |
1862 // Make the page scale and scroll with the given paremeters. | 1866 // Make the page scale and scroll with the given paremeters. |
1863 web_view_impl->SetPageScaleFactor(2.0f); | 1867 web_view_impl->SetPageScaleFactor(2.0f); |
1864 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); | 1868 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); |
1865 web_view_impl->SetVisualViewportOffset(WebFloatPoint(12, 20)); | 1869 web_view_impl->SetVisualViewportOffset(WebFloatPoint(12, 20)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 | 1908 |
1905 bool PrintCalled() const { return print_called_; } | 1909 bool PrintCalled() const { return print_called_; } |
1906 | 1910 |
1907 private: | 1911 private: |
1908 bool print_called_; | 1912 bool print_called_; |
1909 }; | 1913 }; |
1910 | 1914 |
1911 TEST_P(WebViewTest, PrintWithXHRInFlight) { | 1915 TEST_P(WebViewTest, PrintWithXHRInFlight) { |
1912 PrintWebViewClient client; | 1916 PrintWebViewClient client; |
1913 RegisterMockedHttpURLLoad("print_with_xhr_inflight.html"); | 1917 RegisterMockedHttpURLLoad("print_with_xhr_inflight.html"); |
1914 WebViewImpl* web_view_impl = web_view_helper_.InitializeAndLoad( | 1918 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( |
1915 base_url_ + "print_with_xhr_inflight.html", true, 0, &client); | 1919 base_url_ + "print_with_xhr_inflight.html", true, 0, &client); |
1916 | 1920 |
1917 ASSERT_TRUE(ToLocalFrame(web_view_impl->GetPage()->MainFrame()) | 1921 ASSERT_TRUE(ToLocalFrame(web_view_impl->GetPage()->MainFrame()) |
1918 ->GetDocument() | 1922 ->GetDocument() |
1919 ->LoadEventFinished()); | 1923 ->LoadEventFinished()); |
1920 EXPECT_TRUE(client.PrintCalled()); | 1924 EXPECT_TRUE(client.PrintCalled()); |
1921 web_view_helper_.Reset(); | 1925 web_view_helper_.Reset(); |
1922 } | 1926 } |
1923 | 1927 |
1924 static void DragAndDropURL(WebViewImpl* web_view, const std::string& url) { | 1928 static void DragAndDropURL(WebViewBase* web_view, const std::string& url) { |
1925 WebDragData drag_data; | 1929 WebDragData drag_data; |
1926 drag_data.Initialize(); | 1930 drag_data.Initialize(); |
1927 | 1931 |
1928 WebDragData::Item item; | 1932 WebDragData::Item item; |
1929 item.storage_type = WebDragData::Item::kStorageTypeString; | 1933 item.storage_type = WebDragData::Item::kStorageTypeString; |
1930 item.string_type = "text/uri-list"; | 1934 item.string_type = "text/uri-list"; |
1931 item.string_data = WebString::FromUTF8(url); | 1935 item.string_data = WebString::FromUTF8(url); |
1932 drag_data.AddItem(item); | 1936 drag_data.AddItem(item); |
1933 | 1937 |
1934 const WebPoint client_point(0, 0); | 1938 const WebPoint client_point(0, 0); |
1935 const WebPoint screen_point(0, 0); | 1939 const WebPoint screen_point(0, 0); |
1936 WebFrameWidgetBase* widget = web_view->MainFrameImpl()->FrameWidget(); | 1940 WebFrameWidgetBase* widget = web_view->MainFrameImpl()->FrameWidget(); |
1937 widget->DragTargetDragEnter(drag_data, client_point, screen_point, | 1941 widget->DragTargetDragEnter(drag_data, client_point, screen_point, |
1938 kWebDragOperationCopy, 0); | 1942 kWebDragOperationCopy, 0); |
1939 widget->DragTargetDrop(drag_data, client_point, screen_point, 0); | 1943 widget->DragTargetDrop(drag_data, client_point, screen_point, 0); |
1940 FrameTestHelpers::PumpPendingRequestsForFrameToLoad(web_view->MainFrame()); | 1944 FrameTestHelpers::PumpPendingRequestsForFrameToLoad(web_view->MainFrame()); |
1941 } | 1945 } |
1942 | 1946 |
1943 TEST_P(WebViewTest, DragDropURL) { | 1947 TEST_P(WebViewTest, DragDropURL) { |
1944 RegisterMockedHttpURLLoad("foo.html"); | 1948 RegisterMockedHttpURLLoad("foo.html"); |
1945 RegisterMockedHttpURLLoad("bar.html"); | 1949 RegisterMockedHttpURLLoad("bar.html"); |
1946 | 1950 |
1947 const std::string foo_url = base_url_ + "foo.html"; | 1951 const std::string foo_url = base_url_ + "foo.html"; |
1948 const std::string bar_url = base_url_ + "bar.html"; | 1952 const std::string bar_url = base_url_ + "bar.html"; |
1949 | 1953 |
1950 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad(foo_url); | 1954 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(foo_url); |
1951 | 1955 |
1952 ASSERT_TRUE(web_view); | 1956 ASSERT_TRUE(web_view); |
1953 | 1957 |
1954 // Drag and drop barUrl and verify that we've navigated to it. | 1958 // Drag and drop barUrl and verify that we've navigated to it. |
1955 DragAndDropURL(web_view, bar_url); | 1959 DragAndDropURL(web_view, bar_url); |
1956 EXPECT_EQ(bar_url, | 1960 EXPECT_EQ(bar_url, |
1957 web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); | 1961 web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); |
1958 | 1962 |
1959 // Drag and drop fooUrl and verify that we've navigated back to it. | 1963 // Drag and drop fooUrl and verify that we've navigated back to it. |
1960 DragAndDropURL(web_view, foo_url); | 1964 DragAndDropURL(web_view, foo_url); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 web_view->HandleInputEvent(WebCoalescedInputEvent(event)); | 2045 web_view->HandleInputEvent(WebCoalescedInputEvent(event)); |
2042 RunPendingTasks(); | 2046 RunPendingTasks(); |
2043 EXPECT_EQ(25, client.LongpressX()); | 2047 EXPECT_EQ(25, client.LongpressX()); |
2044 EXPECT_EQ(7, client.LongpressY()); | 2048 EXPECT_EQ(7, client.LongpressY()); |
2045 | 2049 |
2046 // Explicitly reset to break dependency on locally scoped client. | 2050 // Explicitly reset to break dependency on locally scoped client. |
2047 web_view_helper_.Reset(); | 2051 web_view_helper_.Reset(); |
2048 } | 2052 } |
2049 | 2053 |
2050 TEST_P(WebViewTest, ClientTapHandlingNullWebViewClient) { | 2054 TEST_P(WebViewTest, ClientTapHandlingNullWebViewClient) { |
2051 WebViewImpl* web_view = | 2055 WebViewBase* web_view = static_cast<WebViewBase*>( |
2052 WebViewImpl::Create(nullptr, kWebPageVisibilityStateVisible); | 2056 WebView::Create(nullptr, kWebPageVisibilityStateVisible)); |
2053 FrameTestHelpers::TestWebFrameClient web_frame_client; | 2057 FrameTestHelpers::TestWebFrameClient web_frame_client; |
2054 FrameTestHelpers::TestWebWidgetClient web_widget_client; | 2058 FrameTestHelpers::TestWebWidgetClient web_widget_client; |
2055 WebLocalFrame* local_frame = WebLocalFrame::Create( | 2059 WebLocalFrame* local_frame = WebLocalFrame::Create( |
2056 WebTreeScopeType::kDocument, &web_frame_client, nullptr, nullptr); | 2060 WebTreeScopeType::kDocument, &web_frame_client, nullptr, nullptr); |
2057 web_view->SetMainFrame(local_frame); | 2061 web_view->SetMainFrame(local_frame); |
2058 | 2062 |
2059 // TODO(dcheng): The main frame widget currently has a special case. | 2063 // TODO(dcheng): The main frame widget currently has a special case. |
2060 // Eliminate this once WebView is no longer a WebWidget. | 2064 // Eliminate this once WebView is no longer a WebWidget. |
2061 blink::WebFrameWidget::Create(&web_widget_client, web_view, local_frame); | 2065 blink::WebFrameWidget::Create(&web_widget_client, web_view, local_frame); |
2062 | 2066 |
2063 WebGestureEvent event(WebInputEvent::kGestureTap, WebInputEvent::kNoModifiers, | 2067 WebGestureEvent event(WebInputEvent::kGestureTap, WebInputEvent::kNoModifiers, |
2064 WebInputEvent::kTimeStampForTesting); | 2068 WebInputEvent::kTimeStampForTesting); |
2065 event.source_device = kWebGestureDeviceTouchscreen; | 2069 event.source_device = kWebGestureDeviceTouchscreen; |
2066 event.x = 3; | 2070 event.x = 3; |
2067 event.y = 8; | 2071 event.y = 8; |
2068 EXPECT_EQ(WebInputEventResult::kNotHandled, | 2072 EXPECT_EQ(WebInputEventResult::kNotHandled, |
2069 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2073 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2070 web_view->Close(); | 2074 web_view->Close(); |
2071 } | 2075 } |
2072 | 2076 |
2073 TEST_P(WebViewTest, LongPressEmptyDiv) { | 2077 TEST_P(WebViewTest, LongPressEmptyDiv) { |
2074 RegisterMockedHttpURLLoad("long_press_empty_div.html"); | 2078 RegisterMockedHttpURLLoad("long_press_empty_div.html"); |
2075 | 2079 |
2076 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2080 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2077 base_url_ + "long_press_empty_div.html", true); | 2081 base_url_ + "long_press_empty_div.html", true); |
2078 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2082 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); |
2079 web_view->Resize(WebSize(500, 300)); | 2083 web_view->Resize(WebSize(500, 300)); |
2080 web_view->UpdateAllLifecyclePhases(); | 2084 web_view->UpdateAllLifecyclePhases(); |
2081 RunPendingTasks(); | 2085 RunPendingTasks(); |
2082 | 2086 |
2083 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2087 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2084 WebInputEvent::kNoModifiers, | 2088 WebInputEvent::kNoModifiers, |
2085 WebInputEvent::kTimeStampForTesting); | 2089 WebInputEvent::kTimeStampForTesting); |
2086 event.source_device = kWebGestureDeviceTouchscreen; | 2090 event.source_device = kWebGestureDeviceTouchscreen; |
2087 event.x = 250; | 2091 event.x = 250; |
2088 event.y = 150; | 2092 event.y = 150; |
2089 | 2093 |
2090 EXPECT_EQ(WebInputEventResult::kNotHandled, | 2094 EXPECT_EQ(WebInputEventResult::kNotHandled, |
2091 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2095 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2092 } | 2096 } |
2093 | 2097 |
2094 TEST_P(WebViewTest, LongPressEmptyDivAlwaysShow) { | 2098 TEST_P(WebViewTest, LongPressEmptyDivAlwaysShow) { |
2095 RegisterMockedHttpURLLoad("long_press_empty_div.html"); | 2099 RegisterMockedHttpURLLoad("long_press_empty_div.html"); |
2096 | 2100 |
2097 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2101 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2098 base_url_ + "long_press_empty_div.html", true); | 2102 base_url_ + "long_press_empty_div.html", true); |
2099 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); | 2103 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); |
2100 web_view->Resize(WebSize(500, 300)); | 2104 web_view->Resize(WebSize(500, 300)); |
2101 web_view->UpdateAllLifecyclePhases(); | 2105 web_view->UpdateAllLifecyclePhases(); |
2102 RunPendingTasks(); | 2106 RunPendingTasks(); |
2103 | 2107 |
2104 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2108 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2105 WebInputEvent::kNoModifiers, | 2109 WebInputEvent::kNoModifiers, |
2106 WebInputEvent::kTimeStampForTesting); | 2110 WebInputEvent::kTimeStampForTesting); |
2107 event.source_device = kWebGestureDeviceTouchscreen; | 2111 event.source_device = kWebGestureDeviceTouchscreen; |
2108 event.x = 250; | 2112 event.x = 250; |
2109 event.y = 150; | 2113 event.y = 150; |
2110 | 2114 |
2111 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2115 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2112 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2116 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2113 } | 2117 } |
2114 | 2118 |
2115 TEST_P(WebViewTest, LongPressObject) { | 2119 TEST_P(WebViewTest, LongPressObject) { |
2116 RegisterMockedHttpURLLoad("long_press_object.html"); | 2120 RegisterMockedHttpURLLoad("long_press_object.html"); |
2117 | 2121 |
2118 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2122 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2119 base_url_ + "long_press_object.html", true); | 2123 base_url_ + "long_press_object.html", true); |
2120 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); | 2124 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); |
2121 web_view->Resize(WebSize(500, 300)); | 2125 web_view->Resize(WebSize(500, 300)); |
2122 web_view->UpdateAllLifecyclePhases(); | 2126 web_view->UpdateAllLifecyclePhases(); |
2123 RunPendingTasks(); | 2127 RunPendingTasks(); |
2124 | 2128 |
2125 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2129 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2126 WebInputEvent::kNoModifiers, | 2130 WebInputEvent::kNoModifiers, |
2127 WebInputEvent::kTimeStampForTesting); | 2131 WebInputEvent::kTimeStampForTesting); |
2128 event.source_device = kWebGestureDeviceTouchscreen; | 2132 event.source_device = kWebGestureDeviceTouchscreen; |
2129 event.x = 10; | 2133 event.x = 10; |
2130 event.y = 10; | 2134 event.y = 10; |
2131 | 2135 |
2132 EXPECT_NE(WebInputEventResult::kHandledSystem, | 2136 EXPECT_NE(WebInputEventResult::kHandledSystem, |
2133 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2137 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2134 | 2138 |
2135 HTMLElement* element = | 2139 HTMLElement* element = |
2136 ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); | 2140 ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); |
2137 EXPECT_FALSE(element->CanStartSelection()); | 2141 EXPECT_FALSE(element->CanStartSelection()); |
2138 } | 2142 } |
2139 | 2143 |
2140 TEST_P(WebViewTest, LongPressObjectFallback) { | 2144 TEST_P(WebViewTest, LongPressObjectFallback) { |
2141 RegisterMockedHttpURLLoad("long_press_object_fallback.html"); | 2145 RegisterMockedHttpURLLoad("long_press_object_fallback.html"); |
2142 | 2146 |
2143 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2147 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2144 base_url_ + "long_press_object_fallback.html", true); | 2148 base_url_ + "long_press_object_fallback.html", true); |
2145 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); | 2149 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); |
2146 web_view->Resize(WebSize(500, 300)); | 2150 web_view->Resize(WebSize(500, 300)); |
2147 web_view->UpdateAllLifecyclePhases(); | 2151 web_view->UpdateAllLifecyclePhases(); |
2148 RunPendingTasks(); | 2152 RunPendingTasks(); |
2149 | 2153 |
2150 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2154 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2151 WebInputEvent::kNoModifiers, | 2155 WebInputEvent::kNoModifiers, |
2152 WebInputEvent::kTimeStampForTesting); | 2156 WebInputEvent::kTimeStampForTesting); |
2153 event.source_device = kWebGestureDeviceTouchscreen; | 2157 event.source_device = kWebGestureDeviceTouchscreen; |
2154 event.x = 10; | 2158 event.x = 10; |
2155 event.y = 10; | 2159 event.y = 10; |
2156 | 2160 |
2157 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2161 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2158 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2162 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2159 | 2163 |
2160 HTMLElement* element = | 2164 HTMLElement* element = |
2161 ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); | 2165 ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); |
2162 EXPECT_TRUE(element->CanStartSelection()); | 2166 EXPECT_TRUE(element->CanStartSelection()); |
2163 } | 2167 } |
2164 | 2168 |
2165 TEST_P(WebViewTest, LongPressImage) { | 2169 TEST_P(WebViewTest, LongPressImage) { |
2166 RegisterMockedHttpURLLoad("long_press_image.html"); | 2170 RegisterMockedHttpURLLoad("long_press_image.html"); |
2167 | 2171 |
2168 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2172 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2169 base_url_ + "long_press_image.html", true); | 2173 base_url_ + "long_press_image.html", true); |
2170 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2174 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); |
2171 web_view->Resize(WebSize(500, 300)); | 2175 web_view->Resize(WebSize(500, 300)); |
2172 web_view->UpdateAllLifecyclePhases(); | 2176 web_view->UpdateAllLifecyclePhases(); |
2173 RunPendingTasks(); | 2177 RunPendingTasks(); |
2174 | 2178 |
2175 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2179 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2176 WebInputEvent::kNoModifiers, | 2180 WebInputEvent::kNoModifiers, |
2177 WebInputEvent::kTimeStampForTesting); | 2181 WebInputEvent::kTimeStampForTesting); |
2178 event.source_device = kWebGestureDeviceTouchscreen; | 2182 event.source_device = kWebGestureDeviceTouchscreen; |
2179 event.x = 10; | 2183 event.x = 10; |
2180 event.y = 10; | 2184 event.y = 10; |
2181 | 2185 |
2182 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2186 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2183 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2187 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2184 } | 2188 } |
2185 | 2189 |
2186 TEST_P(WebViewTest, LongPressVideo) { | 2190 TEST_P(WebViewTest, LongPressVideo) { |
2187 RegisterMockedHttpURLLoad("long_press_video.html"); | 2191 RegisterMockedHttpURLLoad("long_press_video.html"); |
2188 | 2192 |
2189 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2193 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2190 base_url_ + "long_press_video.html", true); | 2194 base_url_ + "long_press_video.html", true); |
2191 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2195 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); |
2192 web_view->Resize(WebSize(500, 300)); | 2196 web_view->Resize(WebSize(500, 300)); |
2193 web_view->UpdateAllLifecyclePhases(); | 2197 web_view->UpdateAllLifecyclePhases(); |
2194 RunPendingTasks(); | 2198 RunPendingTasks(); |
2195 | 2199 |
2196 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2200 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2197 WebInputEvent::kNoModifiers, | 2201 WebInputEvent::kNoModifiers, |
2198 WebInputEvent::kTimeStampForTesting); | 2202 WebInputEvent::kTimeStampForTesting); |
2199 event.source_device = kWebGestureDeviceTouchscreen; | 2203 event.source_device = kWebGestureDeviceTouchscreen; |
2200 event.x = 10; | 2204 event.x = 10; |
2201 event.y = 10; | 2205 event.y = 10; |
2202 | 2206 |
2203 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2207 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2204 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2208 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2205 } | 2209 } |
2206 | 2210 |
2207 TEST_P(WebViewTest, LongPressLink) { | 2211 TEST_P(WebViewTest, LongPressLink) { |
2208 RegisterMockedHttpURLLoad("long_press_link.html"); | 2212 RegisterMockedHttpURLLoad("long_press_link.html"); |
2209 | 2213 |
2210 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2214 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2211 base_url_ + "long_press_link.html", true); | 2215 base_url_ + "long_press_link.html", true); |
2212 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2216 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); |
2213 web_view->Resize(WebSize(500, 300)); | 2217 web_view->Resize(WebSize(500, 300)); |
2214 web_view->UpdateAllLifecyclePhases(); | 2218 web_view->UpdateAllLifecyclePhases(); |
2215 RunPendingTasks(); | 2219 RunPendingTasks(); |
2216 | 2220 |
2217 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2221 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2218 WebInputEvent::kNoModifiers, | 2222 WebInputEvent::kNoModifiers, |
2219 WebInputEvent::kTimeStampForTesting); | 2223 WebInputEvent::kTimeStampForTesting); |
2220 event.source_device = kWebGestureDeviceTouchscreen; | 2224 event.source_device = kWebGestureDeviceTouchscreen; |
2221 event.x = 500; | 2225 event.x = 500; |
2222 event.y = 300; | 2226 event.y = 300; |
2223 | 2227 |
2224 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2228 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2225 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2229 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2226 } | 2230 } |
2227 | 2231 |
2228 TEST_P(WebViewTest, showContextMenuOnLongPressingLinks) { | 2232 TEST_P(WebViewTest, showContextMenuOnLongPressingLinks) { |
2229 RegisterMockedHttpURLLoad("long_press_links_and_images.html"); | 2233 RegisterMockedHttpURLLoad("long_press_links_and_images.html"); |
2230 | 2234 |
2231 URLTestHelpers::RegisterMockedURLLoad( | 2235 URLTestHelpers::RegisterMockedURLLoad( |
2232 ToKURL("http://www.test.com/foo.png"), | 2236 ToKURL("http://www.test.com/foo.png"), |
2233 testing::WebTestDataPath("white-1x1.png")); | 2237 testing::WebTestDataPath("white-1x1.png")); |
2234 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2238 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2235 base_url_ + "long_press_links_and_images.html", true); | 2239 base_url_ + "long_press_links_and_images.html", true); |
2236 | 2240 |
2237 web_view->SettingsImpl()->SetTouchDragDropEnabled(true); | 2241 web_view->SettingsImpl()->SetTouchDragDropEnabled(true); |
2238 web_view->Resize(WebSize(500, 300)); | 2242 web_view->Resize(WebSize(500, 300)); |
2239 web_view->UpdateAllLifecyclePhases(); | 2243 web_view->UpdateAllLifecyclePhases(); |
2240 RunPendingTasks(); | 2244 RunPendingTasks(); |
2241 | 2245 |
2242 WebString anchor_tag_id = WebString::FromUTF8("anchorTag"); | 2246 WebString anchor_tag_id = WebString::FromUTF8("anchorTag"); |
2243 WebString image_tag_id = WebString::FromUTF8("imageTag"); | 2247 WebString image_tag_id = WebString::FromUTF8("imageTag"); |
2244 | 2248 |
2245 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, anchor_tag_id)); | 2249 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, anchor_tag_id)); |
2246 EXPECT_STREQ("anchor contextmenu", | 2250 EXPECT_STREQ("anchor contextmenu", |
2247 web_view->MainFrame()->GetDocument().Title().Utf8().data()); | 2251 web_view->MainFrame()->GetDocument().Title().Utf8().data()); |
2248 | 2252 |
2249 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image_tag_id)); | 2253 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image_tag_id)); |
2250 EXPECT_STREQ("image contextmenu", | 2254 EXPECT_STREQ("image contextmenu", |
2251 web_view->MainFrame()->GetDocument().Title().Utf8().data()); | 2255 web_view->MainFrame()->GetDocument().Title().Utf8().data()); |
2252 } | 2256 } |
2253 | 2257 |
2254 TEST_P(WebViewTest, LongPressEmptyEditableSelection) { | 2258 TEST_P(WebViewTest, LongPressEmptyEditableSelection) { |
2255 RegisterMockedHttpURLLoad("long_press_empty_editable_selection.html"); | 2259 RegisterMockedHttpURLLoad("long_press_empty_editable_selection.html"); |
2256 | 2260 |
2257 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2261 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2258 base_url_ + "long_press_empty_editable_selection.html", true); | 2262 base_url_ + "long_press_empty_editable_selection.html", true); |
2259 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2263 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); |
2260 web_view->Resize(WebSize(500, 300)); | 2264 web_view->Resize(WebSize(500, 300)); |
2261 web_view->UpdateAllLifecyclePhases(); | 2265 web_view->UpdateAllLifecyclePhases(); |
2262 RunPendingTasks(); | 2266 RunPendingTasks(); |
2263 | 2267 |
2264 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2268 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2265 WebInputEvent::kNoModifiers, | 2269 WebInputEvent::kNoModifiers, |
2266 WebInputEvent::kTimeStampForTesting); | 2270 WebInputEvent::kTimeStampForTesting); |
2267 event.source_device = kWebGestureDeviceTouchscreen; | 2271 event.source_device = kWebGestureDeviceTouchscreen; |
2268 event.x = 10; | 2272 event.x = 10; |
2269 event.y = 10; | 2273 event.y = 10; |
2270 | 2274 |
2271 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2275 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2272 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2276 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2273 } | 2277 } |
2274 | 2278 |
2275 TEST_P(WebViewTest, LongPressEmptyNonEditableSelection) { | 2279 TEST_P(WebViewTest, LongPressEmptyNonEditableSelection) { |
2276 RegisterMockedHttpURLLoad("long_press_image.html"); | 2280 RegisterMockedHttpURLLoad("long_press_image.html"); |
2277 | 2281 |
2278 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2282 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2279 base_url_ + "long_press_image.html", true); | 2283 base_url_ + "long_press_image.html", true); |
2280 web_view->Resize(WebSize(500, 500)); | 2284 web_view->Resize(WebSize(500, 500)); |
2281 web_view->UpdateAllLifecyclePhases(); | 2285 web_view->UpdateAllLifecyclePhases(); |
2282 RunPendingTasks(); | 2286 RunPendingTasks(); |
2283 | 2287 |
2284 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2288 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
2285 WebInputEvent::kNoModifiers, | 2289 WebInputEvent::kNoModifiers, |
2286 WebInputEvent::kTimeStampForTesting); | 2290 WebInputEvent::kTimeStampForTesting); |
2287 event.source_device = kWebGestureDeviceTouchscreen; | 2291 event.source_device = kWebGestureDeviceTouchscreen; |
2288 event.x = 300; | 2292 event.x = 300; |
2289 event.y = 300; | 2293 event.y = 300; |
2290 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2294 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2291 | 2295 |
2292 EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2296 EXPECT_EQ(WebInputEventResult::kHandledSystem, |
2293 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2297 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); |
2294 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 2298 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); |
2295 } | 2299 } |
2296 | 2300 |
2297 TEST_P(WebViewTest, LongPressSelection) { | 2301 TEST_P(WebViewTest, LongPressSelection) { |
2298 RegisterMockedHttpURLLoad("longpress_selection.html"); | 2302 RegisterMockedHttpURLLoad("longpress_selection.html"); |
2299 | 2303 |
2300 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2304 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2301 base_url_ + "longpress_selection.html", true); | 2305 base_url_ + "longpress_selection.html", true); |
2302 web_view->Resize(WebSize(500, 300)); | 2306 web_view->Resize(WebSize(500, 300)); |
2303 web_view->UpdateAllLifecyclePhases(); | 2307 web_view->UpdateAllLifecyclePhases(); |
2304 RunPendingTasks(); | 2308 RunPendingTasks(); |
2305 | 2309 |
2306 WebString target = WebString::FromUTF8("target"); | 2310 WebString target = WebString::FromUTF8("target"); |
2307 WebString onselectstartfalse = WebString::FromUTF8("onselectstartfalse"); | 2311 WebString onselectstartfalse = WebString::FromUTF8("onselectstartfalse"); |
2308 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2312 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2309 | 2313 |
2310 EXPECT_TRUE( | 2314 EXPECT_TRUE( |
2311 TapElementById(WebInputEvent::kGestureLongPress, onselectstartfalse)); | 2315 TapElementById(WebInputEvent::kGestureLongPress, onselectstartfalse)); |
2312 EXPECT_EQ("", std::string(frame->SelectionAsText().Utf8().data())); | 2316 EXPECT_EQ("", std::string(frame->SelectionAsText().Utf8().data())); |
2313 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, target)); | 2317 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, target)); |
2314 EXPECT_EQ("testword", std::string(frame->SelectionAsText().Utf8().data())); | 2318 EXPECT_EQ("testword", std::string(frame->SelectionAsText().Utf8().data())); |
2315 } | 2319 } |
2316 | 2320 |
2317 TEST_P(WebViewTest, FinishComposingTextDoesNotDismissHandles) { | 2321 TEST_P(WebViewTest, FinishComposingTextDoesNotDismissHandles) { |
2318 RegisterMockedHttpURLLoad("longpress_selection.html"); | 2322 RegisterMockedHttpURLLoad("longpress_selection.html"); |
2319 | 2323 |
2320 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2324 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2321 base_url_ + "longpress_selection.html", true); | 2325 base_url_ + "longpress_selection.html", true); |
2322 web_view->Resize(WebSize(500, 300)); | 2326 web_view->Resize(WebSize(500, 300)); |
2323 web_view->UpdateAllLifecyclePhases(); | 2327 web_view->UpdateAllLifecyclePhases(); |
2324 RunPendingTasks(); | 2328 RunPendingTasks(); |
2325 | 2329 |
2326 WebString target = WebString::FromUTF8("target"); | 2330 WebString target = WebString::FromUTF8("target"); |
2327 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2331 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2328 WebInputMethodController* active_input_method_controller = | 2332 WebInputMethodController* active_input_method_controller = |
2329 frame->FrameWidget()->GetActiveWebInputMethodController(); | 2333 frame->FrameWidget()->GetActiveWebInputMethodController(); |
2330 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, target)); | 2334 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, target)); |
(...skipping 15 matching lines...) Expand all Loading... |
2346 // Check that finishComposingText(KeepSelection) does not dismiss handles. | 2350 // Check that finishComposingText(KeepSelection) does not dismiss handles. |
2347 active_input_method_controller->FinishComposingText( | 2351 active_input_method_controller->FinishComposingText( |
2348 WebInputMethodController::kKeepSelection); | 2352 WebInputMethodController::kKeepSelection); |
2349 EXPECT_TRUE(frame->GetFrame()->Selection().IsHandleVisible()); | 2353 EXPECT_TRUE(frame->GetFrame()->Selection().IsHandleVisible()); |
2350 } | 2354 } |
2351 | 2355 |
2352 #if !OS(MACOSX) | 2356 #if !OS(MACOSX) |
2353 TEST_P(WebViewTest, TouchDoesntSelectEmptyTextarea) { | 2357 TEST_P(WebViewTest, TouchDoesntSelectEmptyTextarea) { |
2354 RegisterMockedHttpURLLoad("longpress_textarea.html"); | 2358 RegisterMockedHttpURLLoad("longpress_textarea.html"); |
2355 | 2359 |
2356 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2360 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2357 base_url_ + "longpress_textarea.html", true); | 2361 base_url_ + "longpress_textarea.html", true); |
2358 web_view->Resize(WebSize(500, 300)); | 2362 web_view->Resize(WebSize(500, 300)); |
2359 web_view->UpdateAllLifecyclePhases(); | 2363 web_view->UpdateAllLifecyclePhases(); |
2360 RunPendingTasks(); | 2364 RunPendingTasks(); |
2361 | 2365 |
2362 WebString blanklinestextbox = WebString::FromUTF8("blanklinestextbox"); | 2366 WebString blanklinestextbox = WebString::FromUTF8("blanklinestextbox"); |
2363 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2367 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2364 | 2368 |
2365 // Long-press on carriage returns. | 2369 // Long-press on carriage returns. |
2366 EXPECT_TRUE( | 2370 EXPECT_TRUE( |
(...skipping 22 matching lines...) Expand all Loading... |
2389 | 2393 |
2390 // Double-tap past last word of textbox. | 2394 // Double-tap past last word of textbox. |
2391 web_view->HandleInputEvent(WebCoalescedInputEvent(event)); | 2395 web_view->HandleInputEvent(WebCoalescedInputEvent(event)); |
2392 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 2396 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); |
2393 } | 2397 } |
2394 #endif | 2398 #endif |
2395 | 2399 |
2396 TEST_P(WebViewTest, LongPressImageTextarea) { | 2400 TEST_P(WebViewTest, LongPressImageTextarea) { |
2397 RegisterMockedHttpURLLoad("longpress_image_contenteditable.html"); | 2401 RegisterMockedHttpURLLoad("longpress_image_contenteditable.html"); |
2398 | 2402 |
2399 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2403 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2400 base_url_ + "longpress_image_contenteditable.html", true); | 2404 base_url_ + "longpress_image_contenteditable.html", true); |
2401 web_view->Resize(WebSize(500, 300)); | 2405 web_view->Resize(WebSize(500, 300)); |
2402 web_view->UpdateAllLifecyclePhases(); | 2406 web_view->UpdateAllLifecyclePhases(); |
2403 RunPendingTasks(); | 2407 RunPendingTasks(); |
2404 | 2408 |
2405 WebString image = WebString::FromUTF8("purpleimage"); | 2409 WebString image = WebString::FromUTF8("purpleimage"); |
2406 | 2410 |
2407 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image)); | 2411 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image)); |
2408 WebRange range = web_view->CaretOrSelectionRange(); | 2412 WebRange range = web_view->CaretOrSelectionRange(); |
2409 EXPECT_FALSE(range.IsNull()); | 2413 EXPECT_FALSE(range.IsNull()); |
2410 EXPECT_EQ(0, range.StartOffset()); | 2414 EXPECT_EQ(0, range.StartOffset()); |
2411 EXPECT_EQ(1, range.length()); | 2415 EXPECT_EQ(1, range.length()); |
2412 } | 2416 } |
2413 | 2417 |
2414 TEST_P(WebViewTest, BlinkCaretAfterLongPress) { | 2418 TEST_P(WebViewTest, BlinkCaretAfterLongPress) { |
2415 RegisterMockedHttpURLLoad("blink_caret_on_typing_after_long_press.html"); | 2419 RegisterMockedHttpURLLoad("blink_caret_on_typing_after_long_press.html"); |
2416 | 2420 |
2417 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2421 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2418 base_url_ + "blink_caret_on_typing_after_long_press.html", true); | 2422 base_url_ + "blink_caret_on_typing_after_long_press.html", true); |
2419 web_view->Resize(WebSize(640, 480)); | 2423 web_view->Resize(WebSize(640, 480)); |
2420 web_view->UpdateAllLifecyclePhases(); | 2424 web_view->UpdateAllLifecyclePhases(); |
2421 RunPendingTasks(); | 2425 RunPendingTasks(); |
2422 | 2426 |
2423 WebString target = WebString::FromUTF8("target"); | 2427 WebString target = WebString::FromUTF8("target"); |
2424 WebLocalFrameImpl* main_frame = web_view->MainFrameImpl(); | 2428 WebLocalFrameImpl* main_frame = web_view->MainFrameImpl(); |
2425 | 2429 |
2426 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, target)); | 2430 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, target)); |
2427 EXPECT_FALSE(main_frame->GetFrame()->Selection().IsCaretBlinkingSuspended()); | 2431 EXPECT_FALSE(main_frame->GetFrame()->Selection().IsCaretBlinkingSuspended()); |
2428 } | 2432 } |
2429 | 2433 |
2430 TEST_P(WebViewTest, BlinkCaretOnClosingContextMenu) { | 2434 TEST_P(WebViewTest, BlinkCaretOnClosingContextMenu) { |
2431 RegisterMockedHttpURLLoad("form.html"); | 2435 RegisterMockedHttpURLLoad("form.html"); |
2432 WebViewImpl* web_view = | 2436 WebViewBase* web_view = |
2433 web_view_helper_.InitializeAndLoad(base_url_ + "form.html", true); | 2437 web_view_helper_.InitializeAndLoad(base_url_ + "form.html", true); |
2434 | 2438 |
2435 web_view->SetInitialFocus(false); | 2439 web_view->SetInitialFocus(false); |
2436 RunPendingTasks(); | 2440 RunPendingTasks(); |
2437 | 2441 |
2438 // We suspend caret blinking when pressing with mouse right button. | 2442 // We suspend caret blinking when pressing with mouse right button. |
2439 // Note that we do not send MouseUp event here since it will be consumed | 2443 // Note that we do not send MouseUp event here since it will be consumed |
2440 // by the context menu once it shows up. | 2444 // by the context menu once it shows up. |
2441 WebMouseEvent mouse_event(WebInputEvent::kMouseDown, | 2445 WebMouseEvent mouse_event(WebInputEvent::kMouseDown, |
2442 WebInputEvent::kNoModifiers, | 2446 WebInputEvent::kNoModifiers, |
(...skipping 13 matching lines...) Expand all Loading... |
2456 EXPECT_TRUE(main_frame->GetFrame()->Selection().IsCaretBlinkingSuspended()); | 2460 EXPECT_TRUE(main_frame->GetFrame()->Selection().IsCaretBlinkingSuspended()); |
2457 | 2461 |
2458 // Caret blinking will be resumed only after context menu is closed. | 2462 // Caret blinking will be resumed only after context menu is closed. |
2459 web_view->DidCloseContextMenu(); | 2463 web_view->DidCloseContextMenu(); |
2460 | 2464 |
2461 EXPECT_FALSE(main_frame->GetFrame()->Selection().IsCaretBlinkingSuspended()); | 2465 EXPECT_FALSE(main_frame->GetFrame()->Selection().IsCaretBlinkingSuspended()); |
2462 } | 2466 } |
2463 | 2467 |
2464 TEST_P(WebViewTest, SelectionOnReadOnlyInput) { | 2468 TEST_P(WebViewTest, SelectionOnReadOnlyInput) { |
2465 RegisterMockedHttpURLLoad("selection_readonly.html"); | 2469 RegisterMockedHttpURLLoad("selection_readonly.html"); |
2466 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2470 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2467 base_url_ + "selection_readonly.html", true); | 2471 base_url_ + "selection_readonly.html", true); |
2468 web_view->Resize(WebSize(640, 480)); | 2472 web_view->Resize(WebSize(640, 480)); |
2469 web_view->UpdateAllLifecyclePhases(); | 2473 web_view->UpdateAllLifecyclePhases(); |
2470 RunPendingTasks(); | 2474 RunPendingTasks(); |
2471 | 2475 |
2472 std::string test_word = "This text should be selected."; | 2476 std::string test_word = "This text should be selected."; |
2473 | 2477 |
2474 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2478 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2475 EXPECT_EQ(test_word, std::string(frame->SelectionAsText().Utf8().data())); | 2479 EXPECT_EQ(test_word, std::string(frame->SelectionAsText().Utf8().data())); |
2476 | 2480 |
2477 WebRange range = web_view->CaretOrSelectionRange(); | 2481 WebRange range = web_view->CaretOrSelectionRange(); |
2478 EXPECT_FALSE(range.IsNull()); | 2482 EXPECT_FALSE(range.IsNull()); |
2479 EXPECT_EQ(0, range.StartOffset()); | 2483 EXPECT_EQ(0, range.StartOffset()); |
2480 EXPECT_EQ(static_cast<int>(test_word.length()), range.length()); | 2484 EXPECT_EQ(static_cast<int>(test_word.length()), range.length()); |
2481 } | 2485 } |
2482 | 2486 |
2483 TEST_P(WebViewTest, KeyDownScrollsHandled) { | 2487 TEST_P(WebViewTest, KeyDownScrollsHandled) { |
2484 RegisterMockedHttpURLLoad("content-width-1000.html"); | 2488 RegisterMockedHttpURLLoad("content-width-1000.html"); |
2485 | 2489 |
2486 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2490 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2487 base_url_ + "content-width-1000.html", true); | 2491 base_url_ + "content-width-1000.html", true); |
2488 web_view->Resize(WebSize(100, 100)); | 2492 web_view->Resize(WebSize(100, 100)); |
2489 web_view->UpdateAllLifecyclePhases(); | 2493 web_view->UpdateAllLifecyclePhases(); |
2490 RunPendingTasks(); | 2494 RunPendingTasks(); |
2491 | 2495 |
2492 WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, | 2496 WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, |
2493 WebInputEvent::kNoModifiers, | 2497 WebInputEvent::kNoModifiers, |
2494 WebInputEvent::kTimeStampForTesting); | 2498 WebInputEvent::kTimeStampForTesting); |
2495 | 2499 |
2496 // RawKeyDown pagedown should be handled. | 2500 // RawKeyDown pagedown should be handled. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2576 static void ConfigueCompositingWebView(WebSettings* settings) { | 2580 static void ConfigueCompositingWebView(WebSettings* settings) { |
2577 settings->SetAcceleratedCompositingEnabled(true); | 2581 settings->SetAcceleratedCompositingEnabled(true); |
2578 settings->SetPreferCompositingToLCDTextEnabled(true); | 2582 settings->SetPreferCompositingToLCDTextEnabled(true); |
2579 } | 2583 } |
2580 | 2584 |
2581 TEST_P(WebViewTest, ShowPressOnTransformedLink) { | 2585 TEST_P(WebViewTest, ShowPressOnTransformedLink) { |
2582 std::unique_ptr<FrameTestHelpers::TestWebViewClient> | 2586 std::unique_ptr<FrameTestHelpers::TestWebViewClient> |
2583 fake_compositing_web_view_client = | 2587 fake_compositing_web_view_client = |
2584 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>(); | 2588 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>(); |
2585 FrameTestHelpers::WebViewHelper web_view_helper; | 2589 FrameTestHelpers::WebViewHelper web_view_helper; |
2586 WebViewImpl* web_view_impl = web_view_helper.Initialize( | 2590 WebViewBase* web_view_impl = web_view_helper.Initialize( |
2587 true, nullptr, fake_compositing_web_view_client.get(), nullptr, | 2591 true, nullptr, fake_compositing_web_view_client.get(), nullptr, |
2588 &ConfigueCompositingWebView); | 2592 &ConfigueCompositingWebView); |
2589 | 2593 |
2590 int page_width = 640; | 2594 int page_width = 640; |
2591 int page_height = 480; | 2595 int page_height = 480; |
2592 web_view_impl->Resize(WebSize(page_width, page_height)); | 2596 web_view_impl->Resize(WebSize(page_width, page_height)); |
2593 | 2597 |
2594 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 2598 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
2595 FrameTestHelpers::LoadHTMLString( | 2599 FrameTestHelpers::LoadHTMLString( |
2596 web_view_impl->MainFrame(), | 2600 web_view_impl->MainFrame(), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2637 | 2641 |
2638 private: | 2642 private: |
2639 int text_changes_; | 2643 int text_changes_; |
2640 int text_changes_from_user_gesture_; | 2644 int text_changes_from_user_gesture_; |
2641 int user_gesture_notifications_count_; | 2645 int user_gesture_notifications_count_; |
2642 }; | 2646 }; |
2643 | 2647 |
2644 TEST_P(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) { | 2648 TEST_P(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) { |
2645 RegisterMockedHttpURLLoad("input_field_populated.html"); | 2649 RegisterMockedHttpURLLoad("input_field_populated.html"); |
2646 MockAutofillClient client; | 2650 MockAutofillClient client; |
2647 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2651 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2648 base_url_ + "input_field_populated.html"); | 2652 base_url_ + "input_field_populated.html"); |
2649 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2653 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2650 frame->SetAutofillClient(&client); | 2654 frame->SetAutofillClient(&client); |
2651 web_view->SetInitialFocus(false); | 2655 web_view->SetInitialFocus(false); |
2652 | 2656 |
2653 // Set up a composition that needs to be committed. | 2657 // Set up a composition that needs to be committed. |
2654 WebVector<WebCompositionUnderline> empty_underlines; | 2658 WebVector<WebCompositionUnderline> empty_underlines; |
2655 frame->SetEditableSelectionOffsets(4, 10); | 2659 frame->SetEditableSelectionOffsets(4, 10); |
2656 frame->SetCompositionFromExistingText(8, 12, empty_underlines); | 2660 frame->SetCompositionFromExistingText(8, 12, empty_underlines); |
2657 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 2661 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); |
2658 EXPECT_EQ(4, info.selection_start); | 2662 EXPECT_EQ(4, info.selection_start); |
2659 EXPECT_EQ(10, info.selection_end); | 2663 EXPECT_EQ(10, info.selection_end); |
2660 EXPECT_EQ(8, info.composition_start); | 2664 EXPECT_EQ(8, info.composition_start); |
2661 EXPECT_EQ(12, info.composition_end); | 2665 EXPECT_EQ(12, info.composition_end); |
2662 | 2666 |
2663 // Clear the focus and track that the subsequent composition commit does not | 2667 // Clear the focus and track that the subsequent composition commit does not |
2664 // trigger a text changed notification for autofill. | 2668 // trigger a text changed notification for autofill. |
2665 client.ClearChangeCounts(); | 2669 client.ClearChangeCounts(); |
2666 web_view->SetFocus(false); | 2670 web_view->SetFocus(false); |
2667 EXPECT_EQ(0, client.TextChanges()); | 2671 EXPECT_EQ(0, client.TextChanges()); |
2668 | 2672 |
2669 frame->SetAutofillClient(0); | 2673 frame->SetAutofillClient(0); |
2670 } | 2674 } |
2671 | 2675 |
2672 static void VerifySelectionAndComposition(WebViewImpl* web_view, | 2676 static void VerifySelectionAndComposition(WebViewBase* web_view, |
2673 int selection_start, | 2677 int selection_start, |
2674 int selection_end, | 2678 int selection_end, |
2675 int composition_start, | 2679 int composition_start, |
2676 int composition_end, | 2680 int composition_end, |
2677 const char* fail_message) { | 2681 const char* fail_message) { |
2678 WebTextInputInfo info = | 2682 WebTextInputInfo info = |
2679 web_view->MainFrameImpl()->GetInputMethodController()->TextInputInfo(); | 2683 web_view->MainFrameImpl()->GetInputMethodController()->TextInputInfo(); |
2680 EXPECT_EQ(selection_start, info.selection_start) << fail_message; | 2684 EXPECT_EQ(selection_start, info.selection_start) << fail_message; |
2681 EXPECT_EQ(selection_end, info.selection_end) << fail_message; | 2685 EXPECT_EQ(selection_end, info.selection_end) << fail_message; |
2682 EXPECT_EQ(composition_start, info.composition_start) << fail_message; | 2686 EXPECT_EQ(composition_start, info.composition_start) << fail_message; |
2683 EXPECT_EQ(composition_end, info.composition_end) << fail_message; | 2687 EXPECT_EQ(composition_end, info.composition_end) << fail_message; |
2684 } | 2688 } |
2685 | 2689 |
2686 TEST_P(WebViewTest, CompositionNotCancelledByBackspace) { | 2690 TEST_P(WebViewTest, CompositionNotCancelledByBackspace) { |
2687 RegisterMockedHttpURLLoad("composition_not_cancelled_by_backspace.html"); | 2691 RegisterMockedHttpURLLoad("composition_not_cancelled_by_backspace.html"); |
2688 MockAutofillClient client; | 2692 MockAutofillClient client; |
2689 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2693 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2690 base_url_ + "composition_not_cancelled_by_backspace.html"); | 2694 base_url_ + "composition_not_cancelled_by_backspace.html"); |
2691 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2695 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2692 frame->SetAutofillClient(&client); | 2696 frame->SetAutofillClient(&client); |
2693 web_view->SetInitialFocus(false); | 2697 web_view->SetInitialFocus(false); |
2694 | 2698 |
2695 // Test both input elements. | 2699 // Test both input elements. |
2696 for (int i = 0; i < 2; ++i) { | 2700 for (int i = 0; i < 2; ++i) { |
2697 // Select composition and do sanity check. | 2701 // Select composition and do sanity check. |
2698 WebVector<WebCompositionUnderline> empty_underlines; | 2702 WebVector<WebCompositionUnderline> empty_underlines; |
2699 frame->SetEditableSelectionOffsets(6, 6); | 2703 frame->SetEditableSelectionOffsets(6, 6); |
(...skipping 25 matching lines...) Expand all Loading... |
2725 | 2729 |
2726 web_view->AdvanceFocus(false); | 2730 web_view->AdvanceFocus(false); |
2727 } | 2731 } |
2728 | 2732 |
2729 frame->SetAutofillClient(0); | 2733 frame->SetAutofillClient(0); |
2730 } | 2734 } |
2731 | 2735 |
2732 TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) { | 2736 TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) { |
2733 RegisterMockedHttpURLLoad("input_field_populated.html"); | 2737 RegisterMockedHttpURLLoad("input_field_populated.html"); |
2734 MockAutofillClient client; | 2738 MockAutofillClient client; |
2735 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2739 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2736 base_url_ + "input_field_populated.html"); | 2740 base_url_ + "input_field_populated.html"); |
2737 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2741 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2738 frame->SetAutofillClient(&client); | 2742 frame->SetAutofillClient(&client); |
2739 web_view->SetInitialFocus(false); | 2743 web_view->SetInitialFocus(false); |
2740 | 2744 |
2741 WebDocument document = web_view->MainFrame()->GetDocument(); | 2745 WebDocument document = web_view->MainFrame()->GetDocument(); |
2742 HTMLFormControlElement* form = | 2746 HTMLFormControlElement* form = |
2743 ToHTMLFormControlElement(document.GetElementById("sample")); | 2747 ToHTMLFormControlElement(document.GetElementById("sample")); |
2744 | 2748 |
2745 WebInputMethodController* active_input_method_controller = | 2749 WebInputMethodController* active_input_method_controller = |
(...skipping 21 matching lines...) Expand all Loading... |
2767 | 2771 |
2768 EXPECT_TRUE(form->IsAutofilled()); | 2772 EXPECT_TRUE(form->IsAutofilled()); |
2769 | 2773 |
2770 frame->SetAutofillClient(0); | 2774 frame->SetAutofillClient(0); |
2771 } | 2775 } |
2772 | 2776 |
2773 TEST_P(WebViewTest, | 2777 TEST_P(WebViewTest, |
2774 SetCompositionFromExistingTextDoesntTriggerAutofillTextChange) { | 2778 SetCompositionFromExistingTextDoesntTriggerAutofillTextChange) { |
2775 RegisterMockedHttpURLLoad("input_field_populated.html"); | 2779 RegisterMockedHttpURLLoad("input_field_populated.html"); |
2776 MockAutofillClient client; | 2780 MockAutofillClient client; |
2777 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 2781 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
2778 base_url_ + "input_field_populated.html", true); | 2782 base_url_ + "input_field_populated.html", true); |
2779 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 2783 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
2780 frame->SetAutofillClient(&client); | 2784 frame->SetAutofillClient(&client); |
2781 web_view->SetInitialFocus(false); | 2785 web_view->SetInitialFocus(false); |
2782 | 2786 |
2783 WebVector<WebCompositionUnderline> empty_underlines; | 2787 WebVector<WebCompositionUnderline> empty_underlines; |
2784 | 2788 |
2785 client.ClearChangeCounts(); | 2789 client.ClearChangeCounts(); |
2786 frame->SetCompositionFromExistingText(8, 12, empty_underlines); | 2790 frame->SetCompositionFromExistingText(8, 12, empty_underlines); |
2787 | 2791 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 WebView* CreatedWebView() const { return web_view_helper_.WebView(); } | 2825 WebView* CreatedWebView() const { return web_view_helper_.WebView(); } |
2822 | 2826 |
2823 private: | 2827 private: |
2824 FrameTestHelpers::WebViewHelper web_view_helper_; | 2828 FrameTestHelpers::WebViewHelper web_view_helper_; |
2825 bool did_focus_called_; | 2829 bool did_focus_called_; |
2826 }; | 2830 }; |
2827 | 2831 |
2828 TEST_P(WebViewTest, DoNotFocusCurrentFrameOnNavigateFromLocalFrame) { | 2832 TEST_P(WebViewTest, DoNotFocusCurrentFrameOnNavigateFromLocalFrame) { |
2829 ViewCreatingWebViewClient client; | 2833 ViewCreatingWebViewClient client; |
2830 FrameTestHelpers::WebViewHelper web_view_helper; | 2834 FrameTestHelpers::WebViewHelper web_view_helper; |
2831 WebViewImpl* web_view_impl = web_view_helper.Initialize(true, 0, &client); | 2835 WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); |
2832 web_view_impl->GetPage() | 2836 web_view_impl->GetPage() |
2833 ->GetSettings() | 2837 ->GetSettings() |
2834 .SetJavaScriptCanOpenWindowsAutomatically(true); | 2838 .SetJavaScriptCanOpenWindowsAutomatically(true); |
2835 | 2839 |
2836 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 2840 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
2837 FrameTestHelpers::LoadHTMLString( | 2841 FrameTestHelpers::LoadHTMLString( |
2838 web_view_impl->MainFrame(), | 2842 web_view_impl->MainFrame(), |
2839 "<html><body><iframe src=\"about:blank\"></iframe></body></html>", | 2843 "<html><body><iframe src=\"about:blank\"></iframe></body></html>", |
2840 base_url); | 2844 base_url); |
2841 | 2845 |
2842 // Make a request from a local frame. | 2846 // Make a request from a local frame. |
2843 WebURLRequest web_url_request_with_target_start; | 2847 WebURLRequest web_url_request_with_target_start; |
2844 LocalFrame* local_frame = | 2848 LocalFrame* local_frame = |
2845 ToWebLocalFrameImpl(web_view_impl->MainFrame()->FirstChild())->GetFrame(); | 2849 ToWebLocalFrameImpl(web_view_impl->MainFrame()->FirstChild())->GetFrame(); |
2846 FrameLoadRequest request_with_target_start( | 2850 FrameLoadRequest request_with_target_start( |
2847 local_frame->GetDocument(), | 2851 local_frame->GetDocument(), |
2848 web_url_request_with_target_start.ToResourceRequest(), "_top"); | 2852 web_url_request_with_target_start.ToResourceRequest(), "_top"); |
2849 local_frame->Loader().Load(request_with_target_start); | 2853 local_frame->Loader().Load(request_with_target_start); |
2850 EXPECT_FALSE(client.DidFocusCalled()); | 2854 EXPECT_FALSE(client.DidFocusCalled()); |
2851 | 2855 |
2852 web_view_helper.Reset(); // Remove dependency on locally scoped client. | 2856 web_view_helper.Reset(); // Remove dependency on locally scoped client. |
2853 } | 2857 } |
2854 | 2858 |
2855 TEST_P(WebViewTest, FocusExistingFrameOnNavigate) { | 2859 TEST_P(WebViewTest, FocusExistingFrameOnNavigate) { |
2856 ViewCreatingWebViewClient client; | 2860 ViewCreatingWebViewClient client; |
2857 FrameTestHelpers::WebViewHelper web_view_helper; | 2861 FrameTestHelpers::WebViewHelper web_view_helper; |
2858 WebViewImpl* web_view_impl = web_view_helper.Initialize(true, 0, &client); | 2862 WebViewBase* web_view_impl = web_view_helper.Initialize(true, 0, &client); |
2859 web_view_impl->GetPage() | 2863 web_view_impl->GetPage() |
2860 ->GetSettings() | 2864 ->GetSettings() |
2861 .SetJavaScriptCanOpenWindowsAutomatically(true); | 2865 .SetJavaScriptCanOpenWindowsAutomatically(true); |
2862 WebLocalFrameImpl* frame = web_view_impl->MainFrameImpl(); | 2866 WebLocalFrameImpl* frame = web_view_impl->MainFrameImpl(); |
2863 frame->SetName("_start"); | 2867 frame->SetName("_start"); |
2864 | 2868 |
2865 // Make a request that will open a new window | 2869 // Make a request that will open a new window |
2866 WebURLRequest web_url_request; | 2870 WebURLRequest web_url_request; |
2867 FrameLoadRequest request(0, web_url_request.ToResourceRequest(), "_blank"); | 2871 FrameLoadRequest request(0, web_url_request.ToResourceRequest(), "_blank"); |
2868 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->Loader().Load(request); | 2872 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->Loader().Load(request); |
2869 ASSERT_TRUE(client.CreatedWebView()); | 2873 ASSERT_TRUE(client.CreatedWebView()); |
2870 EXPECT_FALSE(client.DidFocusCalled()); | 2874 EXPECT_FALSE(client.DidFocusCalled()); |
2871 | 2875 |
2872 // Make a request from the new window that will navigate the original window. | 2876 // Make a request from the new window that will navigate the original window. |
2873 // The original window should be focused. | 2877 // The original window should be focused. |
2874 WebURLRequest web_url_request_with_target_start; | 2878 WebURLRequest web_url_request_with_target_start; |
2875 FrameLoadRequest request_with_target_start( | 2879 FrameLoadRequest request_with_target_start( |
2876 0, web_url_request_with_target_start.ToResourceRequest(), "_start"); | 2880 0, web_url_request_with_target_start.ToResourceRequest(), "_start"); |
2877 ToLocalFrame(ToWebViewImpl(client.CreatedWebView())->GetPage()->MainFrame()) | 2881 ToLocalFrame(static_cast<WebViewBase*>(client.CreatedWebView()) |
| 2882 ->GetPage() |
| 2883 ->MainFrame()) |
2878 ->Loader() | 2884 ->Loader() |
2879 .Load(request_with_target_start); | 2885 .Load(request_with_target_start); |
2880 EXPECT_TRUE(client.DidFocusCalled()); | 2886 EXPECT_TRUE(client.DidFocusCalled()); |
2881 | 2887 |
2882 web_view_helper.Reset(); // Remove dependency on locally scoped client. | 2888 web_view_helper.Reset(); // Remove dependency on locally scoped client. |
2883 } | 2889 } |
2884 | 2890 |
2885 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) { | 2891 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) { |
2886 RegisterMockedHttpURLLoad("focusout_focusin_events.html"); | 2892 RegisterMockedHttpURLLoad("focusout_focusin_events.html"); |
2887 WebView* web_view = web_view_helper_.InitializeAndLoad( | 2893 WebView* web_view = web_view_helper_.InitializeAndLoad( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 #if OS(ANDROID) | 2935 #if OS(ANDROID) |
2930 TEST_P(WebViewTest, DISABLED_ChooseValueFromDateTimeChooser) { | 2936 TEST_P(WebViewTest, DISABLED_ChooseValueFromDateTimeChooser) { |
2931 #else | 2937 #else |
2932 TEST_P(WebViewTest, ChooseValueFromDateTimeChooser) { | 2938 TEST_P(WebViewTest, ChooseValueFromDateTimeChooser) { |
2933 #endif | 2939 #endif |
2934 bool original_multiple_fields_flag = | 2940 bool original_multiple_fields_flag = |
2935 RuntimeEnabledFeatures::inputMultipleFieldsUIEnabled(); | 2941 RuntimeEnabledFeatures::inputMultipleFieldsUIEnabled(); |
2936 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled(false); | 2942 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled(false); |
2937 DateTimeChooserWebViewClient client; | 2943 DateTimeChooserWebViewClient client; |
2938 std::string url = RegisterMockedHttpURLLoad("date_time_chooser.html"); | 2944 std::string url = RegisterMockedHttpURLLoad("date_time_chooser.html"); |
2939 WebViewImpl* web_view_impl = | 2945 WebViewBase* web_view_impl = |
2940 web_view_helper_.InitializeAndLoad(url, true, 0, &client); | 2946 web_view_helper_.InitializeAndLoad(url, true, 0, &client); |
2941 | 2947 |
2942 Document* document = | 2948 Document* document = |
2943 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 2949 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
2944 | 2950 |
2945 HTMLInputElement* input_element; | 2951 HTMLInputElement* input_element; |
2946 | 2952 |
2947 input_element = toHTMLInputElement(document->getElementById("date")); | 2953 input_element = toHTMLInputElement(document->getElementById("date")); |
2948 OpenDateTimeChooser(web_view_impl, input_element); | 2954 OpenDateTimeChooser(web_view_impl, input_element); |
2949 client.ChooserCompletion()->DidChooseValue(0); | 2955 client.ChooserCompletion()->DidChooseValue(0); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3044 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " | 3050 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " |
3045 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " | 3051 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " |
3046 "start; text-indent: 0px; text-transform: none; white-space: normal; " | 3052 "start; text-indent: 0px; text-transform: none; white-space: normal; " |
3047 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " | 3053 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " |
3048 "text-decoration-style: initial; text-decoration-color: initial;\">Price " | 3054 "text-decoration-style: initial; text-decoration-color: initial;\">Price " |
3049 "10,000,000won</div>"; | 3055 "10,000,000won</div>"; |
3050 WebString clip_text; | 3056 WebString clip_text; |
3051 WebString clip_html; | 3057 WebString clip_html; |
3052 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3058 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3053 RegisterMockedHttpURLLoad("smartclip.html"); | 3059 RegisterMockedHttpURLLoad("smartclip.html"); |
3054 WebViewImpl* web_view = | 3060 WebViewBase* web_view = |
3055 web_view_helper_.InitializeAndLoad(base_url_ + "smartclip.html"); | 3061 web_view_helper_.InitializeAndLoad(base_url_ + "smartclip.html"); |
3056 web_view->Resize(WebSize(500, 500)); | 3062 web_view->Resize(WebSize(500, 500)); |
3057 web_view->UpdateAllLifecyclePhases(); | 3063 web_view->UpdateAllLifecyclePhases(); |
3058 WebRect crop_rect(300, 125, 152, 50); | 3064 WebRect crop_rect(300, 125, 152, 50); |
3059 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, | 3065 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, |
3060 clip_html); | 3066 clip_html); |
3061 EXPECT_STREQ(kExpectedClipText, clip_text.Utf8().c_str()); | 3067 EXPECT_STREQ(kExpectedClipText, clip_text.Utf8().c_str()); |
3062 EXPECT_STREQ(kExpectedClipHtml, clip_html.Utf8().c_str()); | 3068 EXPECT_STREQ(kExpectedClipHtml, clip_html.Utf8().c_str()); |
3063 } | 3069 } |
3064 | 3070 |
(...skipping 15 matching lines...) Expand all Loading... |
3080 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " | 3086 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " |
3081 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " | 3087 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " |
3082 "start; text-indent: 0px; text-transform: none; white-space: normal; " | 3088 "start; text-indent: 0px; text-transform: none; white-space: normal; " |
3083 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " | 3089 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " |
3084 "text-decoration-style: initial; text-decoration-color: initial;\">Price " | 3090 "text-decoration-style: initial; text-decoration-color: initial;\">Price " |
3085 "10,000,000won</div>"; | 3091 "10,000,000won</div>"; |
3086 WebString clip_text; | 3092 WebString clip_text; |
3087 WebString clip_html; | 3093 WebString clip_html; |
3088 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3094 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3089 RegisterMockedHttpURLLoad("smartclip.html"); | 3095 RegisterMockedHttpURLLoad("smartclip.html"); |
3090 WebViewImpl* web_view = | 3096 WebViewBase* web_view = |
3091 web_view_helper_.InitializeAndLoad(base_url_ + "smartclip.html"); | 3097 web_view_helper_.InitializeAndLoad(base_url_ + "smartclip.html"); |
3092 web_view->Resize(WebSize(500, 500)); | 3098 web_view->Resize(WebSize(500, 500)); |
3093 web_view->UpdateAllLifecyclePhases(); | 3099 web_view->UpdateAllLifecyclePhases(); |
3094 web_view->SetPageScaleFactor(1.5); | 3100 web_view->SetPageScaleFactor(1.5); |
3095 web_view->SetVisualViewportOffset(WebFloatPoint(167, 100)); | 3101 web_view->SetVisualViewportOffset(WebFloatPoint(167, 100)); |
3096 WebRect crop_rect(200, 38, 228, 75); | 3102 WebRect crop_rect(200, 38, 228, 75); |
3097 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, | 3103 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, |
3098 clip_html); | 3104 clip_html); |
3099 EXPECT_STREQ(kExpectedClipText, clip_text.Utf8().c_str()); | 3105 EXPECT_STREQ(kExpectedClipText, clip_text.Utf8().c_str()); |
3100 EXPECT_STREQ(kExpectedClipHtml, clip_html.Utf8().c_str()); | 3106 EXPECT_STREQ(kExpectedClipHtml, clip_html.Utf8().c_str()); |
3101 } | 3107 } |
3102 | 3108 |
3103 TEST_P(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone) { | 3109 TEST_P(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone) { |
3104 WebString clip_text; | 3110 WebString clip_text; |
3105 WebString clip_html; | 3111 WebString clip_html; |
3106 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3112 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3107 RegisterMockedHttpURLLoad("smartclip_user_select_none.html"); | 3113 RegisterMockedHttpURLLoad("smartclip_user_select_none.html"); |
3108 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3114 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3109 base_url_ + "smartclip_user_select_none.html"); | 3115 base_url_ + "smartclip_user_select_none.html"); |
3110 web_view->Resize(WebSize(500, 500)); | 3116 web_view->Resize(WebSize(500, 500)); |
3111 web_view->UpdateAllLifecyclePhases(); | 3117 web_view->UpdateAllLifecyclePhases(); |
3112 WebRect crop_rect(0, 0, 100, 100); | 3118 WebRect crop_rect(0, 0, 100, 100); |
3113 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, | 3119 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, |
3114 clip_html); | 3120 clip_html); |
3115 EXPECT_STREQ("", clip_text.Utf8().c_str()); | 3121 EXPECT_STREQ("", clip_text.Utf8().c_str()); |
3116 EXPECT_STREQ("", clip_html.Utf8().c_str()); | 3122 EXPECT_STREQ("", clip_html.Utf8().c_str()); |
3117 } | 3123 } |
3118 | 3124 |
3119 TEST_P(WebViewTest, SmartClipDoesNotCrashPositionReversed) { | 3125 TEST_P(WebViewTest, SmartClipDoesNotCrashPositionReversed) { |
3120 WebString clip_text; | 3126 WebString clip_text; |
3121 WebString clip_html; | 3127 WebString clip_html; |
3122 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3128 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3123 RegisterMockedHttpURLLoad("smartclip_reversed_positions.html"); | 3129 RegisterMockedHttpURLLoad("smartclip_reversed_positions.html"); |
3124 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3130 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3125 base_url_ + "smartclip_reversed_positions.html"); | 3131 base_url_ + "smartclip_reversed_positions.html"); |
3126 web_view->Resize(WebSize(500, 500)); | 3132 web_view->Resize(WebSize(500, 500)); |
3127 web_view->UpdateAllLifecyclePhases(); | 3133 web_view->UpdateAllLifecyclePhases(); |
3128 // Left upper corner of the rect will be end position in the DOM hierarchy. | 3134 // Left upper corner of the rect will be end position in the DOM hierarchy. |
3129 WebRect crop_rect(30, 110, 400, 250); | 3135 WebRect crop_rect(30, 110, 400, 250); |
3130 // This should not still crash. See crbug.com/589082 for more details. | 3136 // This should not still crash. See crbug.com/589082 for more details. |
3131 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, | 3137 web_view->MainFrameImpl()->ExtractSmartClipData(crop_rect, clip_text, |
3132 clip_html); | 3138 clip_html); |
3133 } | 3139 } |
3134 | 3140 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called | 3251 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called |
3246 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove| | 3252 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove| |
3247 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made | 3253 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made |
3248 // correctly is the job of LayoutTests/fast/events/event-handler-count.html. | 3254 // correctly is the job of LayoutTests/fast/events/event-handler-count.html. |
3249 TEST_P(WebViewTest, HasTouchEventHandlers) { | 3255 TEST_P(WebViewTest, HasTouchEventHandlers) { |
3250 TouchEventHandlerWebWidgetClient client; | 3256 TouchEventHandlerWebWidgetClient client; |
3251 // We need to create a LayerTreeView for the client before loading the page, | 3257 // We need to create a LayerTreeView for the client before loading the page, |
3252 // otherwise ChromeClient will default to assuming there are touch handlers. | 3258 // otherwise ChromeClient will default to assuming there are touch handlers. |
3253 WebLayerTreeView* layer_tree_view = client.InitializeLayerTreeView(); | 3259 WebLayerTreeView* layer_tree_view = client.InitializeLayerTreeView(); |
3254 std::string url = RegisterMockedHttpURLLoad("has_touch_event_handlers.html"); | 3260 std::string url = RegisterMockedHttpURLLoad("has_touch_event_handlers.html"); |
3255 WebViewImpl* web_view_impl = | 3261 WebViewBase* web_view_impl = |
3256 web_view_helper_.InitializeAndLoad(url, true, 0, 0, &client); | 3262 web_view_helper_.InitializeAndLoad(url, true, 0, 0, &client); |
3257 ASSERT_TRUE(layer_tree_view); | 3263 ASSERT_TRUE(layer_tree_view); |
3258 const EventHandlerRegistry::EventHandlerClass kTouchEvent = | 3264 const EventHandlerRegistry::EventHandlerClass kTouchEvent = |
3259 EventHandlerRegistry::kTouchStartOrMoveEventBlocking; | 3265 EventHandlerRegistry::kTouchStartOrMoveEventBlocking; |
3260 | 3266 |
3261 // The page is initialized with at least one no-handlers call. | 3267 // The page is initialized with at least one no-handlers call. |
3262 // In practice we get two such calls because WebViewHelper::initializeAndLoad | 3268 // In practice we get two such calls because WebViewHelper::initializeAndLoad |
3263 // first initializes an empty frame, and then loads a document into it, so | 3269 // first initializes an empty frame, and then loads a document into it, so |
3264 // there are two FrameLoader::commitProvisionalLoad calls. | 3270 // there are two FrameLoader::commitProvisionalLoad calls. |
3265 EXPECT_LT(0, client.GetAndResetHasTouchEventHandlerCallCount(false)); | 3271 EXPECT_LT(0, client.GetAndResetHasTouchEventHandlerCallCount(false)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3373 // Free the webView before the TouchEventHandlerWebViewClient gets freed. | 3379 // Free the webView before the TouchEventHandlerWebViewClient gets freed. |
3374 web_view_helper_.Reset(); | 3380 web_view_helper_.Reset(); |
3375 } | 3381 } |
3376 | 3382 |
3377 // This test checks that deleting nodes which have only non-JS-registered touch | 3383 // This test checks that deleting nodes which have only non-JS-registered touch |
3378 // handlers also removes them from the event handler registry. Note that this | 3384 // handlers also removes them from the event handler registry. Note that this |
3379 // is different from detaching and re-attaching the same node, which is covered | 3385 // is different from detaching and re-attaching the same node, which is covered |
3380 // by layout tests under fast/events/. | 3386 // by layout tests under fast/events/. |
3381 TEST_P(WebViewTest, DeleteElementWithRegisteredHandler) { | 3387 TEST_P(WebViewTest, DeleteElementWithRegisteredHandler) { |
3382 std::string url = RegisterMockedHttpURLLoad("simple_div.html"); | 3388 std::string url = RegisterMockedHttpURLLoad("simple_div.html"); |
3383 WebViewImpl* web_view_impl = web_view_helper_.InitializeAndLoad(url, true); | 3389 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad(url, true); |
3384 | 3390 |
3385 Persistent<Document> document = | 3391 Persistent<Document> document = |
3386 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 3392 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
3387 Element* div = document->getElementById("div"); | 3393 Element* div = document->getElementById("div"); |
3388 EventHandlerRegistry& registry = | 3394 EventHandlerRegistry& registry = |
3389 document->GetPage()->GetEventHandlerRegistry(); | 3395 document->GetPage()->GetEventHandlerRegistry(); |
3390 | 3396 |
3391 registry.DidAddEventHandler(*div, EventHandlerRegistry::kScrollEvent); | 3397 registry.DidAddEventHandler(*div, EventHandlerRegistry::kScrollEvent); |
3392 EXPECT_TRUE(registry.HasEventHandlers(EventHandlerRegistry::kScrollEvent)); | 3398 EXPECT_TRUE(registry.HasEventHandlers(EventHandlerRegistry::kScrollEvent)); |
3393 | 3399 |
3394 DummyExceptionStateForTesting exception_state; | 3400 DummyExceptionStateForTesting exception_state; |
3395 div->remove(exception_state); | 3401 div->remove(exception_state); |
3396 | 3402 |
3397 // For oilpan we have to force a GC to ensure the event handlers have been | 3403 // For oilpan we have to force a GC to ensure the event handlers have been |
3398 // removed when checking below. We do a precise GC (collectAllGarbage does not | 3404 // removed when checking below. We do a precise GC (collectAllGarbage does not |
3399 // scan the stack) to ensure the div element dies. This is also why the | 3405 // scan the stack) to ensure the div element dies. This is also why the |
3400 // Document is in a Persistent since we want that to stay around. | 3406 // Document is in a Persistent since we want that to stay around. |
3401 ThreadState::Current()->CollectAllGarbage(); | 3407 ThreadState::Current()->CollectAllGarbage(); |
3402 | 3408 |
3403 EXPECT_FALSE(registry.HasEventHandlers(EventHandlerRegistry::kScrollEvent)); | 3409 EXPECT_FALSE(registry.HasEventHandlers(EventHandlerRegistry::kScrollEvent)); |
3404 } | 3410 } |
3405 | 3411 |
3406 // This test verifies the text input flags are correctly exposed to script. | 3412 // This test verifies the text input flags are correctly exposed to script. |
3407 TEST_P(WebViewTest, TextInputFlags) { | 3413 TEST_P(WebViewTest, TextInputFlags) { |
3408 std::string url = RegisterMockedHttpURLLoad("text_input_flags.html"); | 3414 std::string url = RegisterMockedHttpURLLoad("text_input_flags.html"); |
3409 WebViewImpl* web_view_impl = web_view_helper_.InitializeAndLoad(url, true); | 3415 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad(url, true); |
3410 web_view_impl->SetInitialFocus(false); | 3416 web_view_impl->SetInitialFocus(false); |
3411 | 3417 |
3412 WebLocalFrameImpl* frame = web_view_impl->MainFrameImpl(); | 3418 WebLocalFrameImpl* frame = web_view_impl->MainFrameImpl(); |
3413 WebInputMethodControllerImpl* active_input_method_controller = | 3419 WebInputMethodControllerImpl* active_input_method_controller = |
3414 frame->GetInputMethodController(); | 3420 frame->GetInputMethodController(); |
3415 Document* document = frame->GetFrame()->GetDocument(); | 3421 Document* document = frame->GetFrame()->GetDocument(); |
3416 | 3422 |
3417 // (A) <input> | 3423 // (A) <input> |
3418 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and | 3424 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and |
3419 // autocapitalize is set to none. | 3425 // autocapitalize is set to none. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 | 3465 |
3460 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. | 3466 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. |
3461 web_view_helper_.Reset(); | 3467 web_view_helper_.Reset(); |
3462 } | 3468 } |
3463 | 3469 |
3464 // Check that the WebAutofillClient is correctly notified about first user | 3470 // Check that the WebAutofillClient is correctly notified about first user |
3465 // gestures after load, following various input events. | 3471 // gestures after load, following various input events. |
3466 TEST_P(WebViewTest, FirstUserGestureObservedKeyEvent) { | 3472 TEST_P(WebViewTest, FirstUserGestureObservedKeyEvent) { |
3467 RegisterMockedHttpURLLoad("form.html"); | 3473 RegisterMockedHttpURLLoad("form.html"); |
3468 MockAutofillClient client; | 3474 MockAutofillClient client; |
3469 WebViewImpl* web_view = | 3475 WebViewBase* web_view = |
3470 web_view_helper_.InitializeAndLoad(base_url_ + "form.html", true); | 3476 web_view_helper_.InitializeAndLoad(base_url_ + "form.html", true); |
3471 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3477 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3472 frame->SetAutofillClient(&client); | 3478 frame->SetAutofillClient(&client); |
3473 web_view->SetInitialFocus(false); | 3479 web_view->SetInitialFocus(false); |
3474 | 3480 |
3475 EXPECT_EQ(0, client.GetUserGestureNotificationsCount()); | 3481 EXPECT_EQ(0, client.GetUserGestureNotificationsCount()); |
3476 | 3482 |
3477 WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, | 3483 WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, |
3478 WebInputEvent::kNoModifiers, | 3484 WebInputEvent::kNoModifiers, |
3479 WebInputEvent::kTimeStampForTesting); | 3485 WebInputEvent::kTimeStampForTesting); |
3480 key_event.dom_key = Platform::Current()->DomKeyEnumFromString(" "); | 3486 key_event.dom_key = Platform::Current()->DomKeyEnumFromString(" "); |
3481 key_event.windows_key_code = VKEY_SPACE; | 3487 key_event.windows_key_code = VKEY_SPACE; |
3482 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event)); | 3488 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event)); |
3483 key_event.SetType(WebInputEvent::kKeyUp); | 3489 key_event.SetType(WebInputEvent::kKeyUp); |
3484 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event)); | 3490 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event)); |
3485 | 3491 |
3486 EXPECT_EQ(2, client.GetUserGestureNotificationsCount()); | 3492 EXPECT_EQ(2, client.GetUserGestureNotificationsCount()); |
3487 frame->SetAutofillClient(0); | 3493 frame->SetAutofillClient(0); |
3488 } | 3494 } |
3489 | 3495 |
3490 TEST_P(WebViewTest, FirstUserGestureObservedMouseEvent) { | 3496 TEST_P(WebViewTest, FirstUserGestureObservedMouseEvent) { |
3491 RegisterMockedHttpURLLoad("form.html"); | 3497 RegisterMockedHttpURLLoad("form.html"); |
3492 MockAutofillClient client; | 3498 MockAutofillClient client; |
3493 WebViewImpl* web_view = | 3499 WebViewBase* web_view = |
3494 web_view_helper_.InitializeAndLoad(base_url_ + "form.html", true); | 3500 web_view_helper_.InitializeAndLoad(base_url_ + "form.html", true); |
3495 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3501 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3496 frame->SetAutofillClient(&client); | 3502 frame->SetAutofillClient(&client); |
3497 web_view->SetInitialFocus(false); | 3503 web_view->SetInitialFocus(false); |
3498 | 3504 |
3499 EXPECT_EQ(0, client.GetUserGestureNotificationsCount()); | 3505 EXPECT_EQ(0, client.GetUserGestureNotificationsCount()); |
3500 | 3506 |
3501 WebMouseEvent mouse_event(WebInputEvent::kMouseDown, | 3507 WebMouseEvent mouse_event(WebInputEvent::kMouseDown, |
3502 WebInputEvent::kNoModifiers, | 3508 WebInputEvent::kNoModifiers, |
3503 WebInputEvent::kTimeStampForTesting); | 3509 WebInputEvent::kTimeStampForTesting); |
3504 mouse_event.button = WebMouseEvent::Button::kLeft; | 3510 mouse_event.button = WebMouseEvent::Button::kLeft; |
3505 mouse_event.SetPositionInWidget(1, 1); | 3511 mouse_event.SetPositionInWidget(1, 1); |
3506 mouse_event.click_count = 1; | 3512 mouse_event.click_count = 1; |
3507 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event)); | 3513 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event)); |
3508 mouse_event.SetType(WebInputEvent::kMouseUp); | 3514 mouse_event.SetType(WebInputEvent::kMouseUp); |
3509 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event)); | 3515 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event)); |
3510 | 3516 |
3511 EXPECT_EQ(1, client.GetUserGestureNotificationsCount()); | 3517 EXPECT_EQ(1, client.GetUserGestureNotificationsCount()); |
3512 frame->SetAutofillClient(0); | 3518 frame->SetAutofillClient(0); |
3513 } | 3519 } |
3514 | 3520 |
3515 TEST_P(WebViewTest, CompositionIsUserGesture) { | 3521 TEST_P(WebViewTest, CompositionIsUserGesture) { |
3516 RegisterMockedHttpURLLoad("input_field_populated.html"); | 3522 RegisterMockedHttpURLLoad("input_field_populated.html"); |
3517 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3523 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3518 base_url_ + "input_field_populated.html"); | 3524 base_url_ + "input_field_populated.html"); |
3519 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3525 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3520 MockAutofillClient client; | 3526 MockAutofillClient client; |
3521 frame->SetAutofillClient(&client); | 3527 frame->SetAutofillClient(&client); |
3522 web_view->SetInitialFocus(false); | 3528 web_view->SetInitialFocus(false); |
3523 | 3529 |
3524 EXPECT_TRUE( | 3530 EXPECT_TRUE( |
3525 frame->FrameWidget()->GetActiveWebInputMethodController()->SetComposition( | 3531 frame->FrameWidget()->GetActiveWebInputMethodController()->SetComposition( |
3526 WebString::FromUTF8(std::string("hello").c_str()), | 3532 WebString::FromUTF8(std::string("hello").c_str()), |
3527 WebVector<WebCompositionUnderline>(), WebRange(), 3, 3)); | 3533 WebVector<WebCompositionUnderline>(), WebRange(), 3, 3)); |
3528 EXPECT_EQ(1, client.TextChangesFromUserGesture()); | 3534 EXPECT_EQ(1, client.TextChangesFromUserGesture()); |
3529 EXPECT_FALSE(UserGestureIndicator::ProcessingUserGesture()); | 3535 EXPECT_FALSE(UserGestureIndicator::ProcessingUserGesture()); |
3530 EXPECT_TRUE(frame->HasMarkedText()); | 3536 EXPECT_TRUE(frame->HasMarkedText()); |
3531 | 3537 |
3532 frame->SetAutofillClient(0); | 3538 frame->SetAutofillClient(0); |
3533 } | 3539 } |
3534 | 3540 |
3535 TEST_P(WebViewTest, CompareSelectAllToContentAsText) { | 3541 TEST_P(WebViewTest, CompareSelectAllToContentAsText) { |
3536 RegisterMockedHttpURLLoad("longpress_selection.html"); | 3542 RegisterMockedHttpURLLoad("longpress_selection.html"); |
3537 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3543 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3538 base_url_ + "longpress_selection.html", true); | 3544 base_url_ + "longpress_selection.html", true); |
3539 | 3545 |
3540 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3546 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3541 frame->ExecuteScript(WebScriptSource( | 3547 frame->ExecuteScript(WebScriptSource( |
3542 WebString::FromUTF8("document.execCommand('SelectAll', false, null)"))); | 3548 WebString::FromUTF8("document.execCommand('SelectAll', false, null)"))); |
3543 std::string actual = frame->SelectionAsText().Utf8(); | 3549 std::string actual = frame->SelectionAsText().Utf8(); |
3544 | 3550 |
3545 const int kMaxOutputCharacters = 1024; | 3551 const int kMaxOutputCharacters = 1024; |
3546 std::string expected = | 3552 std::string expected = |
3547 WebFrameContentDumper::DumpWebViewAsText(web_view, kMaxOutputCharacters) | 3553 WebFrameContentDumper::DumpWebViewAsText(web_view, kMaxOutputCharacters) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3719 frame->ExecuteScript(WebScriptSource("setTest('click-" handler "');")); \ | 3725 frame->ExecuteScript(WebScriptSource("setTest('click-" handler "');")); \ |
3720 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, \ | 3726 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, \ |
3721 WebString::FromUTF8("target"))); \ | 3727 WebString::FromUTF8("target"))); \ |
3722 EXPECT_##EXPECT(client.GetPageChanged()); | 3728 EXPECT_##EXPECT(client.GetPageChanged()); |
3723 | 3729 |
3724 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateDom) { | 3730 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateDom) { |
3725 std::string test_file = "show_unhandled_tap.html"; | 3731 std::string test_file = "show_unhandled_tap.html"; |
3726 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3732 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3727 RegisterMockedHttpURLLoad(test_file); | 3733 RegisterMockedHttpURLLoad(test_file); |
3728 UnhandledTapWebViewClient client; | 3734 UnhandledTapWebViewClient client; |
3729 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3735 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3730 base_url_ + test_file, true, 0, &client); | 3736 base_url_ + test_file, true, 0, &client); |
3731 web_view->Resize(WebSize(500, 300)); | 3737 web_view->Resize(WebSize(500, 300)); |
3732 web_view->UpdateAllLifecyclePhases(); | 3738 web_view->UpdateAllLifecyclePhases(); |
3733 RunPendingTasks(); | 3739 RunPendingTasks(); |
3734 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3740 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3735 | 3741 |
3736 // Test dom mutation. | 3742 // Test dom mutation. |
3737 TEST_EACH_MOUSEEVENT("mutateDom", TRUE); | 3743 TEST_EACH_MOUSEEVENT("mutateDom", TRUE); |
3738 | 3744 |
3739 // Test without any DOM mutation. | 3745 // Test without any DOM mutation. |
3740 client.Reset(); | 3746 client.Reset(); |
3741 frame->ExecuteScript(WebScriptSource("setTest('none');")); | 3747 frame->ExecuteScript(WebScriptSource("setTest('none');")); |
3742 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 3748 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, |
3743 WebString::FromUTF8("target"))); | 3749 WebString::FromUTF8("target"))); |
3744 EXPECT_FALSE(client.GetPageChanged()); | 3750 EXPECT_FALSE(client.GetPageChanged()); |
3745 | 3751 |
3746 web_view_helper_.Reset(); // Remove dependency on locally scoped client. | 3752 web_view_helper_.Reset(); // Remove dependency on locally scoped client. |
3747 } | 3753 } |
3748 | 3754 |
3749 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateStyle) { | 3755 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateStyle) { |
3750 std::string test_file = "show_unhandled_tap.html"; | 3756 std::string test_file = "show_unhandled_tap.html"; |
3751 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3757 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3752 RegisterMockedHttpURLLoad(test_file); | 3758 RegisterMockedHttpURLLoad(test_file); |
3753 UnhandledTapWebViewClient client; | 3759 UnhandledTapWebViewClient client; |
3754 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3760 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3755 base_url_ + test_file, true, 0, &client); | 3761 base_url_ + test_file, true, 0, &client); |
3756 web_view->Resize(WebSize(500, 300)); | 3762 web_view->Resize(WebSize(500, 300)); |
3757 web_view->UpdateAllLifecyclePhases(); | 3763 web_view->UpdateAllLifecyclePhases(); |
3758 RunPendingTasks(); | 3764 RunPendingTasks(); |
3759 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3765 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3760 | 3766 |
3761 // Test style mutation. | 3767 // Test style mutation. |
3762 TEST_EACH_MOUSEEVENT("mutateStyle", TRUE); | 3768 TEST_EACH_MOUSEEVENT("mutateStyle", TRUE); |
3763 | 3769 |
3764 // Test checkbox:indeterminate style mutation. | 3770 // Test checkbox:indeterminate style mutation. |
(...skipping 13 matching lines...) Expand all Loading... |
3778 EXPECT_FALSE(client.GetPageChanged()); | 3784 EXPECT_FALSE(client.GetPageChanged()); |
3779 | 3785 |
3780 web_view_helper_.Reset(); // Remove dependency on locally scoped client. | 3786 web_view_helper_.Reset(); // Remove dependency on locally scoped client. |
3781 } | 3787 } |
3782 | 3788 |
3783 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithPreventDefault) { | 3789 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithPreventDefault) { |
3784 std::string test_file = "show_unhandled_tap.html"; | 3790 std::string test_file = "show_unhandled_tap.html"; |
3785 RegisterMockedHttpURLLoad("Ahem.ttf"); | 3791 RegisterMockedHttpURLLoad("Ahem.ttf"); |
3786 RegisterMockedHttpURLLoad(test_file); | 3792 RegisterMockedHttpURLLoad(test_file); |
3787 UnhandledTapWebViewClient client; | 3793 UnhandledTapWebViewClient client; |
3788 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3794 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3789 base_url_ + test_file, true, 0, &client); | 3795 base_url_ + test_file, true, 0, &client); |
3790 web_view->Resize(WebSize(500, 300)); | 3796 web_view->Resize(WebSize(500, 300)); |
3791 web_view->UpdateAllLifecyclePhases(); | 3797 web_view->UpdateAllLifecyclePhases(); |
3792 RunPendingTasks(); | 3798 RunPendingTasks(); |
3793 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3799 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3794 | 3800 |
3795 // Testswallowing. | 3801 // Testswallowing. |
3796 TEST_EACH_MOUSEEVENT("preventDefault", FALSE); | 3802 TEST_EACH_MOUSEEVENT("preventDefault", FALSE); |
3797 | 3803 |
3798 // Test without any preventDefault. | 3804 // Test without any preventDefault. |
(...skipping 23 matching lines...) Expand all Loading... |
3822 ASSERT_TRUE(v8_value->IsObject()); | 3828 ASSERT_TRUE(v8_value->IsObject()); |
3823 Document* document = | 3829 Document* document = |
3824 V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent(), v8_value); | 3830 V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent(), v8_value); |
3825 ASSERT_TRUE(document); | 3831 ASSERT_TRUE(document); |
3826 EXPECT_FALSE(document->GetFrame()->IsLoading()); | 3832 EXPECT_FALSE(document->GetFrame()->IsLoading()); |
3827 } | 3833 } |
3828 | 3834 |
3829 #if OS(MACOSX) | 3835 #if OS(MACOSX) |
3830 TEST_P(WebViewTest, WebSubstringUtil) { | 3836 TEST_P(WebViewTest, WebSubstringUtil) { |
3831 RegisterMockedHttpURLLoad("content_editable_populated.html"); | 3837 RegisterMockedHttpURLLoad("content_editable_populated.html"); |
3832 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3838 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3833 base_url_ + "content_editable_populated.html"); | 3839 base_url_ + "content_editable_populated.html"); |
3834 web_view->GetSettings()->SetDefaultFontSize(12); | 3840 web_view->GetSettings()->SetDefaultFontSize(12); |
3835 web_view->Resize(WebSize(400, 400)); | 3841 web_view->Resize(WebSize(400, 400)); |
3836 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3842 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3837 | 3843 |
3838 WebPoint baseline_point; | 3844 WebPoint baseline_point; |
3839 NSAttributedString* result = WebSubstringUtil::AttributedSubstringInRange( | 3845 NSAttributedString* result = WebSubstringUtil::AttributedSubstringInRange( |
3840 frame, 10, 3, &baseline_point); | 3846 frame, 10, 3, &baseline_point); |
3841 ASSERT_TRUE(!!result); | 3847 ASSERT_TRUE(!!result); |
3842 | 3848 |
3843 WebPoint point(baseline_point.x, baseline_point.y); | 3849 WebPoint point(baseline_point.x, baseline_point.y); |
3844 result = WebSubstringUtil::AttributedWordAtPoint(frame->FrameWidget(), point, | 3850 result = WebSubstringUtil::AttributedWordAtPoint(frame->FrameWidget(), point, |
3845 baseline_point); | 3851 baseline_point); |
3846 ASSERT_TRUE(!!result); | 3852 ASSERT_TRUE(!!result); |
3847 | 3853 |
3848 web_view->SetZoomLevel(3); | 3854 web_view->SetZoomLevel(3); |
3849 | 3855 |
3850 result = WebSubstringUtil::AttributedSubstringInRange(frame, 5, 5, | 3856 result = WebSubstringUtil::AttributedSubstringInRange(frame, 5, 5, |
3851 &baseline_point); | 3857 &baseline_point); |
3852 ASSERT_TRUE(!!result); | 3858 ASSERT_TRUE(!!result); |
3853 | 3859 |
3854 point = WebPoint(baseline_point.x, baseline_point.y); | 3860 point = WebPoint(baseline_point.x, baseline_point.y); |
3855 result = WebSubstringUtil::AttributedWordAtPoint(frame->FrameWidget(), point, | 3861 result = WebSubstringUtil::AttributedWordAtPoint(frame->FrameWidget(), point, |
3856 baseline_point); | 3862 baseline_point); |
3857 ASSERT_TRUE(!!result); | 3863 ASSERT_TRUE(!!result); |
3858 } | 3864 } |
3859 | 3865 |
3860 TEST_P(WebViewTest, WebSubstringUtilPinchZoom) { | 3866 TEST_P(WebViewTest, WebSubstringUtilPinchZoom) { |
3861 RegisterMockedHttpURLLoad("content_editable_populated.html"); | 3867 RegisterMockedHttpURLLoad("content_editable_populated.html"); |
3862 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3868 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3863 base_url_ + "content_editable_populated.html"); | 3869 base_url_ + "content_editable_populated.html"); |
3864 web_view->GetSettings()->SetDefaultFontSize(12); | 3870 web_view->GetSettings()->SetDefaultFontSize(12); |
3865 web_view->Resize(WebSize(400, 400)); | 3871 web_view->Resize(WebSize(400, 400)); |
3866 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3872 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3867 NSAttributedString* result = nil; | 3873 NSAttributedString* result = nil; |
3868 | 3874 |
3869 WebPoint baseline_point; | 3875 WebPoint baseline_point; |
3870 result = WebSubstringUtil::AttributedSubstringInRange(frame, 10, 3, | 3876 result = WebSubstringUtil::AttributedSubstringInRange(frame, 10, 3, |
3871 &baseline_point); | 3877 &baseline_point); |
3872 ASSERT_TRUE(!!result); | 3878 ASSERT_TRUE(!!result); |
3873 | 3879 |
3874 web_view->SetPageScaleFactor(3); | 3880 web_view->SetPageScaleFactor(3); |
3875 | 3881 |
3876 WebPoint point_after_zoom; | 3882 WebPoint point_after_zoom; |
3877 result = WebSubstringUtil::AttributedSubstringInRange(frame, 10, 3, | 3883 result = WebSubstringUtil::AttributedSubstringInRange(frame, 10, 3, |
3878 &point_after_zoom); | 3884 &point_after_zoom); |
3879 ASSERT_TRUE(!!result); | 3885 ASSERT_TRUE(!!result); |
3880 | 3886 |
3881 // We won't have moved by a full factor of 3 because of the translations, but | 3887 // We won't have moved by a full factor of 3 because of the translations, but |
3882 // we should move by a factor of >2. | 3888 // we should move by a factor of >2. |
3883 EXPECT_LT(2 * baseline_point.x, point_after_zoom.x); | 3889 EXPECT_LT(2 * baseline_point.x, point_after_zoom.x); |
3884 EXPECT_LT(2 * baseline_point.y, point_after_zoom.y); | 3890 EXPECT_LT(2 * baseline_point.y, point_after_zoom.y); |
3885 } | 3891 } |
3886 | 3892 |
3887 TEST_P(WebViewTest, WebSubstringUtilIframe) { | 3893 TEST_P(WebViewTest, WebSubstringUtilIframe) { |
3888 RegisterMockedHttpURLLoad("single_iframe.html"); | 3894 RegisterMockedHttpURLLoad("single_iframe.html"); |
3889 RegisterMockedHttpURLLoad("visible_iframe.html"); | 3895 RegisterMockedHttpURLLoad("visible_iframe.html"); |
3890 WebViewImpl* web_view = | 3896 WebViewBase* web_view = |
3891 web_view_helper_.InitializeAndLoad(base_url_ + "single_iframe.html"); | 3897 web_view_helper_.InitializeAndLoad(base_url_ + "single_iframe.html"); |
3892 web_view->GetSettings()->SetDefaultFontSize(12); | 3898 web_view->GetSettings()->SetDefaultFontSize(12); |
3893 web_view->GetSettings()->SetJavaScriptEnabled(true); | 3899 web_view->GetSettings()->SetJavaScriptEnabled(true); |
3894 web_view->Resize(WebSize(400, 400)); | 3900 web_view->Resize(WebSize(400, 400)); |
3895 WebLocalFrameImpl* main_frame = web_view->MainFrameImpl(); | 3901 WebLocalFrameImpl* main_frame = web_view->MainFrameImpl(); |
3896 WebLocalFrameImpl* child_frame = WebLocalFrameImpl::FromFrame( | 3902 WebLocalFrameImpl* child_frame = WebLocalFrameImpl::FromFrame( |
3897 ToLocalFrame(main_frame->GetFrame()->Tree().FirstChild())); | 3903 ToLocalFrame(main_frame->GetFrame()->Tree().FirstChild())); |
3898 | 3904 |
3899 WebPoint baseline_point; | 3905 WebPoint baseline_point; |
3900 NSAttributedString* result = WebSubstringUtil::AttributedSubstringInRange( | 3906 NSAttributedString* result = WebSubstringUtil::AttributedSubstringInRange( |
(...skipping 17 matching lines...) Expand all Loading... |
3918 ASSERT_NE(result, nullptr); | 3924 ASSERT_NE(result, nullptr); |
3919 | 3925 |
3920 EXPECT_EQ(y_before_change, baseline_point.y - 100); | 3926 EXPECT_EQ(y_before_change, baseline_point.y - 100); |
3921 } | 3927 } |
3922 | 3928 |
3923 #endif | 3929 #endif |
3924 | 3930 |
3925 TEST_P(WebViewTest, PasswordFieldEditingIsUserGesture) { | 3931 TEST_P(WebViewTest, PasswordFieldEditingIsUserGesture) { |
3926 RegisterMockedHttpURLLoad("input_field_password.html"); | 3932 RegisterMockedHttpURLLoad("input_field_password.html"); |
3927 MockAutofillClient client; | 3933 MockAutofillClient client; |
3928 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3934 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3929 base_url_ + "input_field_password.html", true); | 3935 base_url_ + "input_field_password.html", true); |
3930 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); | 3936 WebLocalFrameImpl* frame = web_view->MainFrameImpl(); |
3931 frame->SetAutofillClient(&client); | 3937 frame->SetAutofillClient(&client); |
3932 web_view->SetInitialFocus(false); | 3938 web_view->SetInitialFocus(false); |
3933 | 3939 |
3934 WebVector<WebCompositionUnderline> empty_underlines; | 3940 WebVector<WebCompositionUnderline> empty_underlines; |
3935 | 3941 |
3936 EXPECT_TRUE( | 3942 EXPECT_TRUE( |
3937 frame->FrameWidget()->GetActiveWebInputMethodController()->CommitText( | 3943 frame->FrameWidget()->GetActiveWebInputMethodController()->CommitText( |
3938 WebString::FromUTF8(std::string("hello").c_str()), empty_underlines, | 3944 WebString::FromUTF8(std::string("hello").c_str()), empty_underlines, |
3939 WebRange(), 0)); | 3945 WebRange(), 0)); |
3940 EXPECT_EQ(1, client.TextChangesFromUserGesture()); | 3946 EXPECT_EQ(1, client.TextChangesFromUserGesture()); |
3941 EXPECT_FALSE(UserGestureIndicator::ProcessingUserGesture()); | 3947 EXPECT_FALSE(UserGestureIndicator::ProcessingUserGesture()); |
3942 frame->SetAutofillClient(0); | 3948 frame->SetAutofillClient(0); |
3943 } | 3949 } |
3944 | 3950 |
3945 // Verify that a WebView created with a ScopedPageSuspender already on the | 3951 // Verify that a WebView created with a ScopedPageSuspender already on the |
3946 // stack defers its loads. | 3952 // stack defers its loads. |
3947 TEST_P(WebViewTest, CreatedDuringPageSuspension) { | 3953 TEST_P(WebViewTest, CreatedDuringPageSuspension) { |
3948 { | 3954 { |
3949 WebViewImpl* web_view = web_view_helper_.Initialize(); | 3955 WebViewBase* web_view = web_view_helper_.Initialize(); |
3950 EXPECT_FALSE(web_view->GetPage()->Suspended()); | 3956 EXPECT_FALSE(web_view->GetPage()->Suspended()); |
3951 } | 3957 } |
3952 | 3958 |
3953 { | 3959 { |
3954 ScopedPageSuspender suspender; | 3960 ScopedPageSuspender suspender; |
3955 WebViewImpl* web_view = web_view_helper_.Initialize(); | 3961 WebViewBase* web_view = web_view_helper_.Initialize(); |
3956 EXPECT_TRUE(web_view->GetPage()->Suspended()); | 3962 EXPECT_TRUE(web_view->GetPage()->Suspended()); |
3957 } | 3963 } |
3958 } | 3964 } |
3959 | 3965 |
3960 // Make sure the SubframeBeforeUnloadUseCounter is only incremented on subframe | 3966 // Make sure the SubframeBeforeUnloadUseCounter is only incremented on subframe |
3961 // unloads. crbug.com/635029. | 3967 // unloads. crbug.com/635029. |
3962 TEST_P(WebViewTest, SubframeBeforeUnloadUseCounter) { | 3968 TEST_P(WebViewTest, SubframeBeforeUnloadUseCounter) { |
3963 RegisterMockedHttpURLLoad("visible_iframe.html"); | 3969 RegisterMockedHttpURLLoad("visible_iframe.html"); |
3964 RegisterMockedHttpURLLoad("single_iframe.html"); | 3970 RegisterMockedHttpURLLoad("single_iframe.html"); |
3965 WebViewImpl* web_view = web_view_helper_.InitializeAndLoad( | 3971 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
3966 base_url_ + "single_iframe.html", true); | 3972 base_url_ + "single_iframe.html", true); |
3967 | 3973 |
3968 WebFrame* frame = web_view_helper_.WebView()->MainFrame(); | 3974 WebFrame* frame = web_view_helper_.WebView()->MainFrame(); |
3969 Document* document = | 3975 Document* document = |
3970 ToLocalFrame(web_view_helper_.WebView()->GetPage()->MainFrame()) | 3976 ToLocalFrame(web_view_helper_.WebView()->GetPage()->MainFrame()) |
3971 ->GetDocument(); | 3977 ->GetDocument(); |
3972 | 3978 |
3973 // Add a beforeunload handler in the main frame. Make sure firing | 3979 // Add a beforeunload handler in the main frame. Make sure firing |
3974 // beforeunload doesn't increment the subframe use counter. | 3980 // beforeunload doesn't increment the subframe use counter. |
3975 { | 3981 { |
(...skipping 22 matching lines...) Expand all Loading... |
3998 .FirstChild()) | 4004 .FirstChild()) |
3999 ->GetDocument(); | 4005 ->GetDocument(); |
4000 EXPECT_TRUE(UseCounter::IsCounted(*child_document, | 4006 EXPECT_TRUE(UseCounter::IsCounted(*child_document, |
4001 UseCounter::kSubFrameBeforeUnloadFired)); | 4007 UseCounter::kSubFrameBeforeUnloadFired)); |
4002 } | 4008 } |
4003 } | 4009 } |
4004 | 4010 |
4005 // Verify that page loads are deferred until all ScopedPageLoadDeferrers are | 4011 // Verify that page loads are deferred until all ScopedPageLoadDeferrers are |
4006 // destroyed. | 4012 // destroyed. |
4007 TEST_P(WebViewTest, NestedPageSuspensions) { | 4013 TEST_P(WebViewTest, NestedPageSuspensions) { |
4008 WebViewImpl* web_view = web_view_helper_.Initialize(); | 4014 WebViewBase* web_view = web_view_helper_.Initialize(); |
4009 EXPECT_FALSE(web_view->GetPage()->Suspended()); | 4015 EXPECT_FALSE(web_view->GetPage()->Suspended()); |
4010 | 4016 |
4011 { | 4017 { |
4012 ScopedPageSuspender suspender; | 4018 ScopedPageSuspender suspender; |
4013 EXPECT_TRUE(web_view->GetPage()->Suspended()); | 4019 EXPECT_TRUE(web_view->GetPage()->Suspended()); |
4014 | 4020 |
4015 { | 4021 { |
4016 ScopedPageSuspender suspender2; | 4022 ScopedPageSuspender suspender2; |
4017 EXPECT_TRUE(web_view->GetPage()->Suspended()); | 4023 EXPECT_TRUE(web_view->GetPage()->Suspended()); |
4018 } | 4024 } |
4019 | 4025 |
4020 EXPECT_TRUE(web_view->GetPage()->Suspended()); | 4026 EXPECT_TRUE(web_view->GetPage()->Suspended()); |
4021 } | 4027 } |
4022 | 4028 |
4023 EXPECT_FALSE(web_view->GetPage()->Suspended()); | 4029 EXPECT_FALSE(web_view->GetPage()->Suspended()); |
4024 } | 4030 } |
4025 | 4031 |
4026 TEST_P(WebViewTest, ClosingPageIsSuspended) { | 4032 TEST_P(WebViewTest, ClosingPageIsSuspended) { |
4027 WebViewImpl* web_view = web_view_helper_.Initialize(); | 4033 WebViewBase* web_view = web_view_helper_.Initialize(); |
4028 Page* page = web_view_helper_.WebView()->GetPage(); | 4034 Page* page = web_view_helper_.WebView()->GetPage(); |
4029 EXPECT_FALSE(page->Suspended()); | 4035 EXPECT_FALSE(page->Suspended()); |
4030 | 4036 |
4031 web_view->SetOpenedByDOM(); | 4037 web_view->SetOpenedByDOM(); |
4032 | 4038 |
4033 LocalFrame* main_frame = ToLocalFrame(page->MainFrame()); | 4039 LocalFrame* main_frame = ToLocalFrame(page->MainFrame()); |
4034 EXPECT_FALSE(main_frame->DomWindow()->closed()); | 4040 EXPECT_FALSE(main_frame->DomWindow()->closed()); |
4035 | 4041 |
4036 main_frame->DomWindow()->close(nullptr); | 4042 main_frame->DomWindow()->close(nullptr); |
4037 // The window should be marked closed... | 4043 // The window should be marked closed... |
4038 EXPECT_TRUE(main_frame->DomWindow()->closed()); | 4044 EXPECT_TRUE(main_frame->DomWindow()->closed()); |
4039 // EXPECT_TRUE(page->isClosing()); | 4045 // EXPECT_TRUE(page->isClosing()); |
4040 // ...but not yet detached. | 4046 // ...but not yet detached. |
4041 EXPECT_TRUE(main_frame->GetPage()); | 4047 EXPECT_TRUE(main_frame->GetPage()); |
4042 | 4048 |
4043 { | 4049 { |
4044 ScopedPageSuspender suspender; | 4050 ScopedPageSuspender suspender; |
4045 EXPECT_TRUE(page->Suspended()); | 4051 EXPECT_TRUE(page->Suspended()); |
4046 } | 4052 } |
4047 } | 4053 } |
4048 | 4054 |
4049 TEST_P(WebViewTest, ForceAndResetViewport) { | 4055 TEST_P(WebViewTest, ForceAndResetViewport) { |
4050 RegisterMockedHttpURLLoad("200-by-300.html"); | 4056 RegisterMockedHttpURLLoad("200-by-300.html"); |
4051 WebViewImpl* web_view_impl = | 4057 WebViewBase* web_view_impl = |
4052 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 4058 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
4053 web_view_impl->Resize(WebSize(100, 150)); | 4059 web_view_impl->Resize(WebSize(100, 150)); |
4054 web_view_impl->LayerTreeView()->SetViewportSize(WebSize(100, 150)); | 4060 web_view_impl->LayerTreeView()->SetViewportSize(WebSize(100, 150)); |
4055 VisualViewport* visual_viewport = | 4061 VisualViewport* visual_viewport = |
4056 &web_view_impl->GetPage()->GetVisualViewport(); | 4062 &web_view_impl->GetPage()->GetVisualViewport(); |
4057 DevToolsEmulator* dev_tools_emulator = web_view_impl->GetDevToolsEmulator(); | 4063 DevToolsEmulator* dev_tools_emulator = web_view_impl->GetDevToolsEmulator(); |
4058 | 4064 |
4059 TransformationMatrix expected_matrix; | 4065 TransformationMatrix expected_matrix; |
4060 expected_matrix.MakeIdentity(); | 4066 expected_matrix.MakeIdentity(); |
4061 EXPECT_EQ(expected_matrix, | 4067 EXPECT_EQ(expected_matrix, |
(...skipping 25 matching lines...) Expand all Loading... |
4087 dev_tools_emulator->ResetViewport(); | 4093 dev_tools_emulator->ResetViewport(); |
4088 expected_matrix.MakeIdentity(); | 4094 expected_matrix.MakeIdentity(); |
4089 EXPECT_EQ(expected_matrix, | 4095 EXPECT_EQ(expected_matrix, |
4090 web_view_impl->GetDeviceEmulationTransformForTesting()); | 4096 web_view_impl->GetDeviceEmulationTransformForTesting()); |
4091 EXPECT_FALSE(dev_tools_emulator->VisibleContentRectForPainting()); | 4097 EXPECT_FALSE(dev_tools_emulator->VisibleContentRectForPainting()); |
4092 EXPECT_TRUE(visual_viewport->ContainerLayer()->MasksToBounds()); | 4098 EXPECT_TRUE(visual_viewport->ContainerLayer()->MasksToBounds()); |
4093 } | 4099 } |
4094 | 4100 |
4095 TEST_P(WebViewTest, ViewportOverrideIntegratesDeviceMetricsOffsetAndScale) { | 4101 TEST_P(WebViewTest, ViewportOverrideIntegratesDeviceMetricsOffsetAndScale) { |
4096 RegisterMockedHttpURLLoad("200-by-300.html"); | 4102 RegisterMockedHttpURLLoad("200-by-300.html"); |
4097 WebViewImpl* web_view_impl = | 4103 WebViewBase* web_view_impl = |
4098 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 4104 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
4099 web_view_impl->Resize(WebSize(100, 150)); | 4105 web_view_impl->Resize(WebSize(100, 150)); |
4100 | 4106 |
4101 TransformationMatrix expected_matrix; | 4107 TransformationMatrix expected_matrix; |
4102 expected_matrix.MakeIdentity(); | 4108 expected_matrix.MakeIdentity(); |
4103 EXPECT_EQ(expected_matrix, | 4109 EXPECT_EQ(expected_matrix, |
4104 web_view_impl->GetDeviceEmulationTransformForTesting()); | 4110 web_view_impl->GetDeviceEmulationTransformForTesting()); |
4105 | 4111 |
4106 WebDeviceEmulationParams emulation_params; | 4112 WebDeviceEmulationParams emulation_params; |
4107 emulation_params.offset = WebFloatPoint(50, 50); | 4113 emulation_params.offset = WebFloatPoint(50, 50); |
(...skipping 10 matching lines...) Expand all Loading... |
4118 .Scale(1.5f) | 4124 .Scale(1.5f) |
4119 .Translate(-5, -10) | 4125 .Translate(-5, -10) |
4120 .Translate(50, 50) | 4126 .Translate(50, 50) |
4121 .Scale(2.f); | 4127 .Scale(2.f); |
4122 EXPECT_EQ(expected_matrix, | 4128 EXPECT_EQ(expected_matrix, |
4123 web_view_impl->GetDeviceEmulationTransformForTesting()); | 4129 web_view_impl->GetDeviceEmulationTransformForTesting()); |
4124 } | 4130 } |
4125 | 4131 |
4126 TEST_P(WebViewTest, ViewportOverrideAdaptsToScaleAndScroll) { | 4132 TEST_P(WebViewTest, ViewportOverrideAdaptsToScaleAndScroll) { |
4127 RegisterMockedHttpURLLoad("200-by-300.html"); | 4133 RegisterMockedHttpURLLoad("200-by-300.html"); |
4128 WebViewImpl* web_view_impl = | 4134 WebViewBase* web_view_impl = |
4129 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 4135 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
4130 web_view_impl->Resize(WebSize(100, 150)); | 4136 web_view_impl->Resize(WebSize(100, 150)); |
4131 web_view_impl->LayerTreeView()->SetViewportSize(WebSize(100, 150)); | 4137 web_view_impl->LayerTreeView()->SetViewportSize(WebSize(100, 150)); |
4132 FrameView* frame_view = web_view_impl->MainFrameImpl()->GetFrame()->View(); | 4138 FrameView* frame_view = web_view_impl->MainFrameImpl()->GetFrame()->View(); |
4133 DevToolsEmulator* dev_tools_emulator = web_view_impl->GetDevToolsEmulator(); | 4139 DevToolsEmulator* dev_tools_emulator = web_view_impl->GetDevToolsEmulator(); |
4134 | 4140 |
4135 TransformationMatrix expected_matrix; | 4141 TransformationMatrix expected_matrix; |
4136 expected_matrix.MakeIdentity(); | 4142 expected_matrix.MakeIdentity(); |
4137 EXPECT_EQ(expected_matrix, | 4143 EXPECT_EQ(expected_matrix, |
4138 web_view_impl->GetDeviceEmulationTransformForTesting()); | 4144 web_view_impl->GetDeviceEmulationTransformForTesting()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4176 .Translate(50, 55) | 4182 .Translate(50, 55) |
4177 .Scale(1. / 2.f); | 4183 .Scale(1. / 2.f); |
4178 EXPECT_EQ(expected_matrix, | 4184 EXPECT_EQ(expected_matrix, |
4179 web_view_impl->GetDeviceEmulationTransformForTesting()); | 4185 web_view_impl->GetDeviceEmulationTransformForTesting()); |
4180 // visibleContentRect doesn't change. | 4186 // visibleContentRect doesn't change. |
4181 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4187 EXPECT_EQ(IntRect(50, 55, 50, 75), |
4182 *dev_tools_emulator->VisibleContentRectForPainting()); | 4188 *dev_tools_emulator->VisibleContentRectForPainting()); |
4183 } | 4189 } |
4184 | 4190 |
4185 TEST_P(WebViewTest, ResizeForPrintingViewportUnits) { | 4191 TEST_P(WebViewTest, ResizeForPrintingViewportUnits) { |
4186 WebViewImpl* web_view = web_view_helper_.Initialize(); | 4192 WebViewBase* web_view = web_view_helper_.Initialize(); |
4187 web_view->Resize(WebSize(800, 600)); | 4193 web_view->Resize(WebSize(800, 600)); |
4188 | 4194 |
4189 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 4195 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
4190 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), | 4196 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |
4191 "<style>" | 4197 "<style>" |
4192 " body { margin: 0px; }" | 4198 " body { margin: 0px; }" |
4193 " #vw { width: 100vw; height: 100vh; }" | 4199 " #vw { width: 100vw; height: 100vh; }" |
4194 "</style>" | 4200 "</style>" |
4195 "<div id=vw></div>", | 4201 "<div id=vw></div>", |
4196 base_url); | 4202 base_url); |
(...skipping 22 matching lines...) Expand all Loading... |
4219 EXPECT_EQ(expected_size.Width(), vw_element->OffsetWidth()); | 4225 EXPECT_EQ(expected_size.Width(), vw_element->OffsetWidth()); |
4220 EXPECT_EQ(expected_size.Height(), vw_element->OffsetHeight()); | 4226 EXPECT_EQ(expected_size.Height(), vw_element->OffsetHeight()); |
4221 | 4227 |
4222 web_view->Resize(WebSize(800, 600)); | 4228 web_view->Resize(WebSize(800, 600)); |
4223 frame->PrintEnd(); | 4229 frame->PrintEnd(); |
4224 | 4230 |
4225 EXPECT_EQ(800, vw_element->OffsetWidth()); | 4231 EXPECT_EQ(800, vw_element->OffsetWidth()); |
4226 } | 4232 } |
4227 | 4233 |
4228 TEST_P(WebViewTest, WidthMediaQueryWithPageZoomAfterPrinting) { | 4234 TEST_P(WebViewTest, WidthMediaQueryWithPageZoomAfterPrinting) { |
4229 WebViewImpl* web_view = web_view_helper_.Initialize(); | 4235 WebViewBase* web_view = web_view_helper_.Initialize(); |
4230 web_view->Resize(WebSize(800, 600)); | 4236 web_view->Resize(WebSize(800, 600)); |
4231 web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); | 4237 web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); |
4232 | 4238 |
4233 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 4239 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
4234 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), | 4240 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |
4235 "<style>" | 4241 "<style>" |
4236 " @media (max-width: 600px) {" | 4242 " @media (max-width: 600px) {" |
4237 " div { color: green }" | 4243 " div { color: green }" |
4238 " }" | 4244 " }" |
4239 "</style>" | 4245 "</style>" |
(...skipping 14 matching lines...) Expand all Loading... |
4254 print_params.print_content_area.height = page_size.Height(); | 4260 print_params.print_content_area.height = page_size.Height(); |
4255 | 4261 |
4256 frame->PrintBegin(print_params, WebNode()); | 4262 frame->PrintBegin(print_params, WebNode()); |
4257 frame->PrintEnd(); | 4263 frame->PrintEnd(); |
4258 | 4264 |
4259 EXPECT_EQ(MakeRGB(0, 128, 0), | 4265 EXPECT_EQ(MakeRGB(0, 128, 0), |
4260 div->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor)); | 4266 div->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor)); |
4261 } | 4267 } |
4262 | 4268 |
4263 TEST_P(WebViewTest, ViewportUnitsPrintingWithPageZoom) { | 4269 TEST_P(WebViewTest, ViewportUnitsPrintingWithPageZoom) { |
4264 WebViewImpl* web_view = web_view_helper_.Initialize(); | 4270 WebViewBase* web_view = web_view_helper_.Initialize(); |
4265 web_view->Resize(WebSize(800, 600)); | 4271 web_view->Resize(WebSize(800, 600)); |
4266 web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); | 4272 web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(2.0)); |
4267 | 4273 |
4268 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 4274 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
4269 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), | 4275 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |
4270 "<style>" | 4276 "<style>" |
4271 " body { margin: 0 }" | 4277 " body { margin: 0 }" |
4272 " #t1 { width: 100% }" | 4278 " #t1 { width: 100% }" |
4273 " #t2 { width: 100vw }" | 4279 " #t2 { width: 100vw }" |
4274 "</style>" | 4280 "</style>" |
(...skipping 18 matching lines...) Expand all Loading... |
4293 | 4299 |
4294 frame->PrintBegin(print_params, WebNode()); | 4300 frame->PrintBegin(print_params, WebNode()); |
4295 | 4301 |
4296 EXPECT_EQ(expected_width, t1->OffsetWidth()); | 4302 EXPECT_EQ(expected_width, t1->OffsetWidth()); |
4297 EXPECT_EQ(expected_width, t2->OffsetWidth()); | 4303 EXPECT_EQ(expected_width, t2->OffsetWidth()); |
4298 | 4304 |
4299 frame->PrintEnd(); | 4305 frame->PrintEnd(); |
4300 } | 4306 } |
4301 | 4307 |
4302 TEST_P(WebViewTest, DeviceEmulationResetScrollbars) { | 4308 TEST_P(WebViewTest, DeviceEmulationResetScrollbars) { |
4303 WebViewImpl* web_view = web_view_helper_.Initialize(); | 4309 WebViewBase* web_view = web_view_helper_.Initialize(); |
4304 web_view->Resize(WebSize(800, 600)); | 4310 web_view->Resize(WebSize(800, 600)); |
4305 | 4311 |
4306 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); | 4312 WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); |
4307 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), | 4313 FrameTestHelpers::LoadHTMLString(web_view->MainFrame(), |
4308 "<!doctype html>" | 4314 "<!doctype html>" |
4309 "<meta name='viewport'" | 4315 "<meta name='viewport'" |
4310 " content='width=device-width'>" | 4316 " content='width=device-width'>" |
4311 "<style>" | 4317 "<style>" |
4312 " body {margin: 0px; height:3000px;}" | 4318 " body {margin: 0px; height:3000px;}" |
4313 "</style>", | 4319 "</style>", |
(...skipping 28 matching lines...) Expand all Loading... |
4342 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4348 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |
4343 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 4349 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
4344 EXPECT_NE(nullptr, | 4350 EXPECT_NE(nullptr, |
4345 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4351 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |
4346 } else { | 4352 } else { |
4347 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4353 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |
4348 } | 4354 } |
4349 } | 4355 } |
4350 | 4356 |
4351 } // namespace blink | 4357 } // namespace blink |
OLD | NEW |