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

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: sync 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3681 // Get the frame text where the subframe separator falls on the boundary of 3681 // Get the frame text where the subframe separator falls on the boundary of
3682 // what we'll take. There used to be a crash in this case. 3682 // what we'll take. There used to be a crash in this case.
3683 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ; 3683 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 12) ;
3684 EXPECT_EQ("Hello world", text.utf8()); 3684 EXPECT_EQ("Hello world", text.utf8());
3685 } 3685 }
3686 3686
3687 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) 3687 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage)
3688 { 3688 {
3689 FrameTestHelpers::WebViewHelper webViewHelper(this); 3689 FrameTestHelpers::WebViewHelper webViewHelper(this);
3690 webViewHelper.initializeAndLoad("about:blank", true); 3690 webViewHelper.initializeAndLoad("about:blank", true);
3691 WebFrame* frame = webViewHelper.webView()->mainFrame(); 3691 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
3692 3692
3693 // Generate a simple test case. 3693 // Generate a simple test case.
3694 const char simpleSource[] = "<p>Hello</p><p>World</p>"; 3694 const char simpleSource[] = "<p>Hello</p><p>World</p>";
3695 KURL testURL = toKURL("about:blank"); 3695 KURL testURL = toKURL("about:blank");
3696 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL); 3696 FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL);
3697 3697
3698 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max()); 3698 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max());
3699 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3699 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3700 3700
3701 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame->toWebLoc alFrame()).utf8(); 3701 const std::string html = WebFrameContentDumper::dumpAsMarkup(frame).utf8();
3702 3702
3703 // Load again with the output html. 3703 // Load again with the output html.
3704 FrameTestHelpers::loadHTMLString(frame, html, testURL); 3704 FrameTestHelpers::loadHTMLString(frame, html, testURL);
3705 3705
3706 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame->toWebLocalFrame() ).utf8()); 3706 EXPECT_EQ(html, WebFrameContentDumper::dumpAsMarkup(frame).utf8());
3707 3707
3708 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std ::numeric_limits<size_t>::max()); 3708 text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), std ::numeric_limits<size_t>::max());
3709 EXPECT_EQ("Hello\n\nWorld", text.utf8()); 3709 EXPECT_EQ("Hello\n\nWorld", text.utf8());
3710 3710
3711 // Test selection check 3711 // Test selection check
3712 EXPECT_FALSE(frame->hasSelection()); 3712 EXPECT_FALSE(frame->hasSelection());
3713 frame->executeCommand(WebString::fromUTF8("SelectAll")); 3713 frame->executeCommand(WebString::fromUTF8("SelectAll"));
3714 EXPECT_TRUE(frame->hasSelection()); 3714 EXPECT_TRUE(frame->hasSelection());
3715 frame->executeCommand(WebString::fromUTF8("Unselect")); 3715 frame->executeCommand(WebString::fromUTF8("Unselect"));
3716 EXPECT_FALSE(frame->hasSelection()); 3716 EXPECT_FALSE(frame->hasSelection());
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
4144 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 4144 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
4145 } 4145 }
4146 4146
4147 static WebRect elementBounds(WebFrame* frame, const WebString& id) 4147 static WebRect elementBounds(WebFrame* frame, const WebString& id)
4148 { 4148 {
4149 return frame->document().getElementById(id).boundsInViewport(); 4149 return frame->document().getElementById(id).boundsInViewport();
4150 } 4150 }
4151 4151
4152 static std::string selectionAsString(WebFrame* frame) 4152 static std::string selectionAsString(WebFrame* frame)
4153 { 4153 {
4154 return frame->selectionAsText().utf8(); 4154 return frame->toWebLocalFrame()->selectionAsText().utf8();
4155 } 4155 }
4156 4156
4157 TEST_P(ParameterizedWebFrameTest, SelectRange) 4157 TEST_P(ParameterizedWebFrameTest, SelectRange)
4158 { 4158 {
4159 WebFrame* frame; 4159 WebLocalFrame* frame;
4160 WebRect startWebRect; 4160 WebRect startWebRect;
4161 WebRect endWebRect; 4161 WebRect endWebRect;
4162 4162
4163 registerMockedHttpURLLoad("select_range_basic.html"); 4163 registerMockedHttpURLLoad("select_range_basic.html");
4164 registerMockedHttpURLLoad("select_range_scroll.html"); 4164 registerMockedHttpURLLoad("select_range_scroll.html");
4165 4165
4166 FrameTestHelpers::WebViewHelper webViewHelper(this); 4166 FrameTestHelpers::WebViewHelper webViewHelper(this);
4167 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper); 4167 initializeTextSelectionWebView(m_baseURL + "select_range_basic.html", &webVi ewHelper);
4168 frame = webViewHelper.webView()->mainFrame(); 4168 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4169 EXPECT_EQ("Some test text for testing.", selectionAsString(frame)); 4169 EXPECT_EQ("Some test text for testing.", selectionAsString(frame));
4170 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4170 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4171 frame->executeCommand(WebString::fromUTF8("Unselect")); 4171 frame->executeCommand(WebString::fromUTF8("Unselect"));
4172 EXPECT_EQ("", selectionAsString(frame)); 4172 EXPECT_EQ("", selectionAsString(frame));
4173 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4173 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4174 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4174 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4175 std::string selectionString = selectionAsString(frame); 4175 std::string selectionString = selectionAsString(frame);
4176 EXPECT_TRUE(selectionString == "Some test text for testing." 4176 EXPECT_TRUE(selectionString == "Some test text for testing."
4177 || selectionString == "Some test text for testing"); 4177 || selectionString == "Some test text for testing");
4178 4178
4179 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper); 4179 initializeTextSelectionWebView(m_baseURL + "select_range_scroll.html", &webV iewHelper);
4180 frame = webViewHelper.webView()->mainFrame(); 4180 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4181 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ; 4181 EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)) ;
4182 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4182 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4183 frame->executeCommand(WebString::fromUTF8("Unselect")); 4183 frame->executeCommand(WebString::fromUTF8("Unselect"));
4184 EXPECT_EQ("", selectionAsString(frame)); 4184 EXPECT_EQ("", selectionAsString(frame));
4185 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4185 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4186 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4186 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4187 selectionString = selectionAsString(frame); 4187 selectionString = selectionAsString(frame);
4188 EXPECT_TRUE(selectionString == "Some offscreen test text for testing." 4188 EXPECT_TRUE(selectionString == "Some offscreen test text for testing."
4189 || selectionString == "Some offscreen test text for testing"); 4189 || selectionString == "Some offscreen test text for testing");
4190 } 4190 }
4191 4191
4192 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe) 4192 TEST_P(ParameterizedWebFrameTest, SelectRangeInIframe)
4193 { 4193 {
4194 WebFrame* frame; 4194 WebFrame* frame;
4195 WebRect startWebRect; 4195 WebRect startWebRect;
4196 WebRect endWebRect; 4196 WebRect endWebRect;
4197 4197
4198 registerMockedHttpURLLoad("select_range_iframe.html"); 4198 registerMockedHttpURLLoad("select_range_iframe.html");
4199 registerMockedHttpURLLoad("select_range_basic.html"); 4199 registerMockedHttpURLLoad("select_range_basic.html");
4200 4200
4201 FrameTestHelpers::WebViewHelper webViewHelper(this); 4201 FrameTestHelpers::WebViewHelper webViewHelper(this);
4202 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV iewHelper); 4202 initializeTextSelectionWebView(m_baseURL + "select_range_iframe.html", &webV iewHelper);
4203 frame = webViewHelper.webView()->mainFrame(); 4203 frame = webViewHelper.webView()->mainFrame();
4204 WebFrame* subframe = frame->firstChild(); 4204 WebLocalFrame* subframe = frame->firstChild()->toWebLocalFrame();
4205 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); 4205 EXPECT_EQ("Some test text for testing.", selectionAsString(subframe));
4206 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4206 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4207 subframe->executeCommand(WebString::fromUTF8("Unselect")); 4207 subframe->executeCommand(WebString::fromUTF8("Unselect"));
4208 EXPECT_EQ("", selectionAsString(subframe)); 4208 EXPECT_EQ("", selectionAsString(subframe));
4209 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect) ); 4209 subframe->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect) );
4210 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected. 4210 // On some devices, the above bottomRightMinusOne() causes the ending '.' no t selected.
4211 std::string selectionString = selectionAsString(subframe); 4211 std::string selectionString = selectionAsString(subframe);
4212 EXPECT_TRUE(selectionString == "Some test text for testing." 4212 EXPECT_TRUE(selectionString == "Some test text for testing."
4213 || selectionString == "Some test text for testing"); 4213 || selectionString == "Some test text for testing");
4214 } 4214 }
4215 4215
4216 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable) 4216 TEST_P(ParameterizedWebFrameTest, SelectRangeDivContentEditable)
4217 { 4217 {
4218 WebFrame* frame; 4218 WebLocalFrame* frame;
4219 WebRect startWebRect; 4219 WebRect startWebRect;
4220 WebRect endWebRect; 4220 WebRect endWebRect;
4221 4221
4222 registerMockedHttpURLLoad("select_range_div_editable.html"); 4222 registerMockedHttpURLLoad("select_range_div_editable.html");
4223 4223
4224 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4224 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4225 // The selection range should be clipped to the bounds of the editable eleme nt. 4225 // The selection range should be clipped to the bounds of the editable eleme nt.
4226 FrameTestHelpers::WebViewHelper webViewHelper(this); 4226 FrameTestHelpers::WebViewHelper webViewHelper(this);
4227 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4227 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4228 frame = webViewHelper.webView()->mainFrame(); 4228 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4229 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4229 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4230 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4230 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4231 4231
4232 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4232 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4233 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4233 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4234 4234
4235 // As above, but extending the selection to the bottom of the document. 4235 // As above, but extending the selection to the bottom of the document.
4236 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper); 4236 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html", &webViewHelper);
4237 frame = webViewHelper.webView()->mainFrame(); 4237 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4238 4238
4239 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4239 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4240 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4240 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4241 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4241 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4242 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4242 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4243 4243
4244 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4244 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4245 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4245 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4246 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4246 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4247 } 4247 }
4248 4248
4249 // positionForPoint returns the wrong values for contenteditable spans. See 4249 // positionForPoint returns the wrong values for contenteditable spans. See
4250 // http://crbug.com/238334. 4250 // http://crbug.com/238334.
4251 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) 4251 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable)
4252 { 4252 {
4253 WebFrame* frame; 4253 WebLocalFrame* frame;
4254 WebRect startWebRect; 4254 WebRect startWebRect;
4255 WebRect endWebRect; 4255 WebRect endWebRect;
4256 4256
4257 registerMockedHttpURLLoad("select_range_span_editable.html"); 4257 registerMockedHttpURLLoad("select_range_span_editable.html");
4258 4258
4259 // Select the middle of an editable element, then try to extend the selectio n to the top of the document. 4259 // Select the middle of an editable element, then try to extend the selectio n to the top of the document.
4260 // The selection range should be clipped to the bounds of the editable eleme nt. 4260 // The selection range should be clipped to the bounds of the editable eleme nt.
4261 FrameTestHelpers::WebViewHelper webViewHelper(this); 4261 FrameTestHelpers::WebViewHelper webViewHelper(this);
4262 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4262 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4263 frame = webViewHelper.webView()->mainFrame(); 4263 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4264 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4264 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4265 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4265 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4266 4266
4267 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); 4267 frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0));
4268 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame)); 4268 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr ing(frame));
4269 4269
4270 // As above, but extending the selection to the bottom of the document. 4270 // As above, but extending the selection to the bottom of the document.
4271 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper); 4271 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html" , &webViewHelper);
4272 frame = webViewHelper.webView()->mainFrame(); 4272 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4273 4273
4274 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4274 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4275 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); 4275 frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect));
4276 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4276 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4277 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4277 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4278 4278
4279 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); 4279 EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
4280 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); 4280 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
4281 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); 4281 frame->selectRange(topLeft(startWebRect), WebPoint(640, 480));
4282 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame)); 4282 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr ing(frame));
4283 } 4283 }
4284 4284
4285 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) 4285 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart)
4286 { 4286 {
4287 registerMockedHttpURLLoad("text_selection.html"); 4287 registerMockedHttpURLLoad("text_selection.html");
4288 FrameTestHelpers::WebViewHelper webViewHelper(this); 4288 FrameTestHelpers::WebViewHelper webViewHelper(this);
4289 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4289 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4290 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4290 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4291 4291
4292 // Select second span. We can move the start to include the first span. 4292 // Select second span. We can move the start to include the first span.
4293 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4293 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4294 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4294 EXPECT_EQ("Header 2.", selectionAsString(frame));
4295 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1"))); 4295 frame->selectRange(bottomRightMinusOne(elementBounds(frame, "header_2")), to pLeft(elementBounds(frame, "header_1")));
4296 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4296 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4297 4297
4298 // We can move the start and end together. 4298 // We can move the start and end together.
4299 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4299 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4300 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4300 EXPECT_EQ("Header 1.", selectionAsString(frame));
(...skipping 27 matching lines...) Expand all
4328 // positionForPoint returns the wrong values for contenteditable spans. See 4328 // positionForPoint returns the wrong values for contenteditable spans. See
4329 // http://crbug.com/238334. 4329 // http://crbug.com/238334.
4330 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); 4330 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame));
4331 } 4331 }
4332 4332
4333 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) 4333 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd)
4334 { 4334 {
4335 registerMockedHttpURLLoad("text_selection.html"); 4335 registerMockedHttpURLLoad("text_selection.html");
4336 FrameTestHelpers::WebViewHelper webViewHelper(this); 4336 FrameTestHelpers::WebViewHelper webViewHelper(this);
4337 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper); 4337 initializeTextSelectionWebView(m_baseURL + "text_selection.html", &webViewHe lper);
4338 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4338 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4339 4339
4340 // Select first span. We can move the end to include the second span. 4340 // Select first span. We can move the end to include the second span.
4341 frame->executeScript(WebScriptSource("selectElement('header_1');")); 4341 frame->executeScript(WebScriptSource("selectElement('header_1');"));
4342 EXPECT_EQ("Header 1.", selectionAsString(frame)); 4342 EXPECT_EQ("Header 1.", selectionAsString(frame));
4343 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2"))); 4343 frame->selectRange(topLeft(elementBounds(frame, "header_1")), bottomRightMin usOne(elementBounds(frame, "header_2")));
4344 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame)); 4344 EXPECT_EQ("Header 1. Header 2.", selectionAsString(frame));
4345 4345
4346 // We can move the start and end together. 4346 // We can move the start and end together.
4347 frame->executeScript(WebScriptSource("selectElement('header_2');")); 4347 frame->executeScript(WebScriptSource("selectElement('header_2');"));
4348 EXPECT_EQ("Header 2.", selectionAsString(frame)); 4348 EXPECT_EQ("Header 2.", selectionAsString(frame));
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4730 4730
4731 FrameTestHelpers::WebViewHelper webViewHelper(this); 4731 FrameTestHelpers::WebViewHelper webViewHelper(this);
4732 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr ); 4732 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr );
4733 webViewHelper.webView()->settings()->setDefaultFontSize(12); 4733 webViewHelper.webView()->settings()->setDefaultFontSize(12);
4734 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); 4734 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1);
4735 webViewHelper.resize(WebSize(viewWidth, viewHeight)); 4735 webViewHelper.resize(WebSize(viewWidth, viewHeight));
4736 webViewHelper.webView()->setFocus(true); 4736 webViewHelper.webView()->setFocus(true);
4737 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html"); 4737 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "select_range_basic.html");
4738 4738
4739 // The frame starts with no selection. 4739 // The frame starts with no selection.
4740 WebFrame* frame = webViewHelper.webView()->mainFrame(); 4740 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame ();
4741 ASSERT_TRUE(frame->hasSelection()); 4741 ASSERT_TRUE(frame->hasSelection());
4742 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4742 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4743 4743
4744 // The selection cleared notification should be triggered upon layout. 4744 // The selection cleared notification should be triggered upon layout.
4745 frame->executeCommand(WebString::fromUTF8("Unselect")); 4745 frame->executeCommand(WebString::fromUTF8("Unselect"));
4746 ASSERT_FALSE(frame->hasSelection()); 4746 ASSERT_FALSE(frame->hasSelection());
4747 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4747 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4748 webViewHelper.webView()->updateAllLifecyclePhases(); 4748 webViewHelper.webView()->updateAllLifecyclePhases();
4749 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4749 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4750 4750
(...skipping 10 matching lines...) Expand all
4761 WebRect startWebRect; 4761 WebRect startWebRect;
4762 WebRect endWebRect; 4762 WebRect endWebRect;
4763 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect); 4763 webViewHelper.webViewImpl()->selectionBounds(startWebRect, endWebRect);
4764 WebPoint movedEnd(bottomRightMinusOne(endWebRect)); 4764 WebPoint movedEnd(bottomRightMinusOne(endWebRect));
4765 endWebRect.x -= 20; 4765 endWebRect.x -= 20;
4766 frame->selectRange(topLeft(startWebRect), movedEnd); 4766 frame->selectRange(topLeft(startWebRect), movedEnd);
4767 webViewHelper.webView()->updateAllLifecyclePhases(); 4767 webViewHelper.webView()->updateAllLifecyclePhases();
4768 ASSERT_TRUE(frame->hasSelection()); 4768 ASSERT_TRUE(frame->hasSelection());
4769 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4769 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4770 4770
4771 frame = webViewHelper.webView()->mainFrame(); 4771 frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
4772 frame->executeCommand(WebString::fromUTF8("Unselect")); 4772 frame->executeCommand(WebString::fromUTF8("Unselect"));
4773 webViewHelper.webView()->updateAllLifecyclePhases(); 4773 webViewHelper.webView()->updateAllLifecyclePhases();
4774 ASSERT_FALSE(frame->hasSelection()); 4774 ASSERT_FALSE(frame->hasSelection());
4775 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); 4775 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
4776 } 4776 }
4777 4777
4778 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient { 4778 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie wClient {
4779 public: 4779 public:
4780 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override 4780 bool didTapMultipleTargets(const WebSize&, const WebRect&, const WebVector<W ebRect>& targetRects) override
4781 { 4781 {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f rame starts with triggers this. 5159 EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new f rame starts with triggers this.
5160 } 5160 }
5161 5161
5162 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele ction) 5162 TEST_P(ParameterizedWebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSele ction)
5163 { 5163 {
5164 FrameTestHelpers::WebViewHelper webViewHelper(this); 5164 FrameTestHelpers::WebViewHelper webViewHelper(this);
5165 webViewHelper.initializeAndLoad("about:blank", true); 5165 webViewHelper.initializeAndLoad("about:blank", true);
5166 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5166 WebFrame* frame = webViewHelper.webView()->mainFrame();
5167 5167
5168 // This test passes if this doesn't crash. 5168 // This test passes if this doesn't crash.
5169 frame->moveCaretSelection(WebPoint(0, 0)); 5169 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0));
5170 } 5170 }
5171 5171
5172 class SpellCheckClient : public WebSpellCheckClient { 5172 class SpellCheckClient : public WebSpellCheckClient {
5173 public: 5173 public:
5174 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_ hash(hash) { } 5174 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_ hash(hash) { }
5175 virtual ~SpellCheckClient() { } 5175 virtual ~SpellCheckClient() { }
5176 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override 5176 void requestCheckingOfText(const WebString&, const WebVector<uint32_t>&, con st WebVector<unsigned>&, WebTextCheckingCompletion* completion) override
5177 { 5177 {
5178 ++m_numberOfTimesChecked; 5178 ++m_numberOfTimesChecked;
5179 Vector<WebTextCheckingResult> results; 5179 Vector<WebTextCheckingResult> results;
(...skipping 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after
8663 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8663 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame();
8664 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8664 v8::HandleScope scope(v8::Isolate::GetCurrent());
8665 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8665 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8666 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8666 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8667 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8667 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8668 ASSERT_TRUE(result->IsString()); 8668 ASSERT_TRUE(result->IsString());
8669 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); 8669 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked()));
8670 } 8670 }
8671 8671
8672 } // namespace blink 8672 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698