Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

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

Powered by Google App Engine
This is Rietveld 408576698