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

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

Issue 2012823003: Move IME related functions from WebFrame to WebLocalFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove most of the null checks except the one in spellcheck_provider.cc Created 4 years, 6 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 3177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 FrameTestHelpers::WebViewHelper webViewHelper(this); 3188 FrameTestHelpers::WebViewHelper webViewHelper(this);
3189 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); 3189 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html");
3190 webViewHelper.resize(WebSize(640, 480)); 3190 webViewHelper.resize(WebSize(640, 480));
3191 3191
3192 webViewHelper.webViewImpl()->setPageScaleFactor(2); 3192 webViewHelper.webViewImpl()->setPageScaleFactor(2);
3193 webViewHelper.webViewImpl()->setVisualViewportOffset(WebFloatPoint(50, 60)); 3193 webViewHelper.webViewImpl()->setVisualViewportOffset(WebFloatPoint(50, 60));
3194 3194
3195 WebRect baseRect; 3195 WebRect baseRect;
3196 WebRect extentRect; 3196 WebRect extentRect;
3197 3197
3198 WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame(); 3198 WebLocalFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame()->toWebLo calFrame();
3199 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388)); 3199 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388));
3200 3200
3201 EXPECT_EQ(2ul, ix); 3201 EXPECT_EQ(2ul, ix);
3202 } 3202 }
3203 3203
3204 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) 3204 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom)
3205 { 3205 {
3206 registerMockedHttpURLLoad("textbox.html"); 3206 registerMockedHttpURLLoad("textbox.html");
3207 3207
3208 FrameTestHelpers::WebViewHelper webViewHelper(this); 3208 FrameTestHelpers::WebViewHelper webViewHelper(this);
3209 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true); 3209 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true);
3210 webViewHelper.resize(WebSize(640, 480)); 3210 webViewHelper.resize(WebSize(640, 480));
3211 3211
3212 WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame(); 3212 WebLocalFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame()->toWebLo calFrame();
3213 mainFrame->executeScript(WebScriptSource("selectRange();")); 3213 mainFrame->executeScript(WebScriptSource("selectRange();"));
3214 3214
3215 WebRect oldRect; 3215 WebRect oldRect;
3216 mainFrame->firstRectForCharacterRange(0, 5, oldRect); 3216 mainFrame->firstRectForCharacterRange(0, 5, oldRect);
3217 3217
3218 WebFloatPoint visualOffset(100, 130); 3218 WebFloatPoint visualOffset(100, 130);
3219 float scale = 2; 3219 float scale = 2;
3220 webViewHelper.webViewImpl()->setPageScaleFactor(scale); 3220 webViewHelper.webViewImpl()->setPageScaleFactor(scale);
3221 webViewHelper.webViewImpl()->setVisualViewportOffset(visualOffset); 3221 webViewHelper.webViewImpl()->setVisualViewportOffset(visualOffset);
3222 3222
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
3656 // Get the frame text where the subframe separator falls on the boundary of 3656 // Get the frame text where the subframe separator falls on the boundary of
3657 // what we'll take. There used to be a crash in this case. 3657 // what we'll take. There used to be a crash in this case.
3658 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ; 3658 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ;
3659 EXPECT_EQ("Hello world", text.utf8()); 3659 EXPECT_EQ("Hello world", text.utf8());
3660 } 3660 }
3661 3661
3662 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) 3662 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage)
3663 { 3663 {
3664 FrameTestHelpers::WebViewHelper webViewHelper(this); 3664 FrameTestHelpers::WebViewHelper webViewHelper(this);
3665 webViewHelper.initializeAndLoad("about:blank", true); 3665 webViewHelper.initializeAndLoad("about:blank", true);
3666 WebFrame* frame = webViewHelper.webView()->mainFrame(); 3666 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
3667 3667
3668 // Generate a simple test case. 3668 // Generate a simple test case.
3669 const char simpleSource[] = "<p>Hello</p><p>World</p>"; 3669 const char simpleSource[] = "<p>Hello</p><p>World</p>";
3670 KURL testURL = toKURL("about:blank"); 3670 KURL testURL = toKURL("about:blank");
3671 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); 3671 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL);
3672 3672
3673 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max()); 3673 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max());
3674 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3674 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3675 3675
3676 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame->toWebLoc alFrame()).utf8(); 3676 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame).utf8();
3677 3677
3678 // Load again with the output html. 3678 // Load again with the output html.
3679 FrameTestHelpers::loadHTMLString(frame, html, testURL); 3679 FrameTestHelpers::loadHTMLString(frame, html, testURL);
3680 3680
3681 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame->toWebLocalFrame() ).utf8()); 3681 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame).utf8());
3682 3682
3683 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std ::numeric_limits<size_t>::max()); 3683 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std ::numeric_limits<size_t>::max());
3684 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3684 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3685 3685
3686 // Test selection check 3686 // Test selection check
3687 EXPECT_FALSE(frame->hasSelection()); 3687 EXPECT_FALSE(frame->hasSelection());
3688 frame->executeCommand(WebString::fromUTF8("SelectAll")); 3688 frame->executeCommand(WebString::fromUTF8("SelectAll"));
3689 EXPECT_TRUE(frame->hasSelection()); 3689 EXPECT_TRUE(frame->hasSelection());
3690 frame->executeCommand(WebString::fromUTF8("Unselect")); 3690 frame->executeCommand(WebString::fromUTF8("Unselect"));
3691 EXPECT_FALSE(frame->hasSelection()); 3691 EXPECT_FALSE(frame->hasSelection());
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
4119 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 4119 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
4120 } 4120 }
4121 4121
4122 static WebRect elementBounds(WebFrame* frame, const WebString& id) 4122 static WebRect elementBounds(WebFrame* frame, const WebString& id)
4123 { 4123 {
4124 return frame->document().getElementById(id).boundsInViewport(); 4124 return frame->document().getElementById(id).boundsInViewport();
4125 } 4125 }
4126 4126
4127 static std::string selectionAsString(WebFrame* frame) 4127 static std::string selectionAsString(WebFrame* frame)
4128 { 4128 {
4129 return frame->selectionAsText().utf8(); 4129 return frame->toWebLocalFrame()->selectionAsText().utf8();
4130 } 4130 }
4131 4131
4132 TEST_P(ParameterizedWebFrameTest, SelectRange) 4132 TEST_P(ParameterizedWebFrameTest, SelectRange)
4133 { 4133 {
4134 WebFrame* frame; 4134 WebLocalFrame* frame;
4135 WebRect startWebRect; 4135 WebRect startWebRect;
4136 WebRect endWebRect; 4136 WebRect endWebRect;
4137 4137
4138 registerMockedHttpURLLoad("select_range_basic.html"); 4138 registerMockedHttpURLLoad("select_range_basic.html");
4139 registerMockedHttpURLLoad("select_range_scroll.html"); 4139 registerMockedHttpURLLoad("select_range_scroll.html");
4140 4140
4141 FrameTestHelpers::WebViewHelper webViewHelper(this); 4141 FrameTestHelpers::WebViewHelper webViewHelper(this);
4142 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper); 4142 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper);
4143 frame = webViewHelper.webView()->mainFrame(); 4143 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4144 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); 4144 EXPECT_EQ("Some test text for testing.", selectionAsString(frame));
4145 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4145 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4146 frame->executeCommand(WebString::fromUTF8("Unselect")); 4146 frame->executeCommand(WebString::fromUTF8("Unselect"));
4147 EXPECT_EQ("", selectionAsString(frame)); 4147 EXPECT_EQ("", selectionAsString(frame));
4148 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4148 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4149 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4149 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4150 std::string selectionString = selectionAsString(frame); 4150 std::string selectionString = selectionAsString(frame);
4151 EXPECT_TRUE(selectionString == "Some test text for testing." 4151 EXPECT_TRUE(selectionString == "Some test text for testing."
4152 || selectionString == "Some test text for testing"); 4152 || selectionString == "Some test text for testing");
4153 4153
4154 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper); 4154 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper);
4155 frame = webViewHelper.webView()->mainFrame(); 4155 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4156 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ; 4156 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ;
4157 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4157 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4158 frame->executeCommand(WebString::fromUTF8("Unselect")); 4158 frame->executeCommand(WebString::fromUTF8("Unselect"));
4159 EXPECT_EQ("", selectionAsString(frame)); 4159 EXPECT_EQ("", selectionAsString(frame));
4160 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4160 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4161 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4161 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4162 selectionString = selectionAsString(frame); 4162 selectionString = selectionAsString(frame);
4163 EXPECT_TRUE(selectionString == "Some offscreen test text for testing." 4163 EXPECT_TRUE(selectionString == "Some offscreen test text for testing."
4164 || selectionString == "Some offscreen test text for testing"); 4164 || selectionString == "Some offscreen test text for testing");
4165 } 4165 }
4166 4166
4167 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) 4167 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe)
4168 { 4168 {
4169 WebFrame* frame; 4169 WebFrame* frame;
4170 WebRect startWebRect; 4170 WebRect startWebRect;
4171 WebRect endWebRect; 4171 WebRect endWebRect;
4172 4172
4173 registerMockedHttpURLLoad("select_range_iframe.html"); 4173 registerMockedHttpURLLoad("select_range_iframe.html");
4174 registerMockedHttpURLLoad("select_range_basic.html"); 4174 registerMockedHttpURLLoad("select_range_basic.html");
4175 4175
4176 FrameTestHelpers::WebViewHelper webViewHelper(this); 4176 FrameTestHelpers::WebViewHelper webViewHelper(this);
4177 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV iewHelper); 4177 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV iewHelper);
4178 frame = webViewHelper.webView()->mainFrame(); 4178 frame = webViewHelper.webView()->mainFrame();
4179 WebFrame* subframe = frame->firstChild(); 4179 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame();
4180 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); 4180 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe));
4181 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4181 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4182 subframe->executeCommand(WebString::fromUTF8("Unselect")); 4182 subframe->executeCommand(WebString::fromUTF8("Unselect"));
4183 EXPECT_EQ("", selectionAsString(subframe)); 4183 EXPECT_EQ("", selectionAsString(subframe));
4184 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect) ); 4184 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect) );
4185 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4185 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4186 std::string selectionString = selectionAsString(subframe); 4186 std::string selectionString = selectionAsString(subframe);
4187 EXPECT_TRUE(selectionString == "Some test text for testing." 4187 EXPECT_TRUE(selectionString == "Some test text for testing."
4188 || selectionString == "Some test text for testing"); 4188 || selectionString == "Some test text for testing");
4189 } 4189 }
4190 4190
4191 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) 4191 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable)
4192 { 4192 {
4193 WebFrame* frame; 4193 WebLocalFrame* frame;
4194 WebRect startWebRect; 4194 WebRect startWebRect;
4195 WebRect endWebRect; 4195 WebRect endWebRect;
4196 4196
4197 registerMockedHttpURLLoad("select_range_div_editable.html"); 4197 registerMockedHttpURLLoad("select_range_div_editable.html");
4198 4198
4199 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4199 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4200 // The selection range should be clipped to the bounds of the editable eleme nt. 4200 // The selection range should be clipped to the bounds of the editable eleme nt.
4201 FrameTestHelpers::WebViewHelper webViewHelper(this); 4201 FrameTestHelpers::WebViewHelper webViewHelper(this);
4202 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4202 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4203 frame = webViewHelper.webView()->mainFrame(); 4203 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4204 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4204 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4205 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4205 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4206 4206
4207 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4207 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4208 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4208 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4209 4209
4210 // As above, but extending the selection to the bottom of the document. 4210 // As above, but extending the selection to the bottom of the document.
4211 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4211 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4212 frame = webViewHelper.webView()->mainFrame(); 4212 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4213 4213
4214 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4214 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4215 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4215 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4216 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4216 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4217 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4217 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4218 4218
4219 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4219 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4220 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4220 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4221 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4221 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4222 } 4222 }
4223 4223
4224 // positionForPoint returns the wrong values for contenteditable spans. See 4224 // positionForPoint returns the wrong values for contenteditable spans. See
4225 // http://crbug.com/238334. 4225 // http://crbug.com/238334.
4226 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) 4226 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable)
4227 { 4227 {
4228 WebFrame* frame; 4228 WebLocalFrame* frame;
4229 WebRect startWebRect; 4229 WebRect startWebRect;
4230 WebRect endWebRect; 4230 WebRect endWebRect;
4231 4231
4232 registerMockedHttpURLLoad("select_range_span_editable.html"); 4232 registerMockedHttpURLLoad("select_range_span_editable.html");
4233 4233
4234 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4234 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4235 // The selection range should be clipped to the bounds of the editable eleme nt. 4235 // The selection range should be clipped to the bounds of the editable eleme nt.
4236 FrameTestHelpers::WebViewHelper webViewHelper(this); 4236 FrameTestHelpers::WebViewHelper webViewHelper(this);
4237 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4237 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4238 frame = webViewHelper.webView()->mainFrame(); 4238 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4239 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4239 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4240 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4240 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4241 4241
4242 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4242 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4243 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4243 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4244 4244
4245 // As above, but extending the selection to the bottom of the document. 4245 // As above, but extending the selection to the bottom of the document.
4246 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4246 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4247 frame = webViewHelper.webView()->mainFrame(); 4247 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4248 4248
4249 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4249 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4250 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4250 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4251 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4251 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4252 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4252 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4253 4253
4254 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4254 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4255 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4255 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4256 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4256 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4257 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4257 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4258 } 4258 }
4259 4259
4260 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) 4260 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart)
4261 { 4261 {
4262 registerMockedHttpURLLoad("text_selection.html"); 4262 registerMockedHttpURLLoad("text_selection.html");
4263 FrameTestHelpers::WebViewHelper webViewHelper(this); 4263 FrameTestHelpers::WebViewHelper webViewHelper(this);
4264 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4264 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4265 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4265 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4266 4266
4267 // Select second span. We can move the start to include the first span. 4267 // Select second span. We can move the start to include the first span.
4268 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4268 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4269 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4269 EXPECT_EQ("Header 2.", selectionAsString(frame));
4270 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1"))); 4270 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1")));
4271 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4271 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4272 4272
4273 // We can move the start and end together. 4273 // We can move the start and end together.
4274 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4274 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4275 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4275 EXPECT_EQ("Header 1.", selectionAsString(frame));
(...skipping 27 matching lines...) Expand all
4303 // positionForPoint returns the wrong values for contenteditable spans. See 4303 // positionForPoint returns the wrong values for contenteditable spans. See
4304 // http://crbug.com/238334. 4304 // http://crbug.com/238334.
4305 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); 4305 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame));
4306 } 4306 }
4307 4307
4308 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) 4308 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd)
4309 { 4309 {
4310 registerMockedHttpURLLoad("text_selection.html"); 4310 registerMockedHttpURLLoad("text_selection.html");
4311 FrameTestHelpers::WebViewHelper webViewHelper(this); 4311 FrameTestHelpers::WebViewHelper webViewHelper(this);
4312 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4312 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4313 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4313 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4314 4314
4315 // Select first span. We can move the end to include the second span. 4315 // Select first span. We can move the end to include the second span.
4316 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4316 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4317 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4317 EXPECT_EQ("Header 1.", selectionAsString(frame));
4318 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2"))); 4318 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2")));
4319 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4319 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4320 4320
4321 // We can move the start and end together. 4321 // We can move the start and end together.
4322 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4322 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4323 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4323 EXPECT_EQ("Header 2.", selectionAsString(frame));
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4705 4705
4706 FrameTestHelpers::WebViewHelper webViewHelper(this); 4706 FrameTestHelpers::WebViewHelper webViewHelper(this);
4707 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr ); 4707 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr );
4708 webViewHelper.webView()->settings()->setDefaultFontSize(12); 4708 webViewHelper.webView()->settings()->setDefaultFontSize(12);
4709 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); 4709 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1);
4710 webViewHelper.resize(WebSize(viewWidth, viewHeight)); 4710 webViewHelper.resize(WebSize(viewWidth, viewHeight));
4711 webViewHelper.webView()->setFocus(true); 4711 webViewHelper.webView()->setFocus(true);
4712 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html"); 4712 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html");
4713 4713
4714 // The frame starts with no selection. 4714 // The frame starts with no selection.
4715 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4715 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4716 ASSERT_TRUE(frame->hasSelection()); 4716 ASSERT_TRUE(frame->hasSelection());
4717 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4717 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4718 4718
4719 // The selection cleared notification should be triggered upon layout. 4719 // The selection cleared notification should be triggered upon layout.
4720 frame->executeCommand(WebString::fromUTF8("Unselect")); 4720 frame->executeCommand(WebString::fromUTF8("Unselect"));
4721 ASSERT_FALSE(frame->hasSelection()); 4721 ASSERT_FALSE(frame->hasSelection());
4722 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4722 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4723 webViewHelper.webView()->updateAllLifecyclePhases(); 4723 webViewHelper.webView()->updateAllLifecyclePhases();
4724 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4724 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4725 4725
(...skipping 10 matching lines...) Expand all
4736 WebRect startWebRect; 4736 WebRect startWebRect;
4737 WebRect endWebRect; 4737 WebRect endWebRect;
4738 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect); 4738 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect);
4739 WebPoint movedEnd(bottomRightMinusOne(endWebRect)); 4739 WebPoint movedEnd(bottomRightMinusOne(endWebRect));
4740 endWebRect.x -= 20; 4740 endWebRect.x -= 20;
4741 frame->selectRange(topLeft(startWebRect), movedEnd); 4741 frame->selectRange(topLeft(startWebRect), movedEnd);
4742 webViewHelper.webView()->updateAllLifecyclePhases(); 4742 webViewHelper.webView()->updateAllLifecyclePhases();
4743 ASSERT_TRUE(frame->hasSelection()); 4743 ASSERT_TRUE(frame->hasSelection());
4744 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4744 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4745 4745
4746 frame = webViewHelper.webView()->mainFrame(); 4746 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4747 frame->executeCommand(WebString::fromUTF8("Unselect")); 4747 frame->executeCommand(WebString::fromUTF8("Unselect"));
4748 webViewHelper.webView()->updateAllLifecyclePhases(); 4748 webViewHelper.webView()->updateAllLifecyclePhases();
4749 ASSERT_FALSE(frame->hasSelection()); 4749 ASSERT_FALSE(frame->hasSelection());
4750 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4750 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4751 } 4751 }
4752 4752
4753 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient { 4753 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient {
4754 public: 4754 public:
4755 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override 4755 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override
4756 { 4756 {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
5134 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f rame starts with triggers this. 5134 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f rame starts with triggers this.
5135 } 5135 }
5136 5136
5137 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele ction) 5137 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele ction)
5138 { 5138 {
5139 FrameTestHelpers::WebViewHelper webViewHelper(this); 5139 FrameTestHelpers::WebViewHelper webViewHelper(this);
5140 webViewHelper.initializeAndLoad("about:blank", true); 5140 webViewHelper.initializeAndLoad("about:blank", true);
5141 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5141 WebFrame* frame = webViewHelper.webView()->mainFrame();
5142 5142
5143 // This test passes if this doesn't crash. 5143 // This test passes if this doesn't crash.
5144 frame->moveCaretSelection(WebPoint(0, 0)); 5144 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0));
5145 } 5145 }
5146 5146
5147 class SpellCheckClient : public WebSpellCheckClient { 5147 class SpellCheckClient : public WebSpellCheckClient {
5148 public: 5148 public:
5149 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_ hash(hash) { } 5149 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_ hash(hash) { }
5150 virtual ~SpellCheckClient() { } 5150 virtual ~SpellCheckClient() { }
5151 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override 5151 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override
5152 { 5152 {
5153 ++m_numberOfTimesChecked; 5153 ++m_numberOfTimesChecked;
5154 Vector<WebTextCheckingResult> results; 5154 Vector<WebTextCheckingResult> results;
(...skipping 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after
8638 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8638 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame();
8639 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8639 v8::HandleScope scope(v8::Isolate::GetCurrent());
8640 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8640 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8641 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8641 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8642 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8642 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8643 ASSERT_TRUE(result->IsString()); 8643 ASSERT_TRUE(result->IsString());
8644 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); 8644 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked()));
8645 } 8645 }
8646 8646
8647 } // namespace blink 8647 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698