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

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

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: cleanup Created 3 years, 10 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 WebViewTest() 227 WebViewTest()
228 : ScopedRootLayerScrollingForTest(GetParam()), 228 : ScopedRootLayerScrollingForTest(GetParam()),
229 m_baseURL("http://www.test.com/") {} 229 m_baseURL("http://www.test.com/") {}
230 230
231 void TearDown() override { 231 void TearDown() override {
232 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 232 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
233 WebCache::clear(); 233 WebCache::clear();
234 } 234 }
235 235
236 protected: 236 protected:
237 void registerMockedHttpURLLoad(const std::string& fileName) { 237 std::string registerMockedHttpURLLoad(const std::string& fileName) {
238 URLTestHelpers::registerMockedURLFromBaseURL( 238 return URLTestHelpers::registerMockedURLLoadFromBase(
239 WebString::fromUTF8(m_baseURL.c_str()), 239 WebString::fromUTF8(m_baseURL.c_str()),
Takashi Toyoshima 2017/01/26 10:57:58 removing c_str
240 WebString::fromUTF8(fileName.c_str())); 240 testing::webTestDataPath(),
241 WebString::fromUTF8(fileName.c_str()))
242 .string()
243 .utf8();
241 } 244 }
242 245
243 void testAutoResize(const WebSize& minAutoResize, 246 void testAutoResize(const WebSize& minAutoResize,
244 const WebSize& maxAutoResize, 247 const WebSize& maxAutoResize,
245 const std::string& pageWidth, 248 const std::string& pageWidth,
246 const std::string& pageHeight, 249 const std::string& pageHeight,
247 int expectedWidth, 250 int expectedWidth,
248 int expectedHeight, 251 int expectedHeight,
249 HorizontalScrollbarState expectedHorizontalState, 252 HorizontalScrollbarState expectedHorizontalState,
250 VerticalScrollbarState expectedVerticalState); 253 VerticalScrollbarState expectedVerticalState);
(...skipping 17 matching lines...) Expand all
268 271
269 static std::string hitTestElementId(WebView* view, int x, int y) { 272 static std::string hitTestElementId(WebView* view, int x, int y) {
270 WebPoint hitPoint(x, y); 273 WebPoint hitPoint(x, y);
271 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint); 274 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint);
272 return hitTestResult.node().to<WebElement>().getAttribute("id").utf8(); 275 return hitTestResult.node().to<WebElement>().getAttribute("id").utf8();
273 } 276 }
274 277
275 INSTANTIATE_TEST_CASE_P(All, WebViewTest, ::testing::Bool()); 278 INSTANTIATE_TEST_CASE_P(All, WebViewTest, ::testing::Bool());
276 279
277 TEST_P(WebViewTest, HitTestContentEditableImageMaps) { 280 TEST_P(WebViewTest, HitTestContentEditableImageMaps) {
278 std::string url = m_baseURL + "content-editable-image-maps.html"; 281 std::string url =
279 URLTestHelpers::registerMockedURLLoad(toKURL(url), 282 registerMockedHttpURLLoad("content-editable-image-maps.html");
280 "content-editable-image-maps.html");
281 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); 283 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0);
282 webView->resize(WebSize(500, 500)); 284 webView->resize(WebSize(500, 500));
283 285
284 EXPECT_EQ("areaANotEditable", hitTestElementId(webView, 25, 25)); 286 EXPECT_EQ("areaANotEditable", hitTestElementId(webView, 25, 25));
285 EXPECT_FALSE(hitTestIsContentEditable(webView, 25, 25)); 287 EXPECT_FALSE(hitTestIsContentEditable(webView, 25, 25));
286 EXPECT_EQ("imageANotEditable", hitTestElementId(webView, 75, 25)); 288 EXPECT_EQ("imageANotEditable", hitTestElementId(webView, 75, 25));
287 EXPECT_FALSE(hitTestIsContentEditable(webView, 75, 25)); 289 EXPECT_FALSE(hitTestIsContentEditable(webView, 75, 25));
288 290
289 EXPECT_EQ("areaBNotEditable", hitTestElementId(webView, 25, 125)); 291 EXPECT_EQ("areaBNotEditable", hitTestElementId(webView, 25, 125));
290 EXPECT_FALSE(hitTestIsContentEditable(webView, 25, 125)); 292 EXPECT_FALSE(hitTestIsContentEditable(webView, 25, 125));
(...skipping 17 matching lines...) Expand all
308 return hitTestResult.absoluteImageURL().string().utf8(); 310 return hitTestResult.absoluteImageURL().string().utf8();
309 } 311 }
310 312
311 static WebElement hitTestUrlElement(WebView* view, int x, int y) { 313 static WebElement hitTestUrlElement(WebView* view, int x, int y) {
312 WebPoint hitPoint(x, y); 314 WebPoint hitPoint(x, y);
313 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint); 315 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint);
314 return hitTestResult.urlElement(); 316 return hitTestResult.urlElement();
315 } 317 }
316 318
317 TEST_P(WebViewTest, ImageMapUrls) { 319 TEST_P(WebViewTest, ImageMapUrls) {
318 std::string url = m_baseURL + "image-map.html"; 320 std::string url = registerMockedHttpURLLoad("image-map.html");
319 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html");
320 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); 321 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0);
321 webView->resize(WebSize(400, 400)); 322 webView->resize(WebSize(400, 400));
322 323
323 std::string imageUrl = 324 std::string imageUrl =
324 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; 325 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
325 326
326 EXPECT_EQ("area", hitTestElementId(webView, 25, 25)); 327 EXPECT_EQ("area", hitTestElementId(webView, 25, 25));
327 EXPECT_EQ("area", 328 EXPECT_EQ("area",
328 hitTestUrlElement(webView, 25, 25).getAttribute("id").utf8()); 329 hitTestUrlElement(webView, 25, 25).getAttribute("id").utf8());
329 EXPECT_EQ(imageUrl, hitTestAbsoluteUrl(webView, 25, 25)); 330 EXPECT_EQ(imageUrl, hitTestAbsoluteUrl(webView, 25, 25));
330 331
331 EXPECT_EQ("image", hitTestElementId(webView, 75, 25)); 332 EXPECT_EQ("image", hitTestElementId(webView, 75, 25));
332 EXPECT_TRUE(hitTestUrlElement(webView, 75, 25).isNull()); 333 EXPECT_TRUE(hitTestUrlElement(webView, 75, 25).isNull());
333 EXPECT_EQ(imageUrl, hitTestAbsoluteUrl(webView, 75, 25)); 334 EXPECT_EQ(imageUrl, hitTestAbsoluteUrl(webView, 75, 25));
334 } 335 }
335 336
336 TEST_P(WebViewTest, BrokenImage) { 337 TEST_P(WebViewTest, BrokenImage) {
337 URLTestHelpers::registerMockedErrorURLLoad( 338 URLTestHelpers::registerMockedErrorURLLoad(
338 KURL(toKURL(m_baseURL), "non_existent.png")); 339 KURL(toKURL(m_baseURL), "non_existent.png"));
339 std::string url = m_baseURL + "image-broken.html"; 340 std::string url = registerMockedHttpURLLoad("image-broken.html");
340 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-broken.html");
341 341
342 WebView* webView = m_webViewHelper.initialize(); 342 WebView* webView = m_webViewHelper.initialize();
343 webView->settings()->setLoadsImagesAutomatically(true); 343 webView->settings()->setLoadsImagesAutomatically(true);
344 loadFrame(webView->mainFrame(), url); 344 loadFrame(webView->mainFrame(), url);
345 webView->resize(WebSize(400, 400)); 345 webView->resize(WebSize(400, 400));
346 346
347 std::string imageUrl = "http://www.test.com/non_existent.png"; 347 std::string imageUrl = "http://www.test.com/non_existent.png";
348 348
349 EXPECT_EQ("image", hitTestElementId(webView, 25, 25)); 349 EXPECT_EQ("image", hitTestElementId(webView, 25, 25));
350 EXPECT_TRUE(hitTestUrlElement(webView, 25, 25).isNull()); 350 EXPECT_TRUE(hitTestUrlElement(webView, 25, 25).isNull());
351 EXPECT_EQ(imageUrl, hitTestAbsoluteUrl(webView, 25, 25)); 351 EXPECT_EQ(imageUrl, hitTestAbsoluteUrl(webView, 25, 25));
352 } 352 }
353 353
354 TEST_P(WebViewTest, BrokenInputImage) { 354 TEST_P(WebViewTest, BrokenInputImage) {
355 URLTestHelpers::registerMockedErrorURLLoad( 355 URLTestHelpers::registerMockedErrorURLLoad(
356 KURL(toKURL(m_baseURL), "non_existent.png")); 356 KURL(toKURL(m_baseURL), "non_existent.png"));
357 std::string url = m_baseURL + "input-image-broken.html"; 357 std::string url = registerMockedHttpURLLoad("input-image-broken.html");
358 URLTestHelpers::registerMockedURLLoad(toKURL(url), "input-image-broken.html");
359 358
360 WebView* webView = m_webViewHelper.initialize(); 359 WebView* webView = m_webViewHelper.initialize();
361 webView->settings()->setLoadsImagesAutomatically(true); 360 webView->settings()->setLoadsImagesAutomatically(true);
362 loadFrame(webView->mainFrame(), url); 361 loadFrame(webView->mainFrame(), url);
363 webView->resize(WebSize(400, 400)); 362 webView->resize(WebSize(400, 400));
364 363
365 std::string imageUrl = "http://www.test.com/non_existent.png"; 364 std::string imageUrl = "http://www.test.com/non_existent.png";
366 365
367 EXPECT_EQ("image", hitTestElementId(webView, 25, 25)); 366 EXPECT_EQ("image", hitTestElementId(webView, 25, 25));
368 EXPECT_TRUE(hitTestUrlElement(webView, 25, 25).isNull()); 367 EXPECT_TRUE(hitTestUrlElement(webView, 25, 25).isNull());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 478
480 pictureBuilder.endRecording()->playback(&canvas); 479 pictureBuilder.endRecording()->playback(&canvas);
481 480
482 // The result should be a blend of red and green. 481 // The result should be a blend of red and green.
483 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); 482 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2);
484 EXPECT_TRUE(redChannel(color)); 483 EXPECT_TRUE(redChannel(color));
485 EXPECT_TRUE(greenChannel(color)); 484 EXPECT_TRUE(greenChannel(color));
486 } 485 }
487 486
488 TEST_P(WebViewTest, FocusIsInactive) { 487 TEST_P(WebViewTest, FocusIsInactive) {
489 URLTestHelpers::registerMockedURLFromBaseURL( 488 registerMockedHttpURLLoad("visible_iframe.html");
490 WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html");
491 WebViewImpl* webView = 489 WebViewImpl* webView =
492 m_webViewHelper.initializeAndLoad(m_baseURL + "visible_iframe.html"); 490 m_webViewHelper.initializeAndLoad(m_baseURL + "visible_iframe.html");
493 491
494 webView->setFocus(true); 492 webView->setFocus(true);
495 webView->setIsActive(true); 493 webView->setIsActive(true);
496 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 494 WebLocalFrameImpl* frame = webView->mainFrameImpl();
497 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); 495 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument());
498 496
499 Document* document = frame->frame()->document(); 497 Document* document = frame->frame()->document();
500 EXPECT_TRUE(document->hasFocus()); 498 EXPECT_TRUE(document->hasFocus());
501 webView->setFocus(false); 499 webView->setFocus(false);
502 webView->setIsActive(false); 500 webView->setIsActive(false);
503 EXPECT_FALSE(document->hasFocus()); 501 EXPECT_FALSE(document->hasFocus());
504 webView->setFocus(true); 502 webView->setFocus(true);
505 webView->setIsActive(true); 503 webView->setIsActive(true);
506 EXPECT_TRUE(document->hasFocus()); 504 EXPECT_TRUE(document->hasFocus());
507 webView->setFocus(true); 505 webView->setFocus(true);
508 webView->setIsActive(false); 506 webView->setIsActive(false);
509 EXPECT_FALSE(document->hasFocus()); 507 EXPECT_FALSE(document->hasFocus());
510 webView->setFocus(false); 508 webView->setFocus(false);
511 webView->setIsActive(true); 509 webView->setIsActive(true);
512 EXPECT_FALSE(document->hasFocus()); 510 EXPECT_FALSE(document->hasFocus());
513 } 511 }
514 512
515 TEST_P(WebViewTest, ActiveState) { 513 TEST_P(WebViewTest, ActiveState) {
516 URLTestHelpers::registerMockedURLFromBaseURL( 514 registerMockedHttpURLLoad("visible_iframe.html");
517 WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html");
518 WebView* webView = 515 WebView* webView =
519 m_webViewHelper.initializeAndLoad(m_baseURL + "visible_iframe.html"); 516 m_webViewHelper.initializeAndLoad(m_baseURL + "visible_iframe.html");
520 517
521 ASSERT_TRUE(webView); 518 ASSERT_TRUE(webView);
522 519
523 webView->setIsActive(true); 520 webView->setIsActive(true);
524 EXPECT_TRUE(webView->isActive()); 521 EXPECT_TRUE(webView->isActive());
525 522
526 webView->setIsActive(false); 523 webView->setIsActive(false);
527 EXPECT_FALSE(webView->isActive()); 524 EXPECT_FALSE(webView->isActive());
528 525
529 webView->setIsActive(true); 526 webView->setIsActive(true);
530 EXPECT_TRUE(webView->isActive()); 527 EXPECT_TRUE(webView->isActive());
531 } 528 }
532 529
533 TEST_P(WebViewTest, HitTestResultAtWithPageScale) { 530 TEST_P(WebViewTest, HitTestResultAtWithPageScale) {
534 std::string url = m_baseURL + "specify_size.html?" + "50px" + ":" + "50px"; 531 std::string url = m_baseURL + "specify_size.html?" + "50px" + ":" + "50px";
535 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 532 URLTestHelpers::registerMockedURLLoad(
533 toKURL(url), testing::webTestDataPath("specify_size.html"));
536 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); 534 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0);
537 webView->resize(WebSize(100, 100)); 535 webView->resize(WebSize(100, 100));
538 WebPoint hitPoint(75, 75); 536 WebPoint hitPoint(75, 75);
539 537
540 // Image is at top left quandrant, so should not hit it. 538 // Image is at top left quandrant, so should not hit it.
541 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); 539 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint);
542 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img")); 540 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img"));
543 negativeResult.reset(); 541 negativeResult.reset();
544 542
545 // Scale page up 2x so image should occupy the whole viewport. 543 // Scale page up 2x so image should occupy the whole viewport.
546 webView->setPageScaleFactor(2.0f); 544 webView->setPageScaleFactor(2.0f);
547 WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); 545 WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint);
548 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img")); 546 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img"));
549 positiveResult.reset(); 547 positiveResult.reset();
550 } 548 }
551 549
552 TEST_P(WebViewTest, HitTestResultAtWithPageScaleAndPan) { 550 TEST_P(WebViewTest, HitTestResultAtWithPageScaleAndPan) {
553 std::string url = m_baseURL + "specify_size.html?" + "50px" + ":" + "50px"; 551 std::string url = m_baseURL + "specify_size.html?" + "50px" + ":" + "50px";
554 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 552 URLTestHelpers::registerMockedURLLoad(
553 toKURL(url), testing::webTestDataPath("specify_size.html"));
555 WebView* webView = m_webViewHelper.initialize(true); 554 WebView* webView = m_webViewHelper.initialize(true);
556 loadFrame(webView->mainFrame(), url); 555 loadFrame(webView->mainFrame(), url);
557 webView->resize(WebSize(100, 100)); 556 webView->resize(WebSize(100, 100));
558 WebPoint hitPoint(75, 75); 557 WebPoint hitPoint(75, 75);
559 558
560 // Image is at top left quandrant, so should not hit it. 559 // Image is at top left quandrant, so should not hit it.
561 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); 560 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint);
562 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img")); 561 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img"));
563 negativeResult.reset(); 562 negativeResult.reset();
564 563
565 // Scale page up 2x so image should occupy the whole viewport. 564 // Scale page up 2x so image should occupy the whole viewport.
566 webView->setPageScaleFactor(2.0f); 565 webView->setPageScaleFactor(2.0f);
567 WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); 566 WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint);
568 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img")); 567 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img"));
569 positiveResult.reset(); 568 positiveResult.reset();
570 569
571 // Pan around the zoomed in page so the image is not visible in viewport. 570 // Pan around the zoomed in page so the image is not visible in viewport.
572 webView->setVisualViewportOffset(WebFloatPoint(100, 100)); 571 webView->setVisualViewportOffset(WebFloatPoint(100, 100));
573 WebHitTestResult negativeResult2 = webView->hitTestResultAt(hitPoint); 572 WebHitTestResult negativeResult2 = webView->hitTestResultAt(hitPoint);
574 EXPECT_FALSE(negativeResult2.node().to<WebElement>().hasHTMLTagName("img")); 573 EXPECT_FALSE(negativeResult2.node().to<WebElement>().hasHTMLTagName("img"));
575 negativeResult2.reset(); 574 negativeResult2.reset();
576 } 575 }
577 576
578 TEST_P(WebViewTest, HitTestResultForTapWithTapArea) { 577 TEST_P(WebViewTest, HitTestResultForTapWithTapArea) {
579 std::string url = m_baseURL + "hit_test.html"; 578 std::string url = registerMockedHttpURLLoad("hit_test.html");
580 URLTestHelpers::registerMockedURLLoad(toKURL(url), "hit_test.html");
581 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); 579 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0);
582 webView->resize(WebSize(100, 100)); 580 webView->resize(WebSize(100, 100));
583 WebPoint hitPoint(55, 55); 581 WebPoint hitPoint(55, 55);
584 582
585 // Image is at top left quandrant, so should not hit it. 583 // Image is at top left quandrant, so should not hit it.
586 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); 584 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint);
587 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img")); 585 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img"));
588 negativeResult.reset(); 586 negativeResult.reset();
589 587
590 // The tap area is 20 by 20 square, centered at 55, 55. 588 // The tap area is 20 by 20 square, centered at 55, 55.
591 WebSize tapArea(20, 20); 589 WebSize tapArea(20, 20);
592 WebHitTestResult positiveResult = 590 WebHitTestResult positiveResult =
593 webView->hitTestResultForTap(hitPoint, tapArea); 591 webView->hitTestResultForTap(hitPoint, tapArea);
594 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img")); 592 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img"));
595 positiveResult.reset(); 593 positiveResult.reset();
596 594
597 // Move the hit point the image is just outside the tapped area now. 595 // Move the hit point the image is just outside the tapped area now.
598 hitPoint = WebPoint(61, 61); 596 hitPoint = WebPoint(61, 61);
599 WebHitTestResult negativeResult2 = 597 WebHitTestResult negativeResult2 =
600 webView->hitTestResultForTap(hitPoint, tapArea); 598 webView->hitTestResultForTap(hitPoint, tapArea);
601 EXPECT_FALSE(negativeResult2.node().to<WebElement>().hasHTMLTagName("img")); 599 EXPECT_FALSE(negativeResult2.node().to<WebElement>().hasHTMLTagName("img"));
602 negativeResult2.reset(); 600 negativeResult2.reset();
603 } 601 }
604 602
605 TEST_P(WebViewTest, HitTestResultForTapWithTapAreaPageScaleAndPan) { 603 TEST_P(WebViewTest, HitTestResultForTapWithTapAreaPageScaleAndPan) {
606 std::string url = m_baseURL + "hit_test.html"; 604 std::string url = registerMockedHttpURLLoad("hit_test.html");
607 URLTestHelpers::registerMockedURLLoad(toKURL(url), "hit_test.html");
608 WebView* webView = m_webViewHelper.initialize(true); 605 WebView* webView = m_webViewHelper.initialize(true);
609 loadFrame(webView->mainFrame(), url); 606 loadFrame(webView->mainFrame(), url);
610 webView->resize(WebSize(100, 100)); 607 webView->resize(WebSize(100, 100));
611 WebPoint hitPoint(55, 55); 608 WebPoint hitPoint(55, 55);
612 609
613 // Image is at top left quandrant, so should not hit it. 610 // Image is at top left quandrant, so should not hit it.
614 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); 611 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint);
615 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img")); 612 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img"));
616 negativeResult.reset(); 613 negativeResult.reset();
617 614
(...skipping 18 matching lines...) Expand all
636 const WebSize& maxAutoResize, 633 const WebSize& maxAutoResize,
637 const std::string& pageWidth, 634 const std::string& pageWidth,
638 const std::string& pageHeight, 635 const std::string& pageHeight,
639 int expectedWidth, 636 int expectedWidth,
640 int expectedHeight, 637 int expectedHeight,
641 HorizontalScrollbarState expectedHorizontalState, 638 HorizontalScrollbarState expectedHorizontalState,
642 VerticalScrollbarState expectedVerticalState) { 639 VerticalScrollbarState expectedVerticalState) {
643 AutoResizeWebViewClient client; 640 AutoResizeWebViewClient client;
644 std::string url = 641 std::string url =
645 m_baseURL + "specify_size.html?" + pageWidth + ":" + pageHeight; 642 m_baseURL + "specify_size.html?" + pageWidth + ":" + pageHeight;
646 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 643 URLTestHelpers::registerMockedURLLoad(
644 toKURL(url), testing::webTestDataPath("specify_size.html"));
647 WebViewImpl* webView = 645 WebViewImpl* webView =
648 m_webViewHelper.initializeAndLoad(url, true, 0, &client); 646 m_webViewHelper.initializeAndLoad(url, true, 0, &client);
649 client.testData().setWebView(webView); 647 client.testData().setWebView(webView);
650 648
651 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 649 WebLocalFrameImpl* frame = webView->mainFrameImpl();
652 FrameView* frameView = frame->frame()->view(); 650 FrameView* frameView = frame->frame()->view();
653 frameView->layout(); 651 frameView->layout();
654 EXPECT_FALSE(frameView->layoutPending()); 652 EXPECT_FALSE(frameView->layoutPending());
655 EXPECT_FALSE(frameView->needsLayout()); 653 EXPECT_FALSE(frameView->needsLayout());
656 654
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 std::string pageHeight = "300px"; 743 std::string pageHeight = "300px";
746 int expectedWidth = 200; 744 int expectedWidth = 200;
747 int expectedHeight = 300; 745 int expectedHeight = 300;
748 testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight, 746 testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
749 expectedWidth, expectedHeight, NoHorizontalScrollbar, 747 expectedWidth, expectedHeight, NoHorizontalScrollbar,
750 NoVerticalScrollbar); 748 NoVerticalScrollbar);
751 } 749 }
752 750
753 void WebViewTest::testTextInputType(WebTextInputType expectedType, 751 void WebViewTest::testTextInputType(WebTextInputType expectedType,
754 const std::string& htmlFile) { 752 const std::string& htmlFile) {
755 URLTestHelpers::registerMockedURLFromBaseURL( 753 registerMockedHttpURLLoad(htmlFile);
756 WebString::fromUTF8(m_baseURL.c_str()),
757 WebString::fromUTF8(htmlFile.c_str()));
758 WebViewImpl* webView = 754 WebViewImpl* webView =
759 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); 755 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile);
760 WebInputMethodControllerImpl* controller = 756 WebInputMethodControllerImpl* controller =
761 webView->mainFrameImpl()->inputMethodController(); 757 webView->mainFrameImpl()->inputMethodController();
762 EXPECT_EQ(WebTextInputTypeNone, controller->textInputType()); 758 EXPECT_EQ(WebTextInputTypeNone, controller->textInputType());
763 EXPECT_EQ(WebTextInputTypeNone, controller->textInputInfo().type); 759 EXPECT_EQ(WebTextInputTypeNone, controller->textInputInfo().type);
764 webView->setInitialFocus(false); 760 webView->setInitialFocus(false);
765 EXPECT_EQ(expectedType, controller->textInputType()); 761 EXPECT_EQ(expectedType, controller->textInputType());
766 EXPECT_EQ(expectedType, controller->textInputInfo().type); 762 EXPECT_EQ(expectedType, controller->textInputInfo().type);
767 webView->clearFocusedElement(); 763 webView->clearFocusedElement();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 805
810 // This should not DCHECK. 806 // This should not DCHECK.
811 EXPECT_EQ(WebTextInputTypeText, webViewImpl->mainFrameImpl() 807 EXPECT_EQ(WebTextInputTypeText, webViewImpl->mainFrameImpl()
812 ->inputMethodController() 808 ->inputMethodController()
813 ->textInputInfo() 809 ->textInputInfo()
814 .type); 810 .type);
815 } 811 }
816 812
817 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode, 813 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode,
818 const std::string& htmlFile) { 814 const std::string& htmlFile) {
819 URLTestHelpers::registerMockedURLFromBaseURL( 815 registerMockedHttpURLLoad(htmlFile);
820 WebString::fromUTF8(m_baseURL.c_str()),
821 WebString::fromUTF8(htmlFile.c_str()));
822 WebViewImpl* webViewImpl = 816 WebViewImpl* webViewImpl =
823 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); 817 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile);
824 webViewImpl->setInitialFocus(false); 818 webViewImpl->setInitialFocus(false);
825 EXPECT_EQ(expectedInputMode, webViewImpl->mainFrameImpl() 819 EXPECT_EQ(expectedInputMode, webViewImpl->mainFrameImpl()
826 ->inputMethodController() 820 ->inputMethodController()
827 ->textInputInfo() 821 ->textInputInfo()
828 .inputMode); 822 .inputMode);
829 } 823 }
830 824
831 TEST_P(WebViewTest, InputMode) { 825 TEST_P(WebViewTest, InputMode) {
(...skipping 27 matching lines...) Expand all
859 "input_mode_type_numeric.html"); 853 "input_mode_type_numeric.html");
860 testInputMode(WebTextInputMode::kWebTextInputModeTel, 854 testInputMode(WebTextInputMode::kWebTextInputModeTel,
861 "input_mode_type_tel.html"); 855 "input_mode_type_tel.html");
862 testInputMode(WebTextInputMode::kWebTextInputModeEmail, 856 testInputMode(WebTextInputMode::kWebTextInputModeEmail,
863 "input_mode_type_email.html"); 857 "input_mode_type_email.html");
864 testInputMode(WebTextInputMode::kWebTextInputModeUrl, 858 testInputMode(WebTextInputMode::kWebTextInputModeUrl,
865 "input_mode_type_url.html"); 859 "input_mode_type_url.html");
866 } 860 }
867 861
868 TEST_P(WebViewTest, TextInputInfoWithReplacedElements) { 862 TEST_P(WebViewTest, TextInputInfoWithReplacedElements) {
869 std::string url = m_baseURL + "div_with_image.html"; 863 std::string url = registerMockedHttpURLLoad("div_with_image.html");
870 URLTestHelpers::registerMockedURLLoad(toKURL(url), "div_with_image.html"); 864 URLTestHelpers::registerMockedURLLoad(
871 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com/foo.png"), 865 toKURL("http://www.test.com/foo.png"),
872 "white-1x1.png"); 866 testing::webTestDataPath("white-1x1.png"));
873 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url); 867 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url);
874 webViewImpl->setInitialFocus(false); 868 webViewImpl->setInitialFocus(false);
875 WebTextInputInfo info = 869 WebTextInputInfo info =
876 webViewImpl->mainFrameImpl()->inputMethodController()->textInputInfo(); 870 webViewImpl->mainFrameImpl()->inputMethodController()->textInputInfo();
877 871
878 EXPECT_EQ("foo\xef\xbf\xbc", info.value.utf8()); 872 EXPECT_EQ("foo\xef\xbf\xbc", info.value.utf8());
879 } 873 }
880 874
881 TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { 875 TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) {
882 URLTestHelpers::registerMockedURLFromBaseURL( 876 registerMockedHttpURLLoad("input_field_populated.html");
883 WebString::fromUTF8(m_baseURL.c_str()),
884 WebString::fromUTF8("input_field_populated.html"));
885 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 877 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
886 m_baseURL + "input_field_populated.html"); 878 m_baseURL + "input_field_populated.html");
887 webView->setInitialFocus(false); 879 webView->setInitialFocus(false);
888 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 880 WebLocalFrameImpl* frame = webView->mainFrameImpl();
889 WebInputMethodControllerImpl* activeInputMethodController = 881 WebInputMethodControllerImpl* activeInputMethodController =
890 frame->inputMethodController(); 882 frame->inputMethodController();
891 frame->setEditableSelectionOffsets(5, 13); 883 frame->setEditableSelectionOffsets(5, 13);
892 EXPECT_EQ("56789abc", frame->selectionAsText()); 884 EXPECT_EQ("56789abc", frame->selectionAsText());
893 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 885 WebTextInputInfo info = activeInputMethodController->textInputInfo();
894 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); 886 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value);
895 EXPECT_EQ(5, info.selectionStart); 887 EXPECT_EQ(5, info.selectionStart);
896 EXPECT_EQ(13, info.selectionEnd); 888 EXPECT_EQ(13, info.selectionEnd);
897 EXPECT_EQ(-1, info.compositionStart); 889 EXPECT_EQ(-1, info.compositionStart);
898 EXPECT_EQ(-1, info.compositionEnd); 890 EXPECT_EQ(-1, info.compositionEnd);
899 891
900 URLTestHelpers::registerMockedURLFromBaseURL( 892 registerMockedHttpURLLoad("content_editable_populated.html");
901 WebString::fromUTF8(m_baseURL.c_str()),
902 WebString::fromUTF8("content_editable_populated.html"));
903 webView = m_webViewHelper.initializeAndLoad( 893 webView = m_webViewHelper.initializeAndLoad(
904 m_baseURL + "content_editable_populated.html"); 894 m_baseURL + "content_editable_populated.html");
905 webView->setInitialFocus(false); 895 webView->setInitialFocus(false);
906 frame = webView->mainFrameImpl(); 896 frame = webView->mainFrameImpl();
907 activeInputMethodController = frame->inputMethodController(); 897 activeInputMethodController = frame->inputMethodController();
908 frame->setEditableSelectionOffsets(8, 19); 898 frame->setEditableSelectionOffsets(8, 19);
909 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); 899 EXPECT_EQ("89abcdefghi", frame->selectionAsText());
910 info = activeInputMethodController->textInputInfo(); 900 info = activeInputMethodController->textInputInfo();
911 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); 901 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value);
912 EXPECT_EQ(8, info.selectionStart); 902 EXPECT_EQ(8, info.selectionStart);
913 EXPECT_EQ(19, info.selectionEnd); 903 EXPECT_EQ(19, info.selectionEnd);
914 EXPECT_EQ(-1, info.compositionStart); 904 EXPECT_EQ(-1, info.compositionStart);
915 EXPECT_EQ(-1, info.compositionEnd); 905 EXPECT_EQ(-1, info.compositionEnd);
916 } 906 }
917 907
918 // Regression test for crbug.com/663645 908 // Regression test for crbug.com/663645
919 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) { 909 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) {
920 URLTestHelpers::registerMockedURLFromBaseURL( 910 registerMockedHttpURLLoad("input_field_default.html");
921 WebString::fromUTF8(m_baseURL.c_str()),
922 WebString::fromUTF8("input_field_default.html"));
923 WebViewImpl* webView = 911 WebViewImpl* webView =
924 m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_default.html"); 912 m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_default.html");
925 webView->setInitialFocus(false); 913 webView->setInitialFocus(false);
926 914
927 WebInputMethodController* activeInputMethodController = 915 WebInputMethodController* activeInputMethodController =
928 webView->mainFrameImpl() 916 webView->mainFrameImpl()
929 ->frameWidget() 917 ->frameWidget()
930 ->getActiveWebInputMethodController(); 918 ->getActiveWebInputMethodController();
931 919
932 // The test requires non-empty composition. 920 // The test requires non-empty composition.
933 std::string compositionText("hello"); 921 std::string compositionText("hello");
934 WebVector<WebCompositionUnderline> emptyUnderlines; 922 WebVector<WebCompositionUnderline> emptyUnderlines;
935 activeInputMethodController->setComposition( 923 activeInputMethodController->setComposition(
936 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5); 924 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5);
937 925
938 // Do arbitrary change to make layout dirty. 926 // Do arbitrary change to make layout dirty.
939 Document& document = *webView->mainFrameImpl()->frame()->document(); 927 Document& document = *webView->mainFrameImpl()->frame()->document();
940 Element* br = document.createElement("br"); 928 Element* br = document.createElement("br");
941 document.body()->appendChild(br); 929 document.body()->appendChild(br);
942 930
943 // Should not hit assertion when calling 931 // Should not hit assertion when calling
944 // WebInputMethodController::finishComposingText with non-empty composition 932 // WebInputMethodController::finishComposingText with non-empty composition
945 // and dirty layout. 933 // and dirty layout.
946 activeInputMethodController->finishComposingText( 934 activeInputMethodController->finishComposingText(
947 WebInputMethodController::KeepSelection); 935 WebInputMethodController::KeepSelection);
948 } 936 }
949 937
950 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { 938 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) {
951 URLTestHelpers::registerMockedURLFromBaseURL( 939 registerMockedHttpURLLoad("input_field_populated.html");
952 WebString::fromUTF8(m_baseURL.c_str()),
953 WebString::fromUTF8("input_field_populated.html"));
954 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 940 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
955 m_baseURL + "input_field_populated.html"); 941 m_baseURL + "input_field_populated.html");
956 webView->setInitialFocus(false); 942 webView->setInitialFocus(false);
957 943
958 // Set up a composition that needs to be committed. 944 // Set up a composition that needs to be committed.
959 std::string compositionText("hello"); 945 std::string compositionText("hello");
960 946
961 WebInputMethodController* activeInputMethodController = 947 WebInputMethodController* activeInputMethodController =
962 webView->mainFrameImpl() 948 webView->mainFrameImpl()
963 ->frameWidget() 949 ->frameWidget()
(...skipping 29 matching lines...) Expand all
993 activeInputMethodController->finishComposingText( 979 activeInputMethodController->finishComposingText(
994 WebInputMethodController::DoNotKeepSelection); 980 WebInputMethodController::DoNotKeepSelection);
995 info = activeInputMethodController->textInputInfo(); 981 info = activeInputMethodController->textInputInfo();
996 EXPECT_EQ(8, info.selectionStart); 982 EXPECT_EQ(8, info.selectionStart);
997 EXPECT_EQ(8, info.selectionEnd); 983 EXPECT_EQ(8, info.selectionEnd);
998 EXPECT_EQ(-1, info.compositionStart); 984 EXPECT_EQ(-1, info.compositionStart);
999 EXPECT_EQ(-1, info.compositionEnd); 985 EXPECT_EQ(-1, info.compositionEnd);
1000 } 986 }
1001 987
1002 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { 988 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) {
1003 URLTestHelpers::registerMockedURLFromBaseURL( 989 registerMockedHttpURLLoad("input_field_populated.html");
1004 WebString::fromUTF8(m_baseURL.c_str()),
1005 WebString::fromUTF8("input_field_populated.html"));
1006 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 990 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1007 m_baseURL + "input_field_populated.html"); 991 m_baseURL + "input_field_populated.html");
1008 webView->setInitialFocus(false); 992 webView->setInitialFocus(false);
1009 WebInputMethodController* activeInputMethodController = 993 WebInputMethodController* activeInputMethodController =
1010 webView->mainFrameImpl() 994 webView->mainFrameImpl()
1011 ->frameWidget() 995 ->frameWidget()
1012 ->getActiveWebInputMethodController(); 996 ->getActiveWebInputMethodController();
1013 997
1014 WebVector<WebCompositionUnderline> emptyUnderlines; 998 WebVector<WebCompositionUnderline> emptyUnderlines;
1015 999
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100); 1086 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100);
1103 info = activeInputMethodController->textInputInfo(); 1087 info = activeInputMethodController->textInputInfo();
1104 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); 1088 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
1105 EXPECT_EQ(13, info.selectionStart); 1089 EXPECT_EQ(13, info.selectionStart);
1106 EXPECT_EQ(13, info.selectionEnd); 1090 EXPECT_EQ(13, info.selectionEnd);
1107 EXPECT_EQ(5, info.compositionStart); 1091 EXPECT_EQ(5, info.compositionStart);
1108 EXPECT_EQ(8, info.compositionEnd); 1092 EXPECT_EQ(8, info.compositionEnd);
1109 } 1093 }
1110 1094
1111 TEST_P(WebViewTest, SetCompositionWithEmptyText) { 1095 TEST_P(WebViewTest, SetCompositionWithEmptyText) {
1112 URLTestHelpers::registerMockedURLFromBaseURL( 1096 registerMockedHttpURLLoad("input_field_populated.html");
1113 WebString::fromUTF8(m_baseURL.c_str()),
1114 WebString::fromUTF8("input_field_populated.html"));
1115 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1097 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1116 m_baseURL + "input_field_populated.html"); 1098 m_baseURL + "input_field_populated.html");
1117 webView->setInitialFocus(false); 1099 webView->setInitialFocus(false);
1118 WebInputMethodController* activeInputMethodController = 1100 WebInputMethodController* activeInputMethodController =
1119 webView->mainFrameImpl() 1101 webView->mainFrameImpl()
1120 ->frameWidget() 1102 ->frameWidget()
1121 ->getActiveWebInputMethodController(); 1103 ->getActiveWebInputMethodController();
1122 1104
1123 WebVector<WebCompositionUnderline> emptyUnderlines; 1105 WebVector<WebCompositionUnderline> emptyUnderlines;
1124 1106
(...skipping 19 matching lines...) Expand all
1144 emptyUnderlines, -2, -2); 1126 emptyUnderlines, -2, -2);
1145 info = activeInputMethodController->textInputInfo(); 1127 info = activeInputMethodController->textInputInfo();
1146 EXPECT_EQ("hello", std::string(info.value.utf8().data())); 1128 EXPECT_EQ("hello", std::string(info.value.utf8().data()));
1147 EXPECT_EQ(3, info.selectionStart); 1129 EXPECT_EQ(3, info.selectionStart);
1148 EXPECT_EQ(3, info.selectionEnd); 1130 EXPECT_EQ(3, info.selectionEnd);
1149 EXPECT_EQ(-1, info.compositionStart); 1131 EXPECT_EQ(-1, info.compositionStart);
1150 EXPECT_EQ(-1, info.compositionEnd); 1132 EXPECT_EQ(-1, info.compositionEnd);
1151 } 1133 }
1152 1134
1153 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { 1135 TEST_P(WebViewTest, CommitTextForNewCaretPositions) {
1154 URLTestHelpers::registerMockedURLFromBaseURL( 1136 registerMockedHttpURLLoad("input_field_populated.html");
1155 WebString::fromUTF8(m_baseURL.c_str()),
1156 WebString::fromUTF8("input_field_populated.html"));
1157 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1137 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1158 m_baseURL + "input_field_populated.html"); 1138 m_baseURL + "input_field_populated.html");
1159 webView->setInitialFocus(false); 1139 webView->setInitialFocus(false);
1160 WebInputMethodController* activeInputMethodController = 1140 WebInputMethodController* activeInputMethodController =
1161 webView->mainFrameImpl() 1141 webView->mainFrameImpl()
1162 ->frameWidget() 1142 ->frameWidget()
1163 ->getActiveWebInputMethodController(); 1143 ->getActiveWebInputMethodController();
1164 1144
1165 WebVector<WebCompositionUnderline> emptyUnderlines; 1145 WebVector<WebCompositionUnderline> emptyUnderlines;
1166 1146
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 activeInputMethodController->commitText("jk", emptyUnderlines, 100); 1193 activeInputMethodController->commitText("jk", emptyUnderlines, 100);
1214 info = activeInputMethodController->textInputInfo(); 1194 info = activeInputMethodController->textInputInfo();
1215 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); 1195 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data()));
1216 EXPECT_EQ(11, info.selectionStart); 1196 EXPECT_EQ(11, info.selectionStart);
1217 EXPECT_EQ(11, info.selectionEnd); 1197 EXPECT_EQ(11, info.selectionEnd);
1218 EXPECT_EQ(-1, info.compositionStart); 1198 EXPECT_EQ(-1, info.compositionStart);
1219 EXPECT_EQ(-1, info.compositionEnd); 1199 EXPECT_EQ(-1, info.compositionEnd);
1220 } 1200 }
1221 1201
1222 TEST_P(WebViewTest, CommitTextWhileComposing) { 1202 TEST_P(WebViewTest, CommitTextWhileComposing) {
1223 URLTestHelpers::registerMockedURLFromBaseURL( 1203 registerMockedHttpURLLoad("input_field_populated.html");
1224 WebString::fromUTF8(m_baseURL.c_str()),
1225 WebString::fromUTF8("input_field_populated.html"));
1226 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1204 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1227 m_baseURL + "input_field_populated.html"); 1205 m_baseURL + "input_field_populated.html");
1228 webView->setInitialFocus(false); 1206 webView->setInitialFocus(false);
1229 WebInputMethodController* activeInputMethodController = 1207 WebInputMethodController* activeInputMethodController =
1230 webView->mainFrameImpl() 1208 webView->mainFrameImpl()
1231 ->frameWidget() 1209 ->frameWidget()
1232 ->getActiveWebInputMethodController(); 1210 ->getActiveWebInputMethodController();
1233 1211
1234 WebVector<WebCompositionUnderline> emptyUnderlines; 1212 WebVector<WebCompositionUnderline> emptyUnderlines;
1235 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), 1213 activeInputMethodController->setComposition(WebString::fromUTF8("abc"),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 activeInputMethodController->commitText("", emptyUnderlines, 5); 1260 activeInputMethodController->commitText("", emptyUnderlines, 5);
1283 info = activeInputMethodController->textInputInfo(); 1261 info = activeInputMethodController->textInputInfo();
1284 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); 1262 EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
1285 EXPECT_EQ(10, info.selectionStart); 1263 EXPECT_EQ(10, info.selectionStart);
1286 EXPECT_EQ(10, info.selectionEnd); 1264 EXPECT_EQ(10, info.selectionEnd);
1287 EXPECT_EQ(-1, info.compositionStart); 1265 EXPECT_EQ(-1, info.compositionStart);
1288 EXPECT_EQ(-1, info.compositionEnd); 1266 EXPECT_EQ(-1, info.compositionEnd);
1289 } 1267 }
1290 1268
1291 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { 1269 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) {
1292 URLTestHelpers::registerMockedURLFromBaseURL( 1270 registerMockedHttpURLLoad("form_with_input.html");
1293 WebString::fromUTF8(m_baseURL.c_str()),
1294 WebString::fromUTF8("form_with_input.html"));
1295 WebViewImpl* webView = 1271 WebViewImpl* webView =
1296 m_webViewHelper.initializeAndLoad(m_baseURL + "form_with_input.html"); 1272 m_webViewHelper.initializeAndLoad(m_baseURL + "form_with_input.html");
1297 webView->resize(WebSize(800, 600)); 1273 webView->resize(WebSize(800, 600));
1298 webView->setInitialFocus(false); 1274 webView->setInitialFocus(false);
1299 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width); 1275 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width);
1300 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().height); 1276 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().height);
1301 1277
1302 // Set up a composition from existing text that needs to be committed. 1278 // Set up a composition from existing text that needs to be committed.
1303 Vector<CompositionUnderline> emptyUnderlines; 1279 Vector<CompositionUnderline> emptyUnderlines;
1304 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1280 WebLocalFrameImpl* frame = webView->mainFrameImpl();
(...skipping 13 matching lines...) Expand all
1318 1294
1319 // Verify that the input field is not scrolled back into the viewport. 1295 // Verify that the input field is not scrolled back into the viewport.
1320 frame->frameWidget() 1296 frame->frameWidget()
1321 ->getActiveWebInputMethodController() 1297 ->getActiveWebInputMethodController()
1322 ->finishComposingText(WebInputMethodController::DoNotKeepSelection); 1298 ->finishComposingText(WebInputMethodController::DoNotKeepSelection);
1323 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width); 1299 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width);
1324 EXPECT_EQ(offsetHeight, webView->mainFrame()->getScrollOffset().height); 1300 EXPECT_EQ(offsetHeight, webView->mainFrame()->getScrollOffset().height);
1325 } 1301 }
1326 1302
1327 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { 1303 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) {
1328 URLTestHelpers::registerMockedURLFromBaseURL( 1304 registerMockedHttpURLLoad("text_area_populated.html");
1329 WebString::fromUTF8(m_baseURL.c_str()),
1330 WebString::fromUTF8("text_area_populated.html"));
1331 WebViewImpl* webView = 1305 WebViewImpl* webView =
1332 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); 1306 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html");
1333 webView->setInitialFocus(false); 1307 webView->setInitialFocus(false);
1334 1308
1335 WebVector<WebCompositionUnderline> emptyUnderlines; 1309 WebVector<WebCompositionUnderline> emptyUnderlines;
1336 1310
1337 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1311 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1338 WebInputMethodController* activeInputMethodController = 1312 WebInputMethodController* activeInputMethodController =
1339 frame->inputMethodController(); 1313 frame->inputMethodController();
1340 frame->setEditableSelectionOffsets(4, 4); 1314 frame->setEditableSelectionOffsets(4, 4);
(...skipping 21 matching lines...) Expand all
1362 info = activeInputMethodController->textInputInfo(); 1336 info = activeInputMethodController->textInputInfo();
1363 EXPECT_EQ(5, info.selectionStart); 1337 EXPECT_EQ(5, info.selectionStart);
1364 EXPECT_EQ(5, info.selectionEnd); 1338 EXPECT_EQ(5, info.selectionEnd);
1365 EXPECT_EQ(-1, info.compositionStart); 1339 EXPECT_EQ(-1, info.compositionStart);
1366 EXPECT_EQ(-1, info.compositionEnd); 1340 EXPECT_EQ(-1, info.compositionEnd);
1367 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", 1341 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz",
1368 std::string(info.value.utf8().data())); 1342 std::string(info.value.utf8().data()));
1369 } 1343 }
1370 1344
1371 TEST_P(WebViewTest, ExtendSelectionAndDelete) { 1345 TEST_P(WebViewTest, ExtendSelectionAndDelete) {
1372 URLTestHelpers::registerMockedURLFromBaseURL( 1346 registerMockedHttpURLLoad("input_field_populated.html");
1373 WebString::fromUTF8(m_baseURL.c_str()),
1374 WebString::fromUTF8("input_field_populated.html"));
1375 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1347 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1376 m_baseURL + "input_field_populated.html"); 1348 m_baseURL + "input_field_populated.html");
1377 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1349 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1378 webView->setInitialFocus(false); 1350 webView->setInitialFocus(false);
1379 frame->setEditableSelectionOffsets(10, 10); 1351 frame->setEditableSelectionOffsets(10, 10);
1380 frame->extendSelectionAndDelete(5, 8); 1352 frame->extendSelectionAndDelete(5, 8);
1381 WebInputMethodController* activeInputMethodController = 1353 WebInputMethodController* activeInputMethodController =
1382 frame->inputMethodController(); 1354 frame->inputMethodController();
1383 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1355 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1384 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 1356 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1385 EXPECT_EQ(5, info.selectionStart); 1357 EXPECT_EQ(5, info.selectionStart);
1386 EXPECT_EQ(5, info.selectionEnd); 1358 EXPECT_EQ(5, info.selectionEnd);
1387 frame->extendSelectionAndDelete(10, 0); 1359 frame->extendSelectionAndDelete(10, 0);
1388 info = activeInputMethodController->textInputInfo(); 1360 info = activeInputMethodController->textInputInfo();
1389 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 1361 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1390 } 1362 }
1391 1363
1392 TEST_P(WebViewTest, DeleteSurroundingText) { 1364 TEST_P(WebViewTest, DeleteSurroundingText) {
1393 URLTestHelpers::registerMockedURLFromBaseURL( 1365 registerMockedHttpURLLoad("input_field_populated.html");
1394 WebString::fromUTF8(m_baseURL.c_str()),
1395 WebString::fromUTF8("input_field_populated.html"));
1396 WebView* webView = m_webViewHelper.initializeAndLoad( 1366 WebView* webView = m_webViewHelper.initializeAndLoad(
1397 m_baseURL + "input_field_populated.html"); 1367 m_baseURL + "input_field_populated.html");
1398 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1368 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1399 WebInputMethodController* activeInputMethodController = 1369 WebInputMethodController* activeInputMethodController =
1400 frame->inputMethodController(); 1370 frame->inputMethodController();
1401 webView->setInitialFocus(false); 1371 webView->setInitialFocus(false);
1402 1372
1403 frame->setEditableSelectionOffsets(10, 10); 1373 frame->setEditableSelectionOffsets(10, 10);
1404 frame->deleteSurroundingText(5, 8); 1374 frame->deleteSurroundingText(5, 8);
1405 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1375 WebTextInputInfo info = activeInputMethodController->textInputInfo();
(...skipping 22 matching lines...) Expand all
1428 EXPECT_EQ(0, info.selectionEnd); 1398 EXPECT_EQ(0, info.selectionEnd);
1429 1399
1430 frame->deleteSurroundingText(10, 10); 1400 frame->deleteSurroundingText(10, 10);
1431 info = activeInputMethodController->textInputInfo(); 1401 info = activeInputMethodController->textInputInfo();
1432 EXPECT_EQ("", std::string(info.value.utf8().data())); 1402 EXPECT_EQ("", std::string(info.value.utf8().data()));
1433 EXPECT_EQ(0, info.selectionStart); 1403 EXPECT_EQ(0, info.selectionStart);
1434 EXPECT_EQ(0, info.selectionEnd); 1404 EXPECT_EQ(0, info.selectionEnd);
1435 } 1405 }
1436 1406
1437 TEST_P(WebViewTest, SetCompositionFromExistingText) { 1407 TEST_P(WebViewTest, SetCompositionFromExistingText) {
1438 URLTestHelpers::registerMockedURLFromBaseURL( 1408 registerMockedHttpURLLoad("input_field_populated.html");
1439 WebString::fromUTF8(m_baseURL.c_str()),
1440 WebString::fromUTF8("input_field_populated.html"));
1441 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1409 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1442 m_baseURL + "input_field_populated.html"); 1410 m_baseURL + "input_field_populated.html");
1443 webView->setInitialFocus(false); 1411 webView->setInitialFocus(false);
1444 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1412 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1445 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1413 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1446 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1414 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1447 WebInputMethodController* activeInputMethodController = 1415 WebInputMethodController* activeInputMethodController =
1448 frame->inputMethodController(); 1416 frame->inputMethodController();
1449 frame->setEditableSelectionOffsets(4, 10); 1417 frame->setEditableSelectionOffsets(4, 10);
1450 frame->setCompositionFromExistingText(8, 12, underlines); 1418 frame->setCompositionFromExistingText(8, 12, underlines);
1451 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1419 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1452 EXPECT_EQ(4, info.selectionStart); 1420 EXPECT_EQ(4, info.selectionStart);
1453 EXPECT_EQ(10, info.selectionEnd); 1421 EXPECT_EQ(10, info.selectionEnd);
1454 EXPECT_EQ(8, info.compositionStart); 1422 EXPECT_EQ(8, info.compositionStart);
1455 EXPECT_EQ(12, info.compositionEnd); 1423 EXPECT_EQ(12, info.compositionEnd);
1456 WebVector<WebCompositionUnderline> emptyUnderlines; 1424 WebVector<WebCompositionUnderline> emptyUnderlines;
1457 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); 1425 frame->setCompositionFromExistingText(0, 0, emptyUnderlines);
1458 info = activeInputMethodController->textInputInfo(); 1426 info = activeInputMethodController->textInputInfo();
1459 EXPECT_EQ(4, info.selectionStart); 1427 EXPECT_EQ(4, info.selectionStart);
1460 EXPECT_EQ(10, info.selectionEnd); 1428 EXPECT_EQ(10, info.selectionEnd);
1461 EXPECT_EQ(-1, info.compositionStart); 1429 EXPECT_EQ(-1, info.compositionStart);
1462 EXPECT_EQ(-1, info.compositionEnd); 1430 EXPECT_EQ(-1, info.compositionEnd);
1463 } 1431 }
1464 1432
1465 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { 1433 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) {
1466 URLTestHelpers::registerMockedURLFromBaseURL( 1434 registerMockedHttpURLLoad("text_area_populated.html");
1467 WebString::fromUTF8(m_baseURL.c_str()),
1468 WebString::fromUTF8("text_area_populated.html"));
1469 WebViewImpl* webView = 1435 WebViewImpl* webView =
1470 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); 1436 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html");
1471 webView->setInitialFocus(false); 1437 webView->setInitialFocus(false);
1472 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1438 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1473 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1439 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1474 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1440 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1475 WebInputMethodController* activeInputMethodController = 1441 WebInputMethodController* activeInputMethodController =
1476 frame->frameWidget()->getActiveWebInputMethodController(); 1442 frame->frameWidget()->getActiveWebInputMethodController();
1477 frame->setEditableSelectionOffsets(27, 27); 1443 frame->setEditableSelectionOffsets(27, 27);
1478 std::string newLineText("\n"); 1444 std::string newLineText("\n");
(...skipping 20 matching lines...) Expand all
1499 info = activeInputMethodController->textInputInfo(); 1465 info = activeInputMethodController->textInputInfo();
1500 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", 1466 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz",
1501 std::string(info.value.utf8().data())); 1467 std::string(info.value.utf8().data()));
1502 EXPECT_EQ(34, info.selectionStart); 1468 EXPECT_EQ(34, info.selectionStart);
1503 EXPECT_EQ(34, info.selectionEnd); 1469 EXPECT_EQ(34, info.selectionEnd);
1504 EXPECT_EQ(-1, info.compositionStart); 1470 EXPECT_EQ(-1, info.compositionStart);
1505 EXPECT_EQ(-1, info.compositionEnd); 1471 EXPECT_EQ(-1, info.compositionEnd);
1506 } 1472 }
1507 1473
1508 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { 1474 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) {
1509 URLTestHelpers::registerMockedURLFromBaseURL( 1475 registerMockedHttpURLLoad("content_editable_rich_text.html");
1510 WebString::fromUTF8(m_baseURL.c_str()),
1511 WebString::fromUTF8("content_editable_rich_text.html"));
1512 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1476 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1513 m_baseURL + "content_editable_rich_text.html"); 1477 m_baseURL + "content_editable_rich_text.html");
1514 webView->setInitialFocus(false); 1478 webView->setInitialFocus(false);
1515 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1479 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1516 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1480 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1517 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1481 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1518 frame->setEditableSelectionOffsets(1, 1); 1482 frame->setEditableSelectionOffsets(1, 1);
1519 WebDocument document = webView->mainFrame()->document(); 1483 WebDocument document = webView->mainFrame()->document();
1520 EXPECT_FALSE(document.getElementById("bold").isNull()); 1484 EXPECT_FALSE(document.getElementById("bold").isNull());
1521 frame->setCompositionFromExistingText(0, 4, underlines); 1485 frame->setCompositionFromExistingText(0, 4, underlines);
1522 EXPECT_FALSE(document.getElementById("bold").isNull()); 1486 EXPECT_FALSE(document.getElementById("bold").isNull());
1523 } 1487 }
1524 1488
1525 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { 1489 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) {
1526 URLTestHelpers::registerMockedURLFromBaseURL( 1490 registerMockedHttpURLLoad("input_field_populated.html");
1527 WebString::fromUTF8(m_baseURL.c_str()),
1528 WebString::fromUTF8("input_field_populated.html"));
1529 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1491 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1530 m_baseURL + "input_field_populated.html"); 1492 m_baseURL + "input_field_populated.html");
1531 webView->setInitialFocus(false); 1493 webView->setInitialFocus(false);
1532 1494
1533 std::string compositionTextFirst("hello "); 1495 std::string compositionTextFirst("hello ");
1534 std::string compositionTextSecond("world"); 1496 std::string compositionTextSecond("world");
1535 WebVector<WebCompositionUnderline> emptyUnderlines; 1497 WebVector<WebCompositionUnderline> emptyUnderlines;
1536 WebInputMethodController* activeInputMethodController = 1498 WebInputMethodController* activeInputMethodController =
1537 webView->mainFrameImpl() 1499 webView->mainFrameImpl()
1538 ->frameWidget() 1500 ->frameWidget()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 frame->setEditableSelectionOffsets(2, 2); 1548 frame->setEditableSelectionOffsets(2, 2);
1587 info = activeInputMethodController->textInputInfo(); 1549 info = activeInputMethodController->textInputInfo();
1588 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); 1550 EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
1589 EXPECT_EQ(2, info.selectionStart); 1551 EXPECT_EQ(2, info.selectionStart);
1590 EXPECT_EQ(2, info.selectionEnd); 1552 EXPECT_EQ(2, info.selectionEnd);
1591 EXPECT_EQ(-1, info.compositionStart); 1553 EXPECT_EQ(-1, info.compositionStart);
1592 EXPECT_EQ(-1, info.compositionEnd); 1554 EXPECT_EQ(-1, info.compositionEnd);
1593 } 1555 }
1594 1556
1595 TEST_P(WebViewTest, IsSelectionAnchorFirst) { 1557 TEST_P(WebViewTest, IsSelectionAnchorFirst) {
1596 URLTestHelpers::registerMockedURLFromBaseURL( 1558 registerMockedHttpURLLoad("input_field_populated.html");
1597 WebString::fromUTF8(m_baseURL.c_str()),
1598 WebString::fromUTF8("input_field_populated.html"));
1599 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1559 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1600 m_baseURL + "input_field_populated.html"); 1560 m_baseURL + "input_field_populated.html");
1601 WebLocalFrame* frame = webView->mainFrameImpl(); 1561 WebLocalFrame* frame = webView->mainFrameImpl();
1602 1562
1603 webView->setInitialFocus(false); 1563 webView->setInitialFocus(false);
1604 frame->setEditableSelectionOffsets(4, 10); 1564 frame->setEditableSelectionOffsets(4, 10);
1605 EXPECT_TRUE(webView->isSelectionAnchorFirst()); 1565 EXPECT_TRUE(webView->isSelectionAnchorFirst());
1606 WebRect anchor; 1566 WebRect anchor;
1607 WebRect focus; 1567 WebRect focus;
1608 webView->selectionBounds(anchor, focus); 1568 webView->selectionBounds(anchor, focus);
1609 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y)); 1569 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y));
1610 EXPECT_FALSE(webView->isSelectionAnchorFirst()); 1570 EXPECT_FALSE(webView->isSelectionAnchorFirst());
1611 } 1571 }
1612 1572
1613 TEST_P(WebViewTest, ExitingDeviceEmulationResetsPageScale) { 1573 TEST_P(WebViewTest, ExitingDeviceEmulationResetsPageScale) {
1614 URLTestHelpers::registerMockedURLFromBaseURL( 1574 registerMockedHttpURLLoad("200-by-300.html");
1615 WebString::fromUTF8(m_baseURL.c_str()),
1616 WebString::fromUTF8("200-by-300.html"));
1617 WebViewImpl* webViewImpl = 1575 WebViewImpl* webViewImpl =
1618 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 1576 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
1619 webViewImpl->resize(WebSize(200, 300)); 1577 webViewImpl->resize(WebSize(200, 300));
1620 1578
1621 float pageScaleExpected = webViewImpl->pageScaleFactor(); 1579 float pageScaleExpected = webViewImpl->pageScaleFactor();
1622 1580
1623 WebDeviceEmulationParams params; 1581 WebDeviceEmulationParams params;
1624 params.screenPosition = WebDeviceEmulationParams::Desktop; 1582 params.screenPosition = WebDeviceEmulationParams::Desktop;
1625 params.deviceScaleFactor = 0; 1583 params.deviceScaleFactor = 0;
1626 params.fitToView = false; 1584 params.fitToView = false;
1627 params.offset = WebFloatPoint(); 1585 params.offset = WebFloatPoint();
1628 params.scale = 1; 1586 params.scale = 1;
1629 1587
1630 webViewImpl->enableDeviceEmulation(params); 1588 webViewImpl->enableDeviceEmulation(params);
1631 1589
1632 webViewImpl->setPageScaleFactor(2); 1590 webViewImpl->setPageScaleFactor(2);
1633 1591
1634 webViewImpl->disableDeviceEmulation(); 1592 webViewImpl->disableDeviceEmulation();
1635 1593
1636 EXPECT_EQ(pageScaleExpected, webViewImpl->pageScaleFactor()); 1594 EXPECT_EQ(pageScaleExpected, webViewImpl->pageScaleFactor());
1637 } 1595 }
1638 1596
1639 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { 1597 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) {
1640 URLTestHelpers::registerMockedURLFromBaseURL( 1598 registerMockedHttpURLLoad("200-by-300.html");
1641 WebString::fromUTF8(m_baseURL.c_str()),
1642 WebString::fromUTF8("200-by-300.html"));
1643 WebViewImpl* webViewImpl = 1599 WebViewImpl* webViewImpl =
1644 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 1600 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
1645 webViewImpl->resize(WebSize(100, 150)); 1601 webViewImpl->resize(WebSize(100, 150));
1646 webViewImpl->updateAllLifecyclePhases(); 1602 webViewImpl->updateAllLifecyclePhases();
1647 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); 1603 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width);
1648 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1604 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1649 1605
1650 // Make the page scale and scroll with the given paremeters. 1606 // Make the page scale and scroll with the given paremeters.
1651 webViewImpl->setPageScaleFactor(2.0f); 1607 webViewImpl->setPageScaleFactor(2.0f);
1652 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); 1608 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111));
(...skipping 14 matching lines...) Expand all
1667 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); 1623 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width);
1668 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1624 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1669 EXPECT_EQ(1.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); 1625 EXPECT_EQ(1.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor());
1670 EXPECT_EQ(0, 1626 EXPECT_EQ(0,
1671 mainFrameLocal->loader().currentItem()->getScrollOffset().width()); 1627 mainFrameLocal->loader().currentItem()->getScrollOffset().width());
1672 EXPECT_EQ(0, 1628 EXPECT_EQ(0,
1673 mainFrameLocal->loader().currentItem()->getScrollOffset().height()); 1629 mainFrameLocal->loader().currentItem()->getScrollOffset().height());
1674 } 1630 }
1675 1631
1676 TEST_P(WebViewTest, BackForwardRestoreScroll) { 1632 TEST_P(WebViewTest, BackForwardRestoreScroll) {
1677 URLTestHelpers::registerMockedURLFromBaseURL( 1633 registerMockedHttpURLLoad("back_forward_restore_scroll.html");
1678 WebString::fromUTF8(m_baseURL.c_str()),
1679 WebString::fromUTF8("back_forward_restore_scroll.html"));
1680 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad( 1634 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(
1681 m_baseURL + "back_forward_restore_scroll.html"); 1635 m_baseURL + "back_forward_restore_scroll.html");
1682 webViewImpl->resize(WebSize(640, 480)); 1636 webViewImpl->resize(WebSize(640, 480));
1683 webViewImpl->updateAllLifecyclePhases(); 1637 webViewImpl->updateAllLifecyclePhases();
1684 1638
1685 // Emulate a user scroll 1639 // Emulate a user scroll
1686 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900)); 1640 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900));
1687 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); 1641 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame());
1688 Persistent<HistoryItem> item1 = mainFrameLocal->loader().currentItem(); 1642 Persistent<HistoryItem> item1 = mainFrameLocal->loader().currentItem();
1689 1643
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 nullptr, FrameLoader::resourceRequestFromHistoryItem( 1682 nullptr, FrameLoader::resourceRequestFromHistoryItem(
1729 item3.get(), WebCachePolicy::UseProtocolCachePolicy)), 1683 item3.get(), WebCachePolicy::UseProtocolCachePolicy)),
1730 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); 1684 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad);
1731 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); 1685 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width);
1732 EXPECT_GT(webViewImpl->mainFrame()->getScrollOffset().height, 2000); 1686 EXPECT_GT(webViewImpl->mainFrame()->getScrollOffset().height, 2000);
1733 } 1687 }
1734 1688
1735 // Tests that we restore scroll and scale *after* the fullscreen styles are 1689 // Tests that we restore scroll and scale *after* the fullscreen styles are
1736 // removed and the page is laid out. http://crbug.com/625683. 1690 // removed and the page is laid out. http://crbug.com/625683.
1737 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { 1691 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) {
1738 URLTestHelpers::registerMockedURLFromBaseURL( 1692 registerMockedHttpURLLoad("fullscreen_style.html");
1739 WebString::fromUTF8(m_baseURL.c_str()),
1740 WebString::fromUTF8("fullscreen_style.html"));
1741 WebViewImpl* webViewImpl = 1693 WebViewImpl* webViewImpl =
1742 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html"); 1694 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html");
1743 webViewImpl->resize(WebSize(800, 600)); 1695 webViewImpl->resize(WebSize(800, 600));
1744 webViewImpl->updateAllLifecyclePhases(); 1696 webViewImpl->updateAllLifecyclePhases();
1745 1697
1746 // Scroll the page down. 1698 // Scroll the page down.
1747 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); 1699 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000));
1748 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1700 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1749 1701
1750 // Enter fullscreen. 1702 // Enter fullscreen.
(...skipping 21 matching lines...) Expand all
1772 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout()); 1724 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
1773 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); 1725 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1774 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1726 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1775 webViewImpl->updateAllLifecyclePhases(); 1727 webViewImpl->updateAllLifecyclePhases();
1776 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1728 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1777 } 1729 }
1778 1730
1779 // Tests that exiting and immediately reentering fullscreen doesn't cause the 1731 // Tests that exiting and immediately reentering fullscreen doesn't cause the
1780 // scroll and scale restoration to occur when we enter fullscreen again. 1732 // scroll and scale restoration to occur when we enter fullscreen again.
1781 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { 1733 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) {
1782 URLTestHelpers::registerMockedURLFromBaseURL( 1734 registerMockedHttpURLLoad("fullscreen_style.html");
1783 WebString::fromUTF8(m_baseURL.c_str()),
1784 WebString::fromUTF8("fullscreen_style.html"));
1785 WebViewImpl* webViewImpl = 1735 WebViewImpl* webViewImpl =
1786 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html"); 1736 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html");
1787 webViewImpl->resize(WebSize(800, 600)); 1737 webViewImpl->resize(WebSize(800, 600));
1788 webViewImpl->updateAllLifecyclePhases(); 1738 webViewImpl->updateAllLifecyclePhases();
1789 1739
1790 // Scroll the page down. 1740 // Scroll the page down.
1791 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); 1741 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000));
1792 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1742 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1793 1743
1794 // Enter fullscreen. 1744 // Enter fullscreen.
(...skipping 30 matching lines...) Expand all
1825 1775
1826 // When we exit now, we should restore the original scroll value. 1776 // When we exit now, we should restore the original scroll value.
1827 webViewImpl->didExitFullscreen(); 1777 webViewImpl->didExitFullscreen();
1828 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); 1778 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime());
1829 webViewImpl->updateAllLifecyclePhases(); 1779 webViewImpl->updateAllLifecyclePhases();
1830 1780
1831 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1781 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1832 } 1782 }
1833 1783
1834 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { 1784 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) {
1835 URLTestHelpers::registerMockedURLFromBaseURL( 1785 registerMockedHttpURLLoad("200-by-300.html");
1836 WebString::fromUTF8(m_baseURL.c_str()),
1837 WebString::fromUTF8("200-by-300.html"));
1838 WebViewImpl* webViewImpl = 1786 WebViewImpl* webViewImpl =
1839 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 1787 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
1840 webViewImpl->resize(WebSize(100, 150)); 1788 webViewImpl->resize(WebSize(100, 150));
1841 webViewImpl->updateAllLifecyclePhases(); 1789 webViewImpl->updateAllLifecyclePhases();
1842 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); 1790 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width);
1843 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1791 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1844 1792
1845 // Make the page scale and scroll with the given paremeters. 1793 // Make the page scale and scroll with the given paremeters.
1846 webViewImpl->setPageScaleFactor(2.0f); 1794 webViewImpl->setPageScaleFactor(2.0f);
1847 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); 1795 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 void printPage(WebLocalFrame*) override { m_printCalled = true; } 1836 void printPage(WebLocalFrame*) override { m_printCalled = true; }
1889 1837
1890 bool printCalled() const { return m_printCalled; } 1838 bool printCalled() const { return m_printCalled; }
1891 1839
1892 private: 1840 private:
1893 bool m_printCalled; 1841 bool m_printCalled;
1894 }; 1842 };
1895 1843
1896 TEST_P(WebViewTest, PrintWithXHRInFlight) { 1844 TEST_P(WebViewTest, PrintWithXHRInFlight) {
1897 PrintWebViewClient client; 1845 PrintWebViewClient client;
1898 URLTestHelpers::registerMockedURLFromBaseURL( 1846 registerMockedHttpURLLoad("print_with_xhr_inflight.html");
1899 WebString::fromUTF8(m_baseURL.c_str()),
1900 WebString::fromUTF8("print_with_xhr_inflight.html"));
1901 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad( 1847 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(
1902 m_baseURL + "print_with_xhr_inflight.html", true, 0, &client); 1848 m_baseURL + "print_with_xhr_inflight.html", true, 0, &client);
1903 1849
1904 ASSERT_TRUE(toLocalFrame(webViewImpl->page()->mainFrame()) 1850 ASSERT_TRUE(toLocalFrame(webViewImpl->page()->mainFrame())
1905 ->document() 1851 ->document()
1906 ->loadEventFinished()); 1852 ->loadEventFinished());
1907 EXPECT_TRUE(client.printCalled()); 1853 EXPECT_TRUE(client.printCalled());
1908 m_webViewHelper.reset(); 1854 m_webViewHelper.reset();
1909 } 1855 }
1910 1856
(...skipping 10 matching lines...) Expand all
1921 const WebPoint clientPoint(0, 0); 1867 const WebPoint clientPoint(0, 0);
1922 const WebPoint screenPoint(0, 0); 1868 const WebPoint screenPoint(0, 0);
1923 WebFrameWidgetBase* widget = webView->mainFrameImpl()->frameWidget(); 1869 WebFrameWidgetBase* widget = webView->mainFrameImpl()->frameWidget();
1924 widget->dragTargetDragEnter(dragData, clientPoint, screenPoint, 1870 widget->dragTargetDragEnter(dragData, clientPoint, screenPoint,
1925 WebDragOperationCopy, 0); 1871 WebDragOperationCopy, 0);
1926 widget->dragTargetDrop(dragData, clientPoint, screenPoint, 0); 1872 widget->dragTargetDrop(dragData, clientPoint, screenPoint, 0);
1927 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webView->mainFrame()); 1873 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webView->mainFrame());
1928 } 1874 }
1929 1875
1930 TEST_P(WebViewTest, DragDropURL) { 1876 TEST_P(WebViewTest, DragDropURL) {
1931 URLTestHelpers::registerMockedURLFromBaseURL( 1877 registerMockedHttpURLLoad("foo.html");
1932 WebString::fromUTF8(m_baseURL.c_str()), "foo.html"); 1878 registerMockedHttpURLLoad("bar.html");
1933 URLTestHelpers::registerMockedURLFromBaseURL(
1934 WebString::fromUTF8(m_baseURL.c_str()), "bar.html");
1935 1879
1936 const std::string fooUrl = m_baseURL + "foo.html"; 1880 const std::string fooUrl = m_baseURL + "foo.html";
1937 const std::string barUrl = m_baseURL + "bar.html"; 1881 const std::string barUrl = m_baseURL + "bar.html";
1938 1882
1939 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(fooUrl); 1883 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(fooUrl);
1940 1884
1941 ASSERT_TRUE(webView); 1885 ASSERT_TRUE(webView);
1942 1886
1943 // Drag and drop barUrl and verify that we've navigated to it. 1887 // Drag and drop barUrl and verify that we've navigated to it.
1944 DragAndDropURL(webView, barUrl); 1888 DragAndDropURL(webView, barUrl);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 1973
2030 bool WebViewTest::tapElementById(WebInputEvent::Type type, 1974 bool WebViewTest::tapElementById(WebInputEvent::Type type,
2031 const WebString& id) { 1975 const WebString& id) {
2032 DCHECK(m_webViewHelper.webView()); 1976 DCHECK(m_webViewHelper.webView());
2033 Element* element = static_cast<Element*>( 1977 Element* element = static_cast<Element*>(
2034 m_webViewHelper.webView()->mainFrame()->document().getElementById(id)); 1978 m_webViewHelper.webView()->mainFrame()->document().getElementById(id));
2035 return tapElement(type, element); 1979 return tapElement(type, element);
2036 } 1980 }
2037 1981
2038 TEST_P(WebViewTest, DetectContentAroundPosition) { 1982 TEST_P(WebViewTest, DetectContentAroundPosition) {
2039 URLTestHelpers::registerMockedURLFromBaseURL( 1983 registerMockedHttpURLLoad("content_listeners.html");
2040 WebString::fromUTF8(m_baseURL.c_str()),
2041 WebString::fromUTF8("content_listeners.html"));
2042 1984
2043 ContentDetectorClient client; 1985 ContentDetectorClient client;
2044 WebView* webView = m_webViewHelper.initializeAndLoad( 1986 WebView* webView = m_webViewHelper.initializeAndLoad(
2045 m_baseURL + "content_listeners.html", true, 0, &client); 1987 m_baseURL + "content_listeners.html", true, 0, &client);
2046 webView->resize(WebSize(500, 300)); 1988 webView->resize(WebSize(500, 300));
2047 webView->updateAllLifecyclePhases(); 1989 webView->updateAllLifecyclePhases();
2048 runPendingTasks(); 1990 runPendingTasks();
2049 1991
2050 WebString clickListener = WebString::fromUTF8("clickListener"); 1992 WebString clickListener = WebString::fromUTF8("clickListener");
2051 WebString touchstartListener = WebString::fromUTF8("touchstartListener"); 1993 WebString touchstartListener = WebString::fromUTF8("touchstartListener");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 event.sourceDevice = WebGestureDeviceTouchscreen; 2027 event.sourceDevice = WebGestureDeviceTouchscreen;
2086 webView->handleInputEvent(WebCoalescedInputEvent(event)); 2028 webView->handleInputEvent(WebCoalescedInputEvent(event));
2087 runPendingTasks(); 2029 runPendingTasks();
2088 EXPECT_TRUE(client.pendingIntentsCancelled()); 2030 EXPECT_TRUE(client.pendingIntentsCancelled());
2089 2031
2090 // Explicitly reset to break dependency on locally scoped client. 2032 // Explicitly reset to break dependency on locally scoped client.
2091 m_webViewHelper.reset(); 2033 m_webViewHelper.reset();
2092 } 2034 }
2093 2035
2094 TEST_P(WebViewTest, ContentDetectionInIframe) { 2036 TEST_P(WebViewTest, ContentDetectionInIframe) {
2095 URLTestHelpers::registerMockedURLFromBaseURL( 2037 registerMockedHttpURLLoad("content_listeners_iframe.html");
2096 WebString::fromUTF8(m_baseURL.c_str()),
2097 WebString::fromUTF8("content_listeners_iframe.html"));
2098 2038
2099 ContentDetectorClient client; 2039 ContentDetectorClient client;
2100 WebView* webView = m_webViewHelper.initializeAndLoad( 2040 WebView* webView = m_webViewHelper.initializeAndLoad(
2101 m_baseURL + "content_listeners_iframe.html", true, 0, &client); 2041 m_baseURL + "content_listeners_iframe.html", true, 0, &client);
2102 webView->resize(WebSize(500, 300)); 2042 webView->resize(WebSize(500, 300));
2103 webView->updateAllLifecyclePhases(); 2043 webView->updateAllLifecyclePhases();
2104 runPendingTasks(); 2044 runPendingTasks();
2105 2045
2106 WebString noListener = WebString::fromUTF8("noListener"); 2046 WebString noListener = WebString::fromUTF8("noListener");
2107 WebString frameName = WebString::fromUTF8("innerFrame"); 2047 WebString frameName = WebString::fromUTF8("innerFrame");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 WebInputEvent::TimeStampForTesting); 2103 WebInputEvent::TimeStampForTesting);
2164 event.sourceDevice = WebGestureDeviceTouchscreen; 2104 event.sourceDevice = WebGestureDeviceTouchscreen;
2165 event.x = 3; 2105 event.x = 3;
2166 event.y = 8; 2106 event.y = 8;
2167 EXPECT_EQ(WebInputEventResult::NotHandled, 2107 EXPECT_EQ(WebInputEventResult::NotHandled,
2168 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2108 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2169 webView->close(); 2109 webView->close();
2170 } 2110 }
2171 2111
2172 TEST_P(WebViewTest, LongPressEmptyDiv) { 2112 TEST_P(WebViewTest, LongPressEmptyDiv) {
2173 URLTestHelpers::registerMockedURLFromBaseURL( 2113 registerMockedHttpURLLoad("long_press_empty_div.html");
2174 WebString::fromUTF8(m_baseURL.c_str()),
2175 WebString::fromUTF8("long_press_empty_div.html"));
2176 2114
2177 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2115 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2178 m_baseURL + "long_press_empty_div.html", true); 2116 m_baseURL + "long_press_empty_div.html", true);
2179 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 2117 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
2180 webView->resize(WebSize(500, 300)); 2118 webView->resize(WebSize(500, 300));
2181 webView->updateAllLifecyclePhases(); 2119 webView->updateAllLifecyclePhases();
2182 runPendingTasks(); 2120 runPendingTasks();
2183 2121
2184 WebGestureEvent event(WebInputEvent::GestureLongPress, 2122 WebGestureEvent event(WebInputEvent::GestureLongPress,
2185 WebInputEvent::NoModifiers, 2123 WebInputEvent::NoModifiers,
2186 WebInputEvent::TimeStampForTesting); 2124 WebInputEvent::TimeStampForTesting);
2187 event.sourceDevice = WebGestureDeviceTouchscreen; 2125 event.sourceDevice = WebGestureDeviceTouchscreen;
2188 event.x = 250; 2126 event.x = 250;
2189 event.y = 150; 2127 event.y = 150;
2190 2128
2191 EXPECT_EQ(WebInputEventResult::NotHandled, 2129 EXPECT_EQ(WebInputEventResult::NotHandled,
2192 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2130 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2193 } 2131 }
2194 2132
2195 TEST_P(WebViewTest, LongPressEmptyDivAlwaysShow) { 2133 TEST_P(WebViewTest, LongPressEmptyDivAlwaysShow) {
2196 URLTestHelpers::registerMockedURLFromBaseURL( 2134 registerMockedHttpURLLoad("long_press_empty_div.html");
2197 WebString::fromUTF8(m_baseURL.c_str()),
2198 WebString::fromUTF8("long_press_empty_div.html"));
2199 2135
2200 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2136 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2201 m_baseURL + "long_press_empty_div.html", true); 2137 m_baseURL + "long_press_empty_div.html", true);
2202 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(true); 2138 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(true);
2203 webView->resize(WebSize(500, 300)); 2139 webView->resize(WebSize(500, 300));
2204 webView->updateAllLifecyclePhases(); 2140 webView->updateAllLifecyclePhases();
2205 runPendingTasks(); 2141 runPendingTasks();
2206 2142
2207 WebGestureEvent event(WebInputEvent::GestureLongPress, 2143 WebGestureEvent event(WebInputEvent::GestureLongPress,
2208 WebInputEvent::NoModifiers, 2144 WebInputEvent::NoModifiers,
2209 WebInputEvent::TimeStampForTesting); 2145 WebInputEvent::TimeStampForTesting);
2210 event.sourceDevice = WebGestureDeviceTouchscreen; 2146 event.sourceDevice = WebGestureDeviceTouchscreen;
2211 event.x = 250; 2147 event.x = 250;
2212 event.y = 150; 2148 event.y = 150;
2213 2149
2214 EXPECT_EQ(WebInputEventResult::HandledSystem, 2150 EXPECT_EQ(WebInputEventResult::HandledSystem,
2215 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2151 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2216 } 2152 }
2217 2153
2218 TEST_P(WebViewTest, LongPressObject) { 2154 TEST_P(WebViewTest, LongPressObject) {
2219 URLTestHelpers::registerMockedURLFromBaseURL( 2155 registerMockedHttpURLLoad("long_press_object.html");
2220 WebString::fromUTF8(m_baseURL.c_str()),
2221 WebString::fromUTF8("long_press_object.html"));
2222 2156
2223 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2157 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2224 m_baseURL + "long_press_object.html", true); 2158 m_baseURL + "long_press_object.html", true);
2225 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(true); 2159 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(true);
2226 webView->resize(WebSize(500, 300)); 2160 webView->resize(WebSize(500, 300));
2227 webView->updateAllLifecyclePhases(); 2161 webView->updateAllLifecyclePhases();
2228 runPendingTasks(); 2162 runPendingTasks();
2229 2163
2230 WebGestureEvent event(WebInputEvent::GestureLongPress, 2164 WebGestureEvent event(WebInputEvent::GestureLongPress,
2231 WebInputEvent::NoModifiers, 2165 WebInputEvent::NoModifiers,
2232 WebInputEvent::TimeStampForTesting); 2166 WebInputEvent::TimeStampForTesting);
2233 event.sourceDevice = WebGestureDeviceTouchscreen; 2167 event.sourceDevice = WebGestureDeviceTouchscreen;
2234 event.x = 10; 2168 event.x = 10;
2235 event.y = 10; 2169 event.y = 10;
2236 2170
2237 EXPECT_NE(WebInputEventResult::HandledSystem, 2171 EXPECT_NE(WebInputEventResult::HandledSystem,
2238 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2172 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2239 2173
2240 HTMLElement* element = 2174 HTMLElement* element =
2241 toHTMLElement(webView->mainFrame()->document().getElementById("obj")); 2175 toHTMLElement(webView->mainFrame()->document().getElementById("obj"));
2242 EXPECT_FALSE(element->canStartSelection()); 2176 EXPECT_FALSE(element->canStartSelection());
2243 } 2177 }
2244 2178
2245 TEST_P(WebViewTest, LongPressObjectFallback) { 2179 TEST_P(WebViewTest, LongPressObjectFallback) {
2246 URLTestHelpers::registerMockedURLFromBaseURL( 2180 registerMockedHttpURLLoad("long_press_object_fallback.html");
2247 WebString::fromUTF8(m_baseURL.c_str()),
2248 WebString::fromUTF8("long_press_object_fallback.html"));
2249 2181
2250 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2182 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2251 m_baseURL + "long_press_object_fallback.html", true); 2183 m_baseURL + "long_press_object_fallback.html", true);
2252 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(true); 2184 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(true);
2253 webView->resize(WebSize(500, 300)); 2185 webView->resize(WebSize(500, 300));
2254 webView->updateAllLifecyclePhases(); 2186 webView->updateAllLifecyclePhases();
2255 runPendingTasks(); 2187 runPendingTasks();
2256 2188
2257 WebGestureEvent event(WebInputEvent::GestureLongPress, 2189 WebGestureEvent event(WebInputEvent::GestureLongPress,
2258 WebInputEvent::NoModifiers, 2190 WebInputEvent::NoModifiers,
2259 WebInputEvent::TimeStampForTesting); 2191 WebInputEvent::TimeStampForTesting);
2260 event.sourceDevice = WebGestureDeviceTouchscreen; 2192 event.sourceDevice = WebGestureDeviceTouchscreen;
2261 event.x = 10; 2193 event.x = 10;
2262 event.y = 10; 2194 event.y = 10;
2263 2195
2264 EXPECT_EQ(WebInputEventResult::HandledSystem, 2196 EXPECT_EQ(WebInputEventResult::HandledSystem,
2265 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2197 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2266 2198
2267 HTMLElement* element = 2199 HTMLElement* element =
2268 toHTMLElement(webView->mainFrame()->document().getElementById("obj")); 2200 toHTMLElement(webView->mainFrame()->document().getElementById("obj"));
2269 EXPECT_TRUE(element->canStartSelection()); 2201 EXPECT_TRUE(element->canStartSelection());
2270 } 2202 }
2271 2203
2272 TEST_P(WebViewTest, LongPressImage) { 2204 TEST_P(WebViewTest, LongPressImage) {
2273 URLTestHelpers::registerMockedURLFromBaseURL( 2205 registerMockedHttpURLLoad("long_press_image.html");
2274 WebString::fromUTF8(m_baseURL.c_str()),
2275 WebString::fromUTF8("long_press_image.html"));
2276 2206
2277 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2207 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2278 m_baseURL + "long_press_image.html", true); 2208 m_baseURL + "long_press_image.html", true);
2279 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 2209 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
2280 webView->resize(WebSize(500, 300)); 2210 webView->resize(WebSize(500, 300));
2281 webView->updateAllLifecyclePhases(); 2211 webView->updateAllLifecyclePhases();
2282 runPendingTasks(); 2212 runPendingTasks();
2283 2213
2284 WebGestureEvent event(WebInputEvent::GestureLongPress, 2214 WebGestureEvent event(WebInputEvent::GestureLongPress,
2285 WebInputEvent::NoModifiers, 2215 WebInputEvent::NoModifiers,
2286 WebInputEvent::TimeStampForTesting); 2216 WebInputEvent::TimeStampForTesting);
2287 event.sourceDevice = WebGestureDeviceTouchscreen; 2217 event.sourceDevice = WebGestureDeviceTouchscreen;
2288 event.x = 10; 2218 event.x = 10;
2289 event.y = 10; 2219 event.y = 10;
2290 2220
2291 EXPECT_EQ(WebInputEventResult::HandledSystem, 2221 EXPECT_EQ(WebInputEventResult::HandledSystem,
2292 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2222 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2293 } 2223 }
2294 2224
2295 TEST_P(WebViewTest, LongPressVideo) { 2225 TEST_P(WebViewTest, LongPressVideo) {
2296 URLTestHelpers::registerMockedURLFromBaseURL( 2226 registerMockedHttpURLLoad("long_press_video.html");
2297 WebString::fromUTF8(m_baseURL.c_str()),
2298 WebString::fromUTF8("long_press_video.html"));
2299 2227
2300 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2228 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2301 m_baseURL + "long_press_video.html", true); 2229 m_baseURL + "long_press_video.html", true);
2302 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 2230 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
2303 webView->resize(WebSize(500, 300)); 2231 webView->resize(WebSize(500, 300));
2304 webView->updateAllLifecyclePhases(); 2232 webView->updateAllLifecyclePhases();
2305 runPendingTasks(); 2233 runPendingTasks();
2306 2234
2307 WebGestureEvent event(WebInputEvent::GestureLongPress, 2235 WebGestureEvent event(WebInputEvent::GestureLongPress,
2308 WebInputEvent::NoModifiers, 2236 WebInputEvent::NoModifiers,
2309 WebInputEvent::TimeStampForTesting); 2237 WebInputEvent::TimeStampForTesting);
2310 event.sourceDevice = WebGestureDeviceTouchscreen; 2238 event.sourceDevice = WebGestureDeviceTouchscreen;
2311 event.x = 10; 2239 event.x = 10;
2312 event.y = 10; 2240 event.y = 10;
2313 2241
2314 EXPECT_EQ(WebInputEventResult::HandledSystem, 2242 EXPECT_EQ(WebInputEventResult::HandledSystem,
2315 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2243 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2316 } 2244 }
2317 2245
2318 TEST_P(WebViewTest, LongPressLink) { 2246 TEST_P(WebViewTest, LongPressLink) {
2319 URLTestHelpers::registerMockedURLFromBaseURL( 2247 registerMockedHttpURLLoad("long_press_link.html");
2320 WebString::fromUTF8(m_baseURL.c_str()),
2321 WebString::fromUTF8("long_press_link.html"));
2322 2248
2323 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2249 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2324 m_baseURL + "long_press_link.html", true); 2250 m_baseURL + "long_press_link.html", true);
2325 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 2251 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
2326 webView->resize(WebSize(500, 300)); 2252 webView->resize(WebSize(500, 300));
2327 webView->updateAllLifecyclePhases(); 2253 webView->updateAllLifecyclePhases();
2328 runPendingTasks(); 2254 runPendingTasks();
2329 2255
2330 WebGestureEvent event(WebInputEvent::GestureLongPress, 2256 WebGestureEvent event(WebInputEvent::GestureLongPress,
2331 WebInputEvent::NoModifiers, 2257 WebInputEvent::NoModifiers,
2332 WebInputEvent::TimeStampForTesting); 2258 WebInputEvent::TimeStampForTesting);
2333 event.sourceDevice = WebGestureDeviceTouchscreen; 2259 event.sourceDevice = WebGestureDeviceTouchscreen;
2334 event.x = 500; 2260 event.x = 500;
2335 event.y = 300; 2261 event.y = 300;
2336 2262
2337 EXPECT_EQ(WebInputEventResult::HandledSystem, 2263 EXPECT_EQ(WebInputEventResult::HandledSystem,
2338 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2264 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2339 } 2265 }
2340 2266
2341 TEST_P(WebViewTest, showContextMenuOnLongPressingLinks) { 2267 TEST_P(WebViewTest, showContextMenuOnLongPressingLinks) {
2342 URLTestHelpers::registerMockedURLFromBaseURL( 2268 registerMockedHttpURLLoad("long_press_links_and_images.html");
2343 WebString::fromUTF8(m_baseURL.c_str()),
2344 WebString::fromUTF8("long_press_links_and_images.html"));
2345 2269
2346 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com/foo.png"), 2270 URLTestHelpers::registerMockedURLLoad(
2347 "white-1x1.png"); 2271 toKURL("http://www.test.com/foo.png"),
2272 testing::webTestDataPath("white-1x1.png"));
2348 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2273 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2349 m_baseURL + "long_press_links_and_images.html", true); 2274 m_baseURL + "long_press_links_and_images.html", true);
2350 2275
2351 webView->settingsImpl()->setTouchDragDropEnabled(true); 2276 webView->settingsImpl()->setTouchDragDropEnabled(true);
2352 webView->resize(WebSize(500, 300)); 2277 webView->resize(WebSize(500, 300));
2353 webView->updateAllLifecyclePhases(); 2278 webView->updateAllLifecyclePhases();
2354 runPendingTasks(); 2279 runPendingTasks();
2355 2280
2356 WebString anchorTagId = WebString::fromUTF8("anchorTag"); 2281 WebString anchorTagId = WebString::fromUTF8("anchorTag");
2357 WebString imageTagId = WebString::fromUTF8("imageTag"); 2282 WebString imageTagId = WebString::fromUTF8("imageTag");
2358 2283
2359 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, anchorTagId)); 2284 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, anchorTagId));
2360 EXPECT_STREQ("anchor contextmenu", 2285 EXPECT_STREQ("anchor contextmenu",
2361 webView->mainFrame()->document().title().utf8().data()); 2286 webView->mainFrame()->document().title().utf8().data());
2362 2287
2363 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, imageTagId)); 2288 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, imageTagId));
2364 EXPECT_STREQ("image contextmenu", 2289 EXPECT_STREQ("image contextmenu",
2365 webView->mainFrame()->document().title().utf8().data()); 2290 webView->mainFrame()->document().title().utf8().data());
2366 } 2291 }
2367 2292
2368 TEST_P(WebViewTest, LongPressEmptyEditableSelection) { 2293 TEST_P(WebViewTest, LongPressEmptyEditableSelection) {
2369 URLTestHelpers::registerMockedURLFromBaseURL( 2294 registerMockedHttpURLLoad("long_press_empty_editable_selection.html");
2370 WebString::fromUTF8(m_baseURL.c_str()),
2371 WebString::fromUTF8("long_press_empty_editable_selection.html"));
2372 2295
2373 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2296 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2374 m_baseURL + "long_press_empty_editable_selection.html", true); 2297 m_baseURL + "long_press_empty_editable_selection.html", true);
2375 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 2298 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
2376 webView->resize(WebSize(500, 300)); 2299 webView->resize(WebSize(500, 300));
2377 webView->updateAllLifecyclePhases(); 2300 webView->updateAllLifecyclePhases();
2378 runPendingTasks(); 2301 runPendingTasks();
2379 2302
2380 WebGestureEvent event(WebInputEvent::GestureLongPress, 2303 WebGestureEvent event(WebInputEvent::GestureLongPress,
2381 WebInputEvent::NoModifiers, 2304 WebInputEvent::NoModifiers,
2382 WebInputEvent::TimeStampForTesting); 2305 WebInputEvent::TimeStampForTesting);
2383 event.sourceDevice = WebGestureDeviceTouchscreen; 2306 event.sourceDevice = WebGestureDeviceTouchscreen;
2384 event.x = 10; 2307 event.x = 10;
2385 event.y = 10; 2308 event.y = 10;
2386 2309
2387 EXPECT_EQ(WebInputEventResult::HandledSystem, 2310 EXPECT_EQ(WebInputEventResult::HandledSystem,
2388 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2311 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2389 } 2312 }
2390 2313
2391 TEST_P(WebViewTest, LongPressEmptyNonEditableSelection) { 2314 TEST_P(WebViewTest, LongPressEmptyNonEditableSelection) {
2392 URLTestHelpers::registerMockedURLFromBaseURL( 2315 registerMockedHttpURLLoad("long_press_image.html");
2393 WebString::fromUTF8(m_baseURL.c_str()),
2394 WebString::fromUTF8("long_press_image.html"));
2395 2316
2396 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2317 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2397 m_baseURL + "long_press_image.html", true); 2318 m_baseURL + "long_press_image.html", true);
2398 webView->resize(WebSize(500, 500)); 2319 webView->resize(WebSize(500, 500));
2399 webView->updateAllLifecyclePhases(); 2320 webView->updateAllLifecyclePhases();
2400 runPendingTasks(); 2321 runPendingTasks();
2401 2322
2402 WebGestureEvent event(WebInputEvent::GestureLongPress, 2323 WebGestureEvent event(WebInputEvent::GestureLongPress,
2403 WebInputEvent::NoModifiers, 2324 WebInputEvent::NoModifiers,
2404 WebInputEvent::TimeStampForTesting); 2325 WebInputEvent::TimeStampForTesting);
2405 event.sourceDevice = WebGestureDeviceTouchscreen; 2326 event.sourceDevice = WebGestureDeviceTouchscreen;
2406 event.x = 300; 2327 event.x = 300;
2407 event.y = 300; 2328 event.y = 300;
2408 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2329 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2409 2330
2410 EXPECT_EQ(WebInputEventResult::HandledSystem, 2331 EXPECT_EQ(WebInputEventResult::HandledSystem,
2411 webView->handleInputEvent(WebCoalescedInputEvent(event))); 2332 webView->handleInputEvent(WebCoalescedInputEvent(event)));
2412 EXPECT_TRUE(frame->selectionAsText().isEmpty()); 2333 EXPECT_TRUE(frame->selectionAsText().isEmpty());
2413 } 2334 }
2414 2335
2415 TEST_P(WebViewTest, LongPressSelection) { 2336 TEST_P(WebViewTest, LongPressSelection) {
2416 URLTestHelpers::registerMockedURLFromBaseURL( 2337 registerMockedHttpURLLoad("longpress_selection.html");
2417 WebString::fromUTF8(m_baseURL.c_str()),
2418 WebString::fromUTF8("longpress_selection.html"));
2419 2338
2420 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2339 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2421 m_baseURL + "longpress_selection.html", true); 2340 m_baseURL + "longpress_selection.html", true);
2422 webView->resize(WebSize(500, 300)); 2341 webView->resize(WebSize(500, 300));
2423 webView->updateAllLifecyclePhases(); 2342 webView->updateAllLifecyclePhases();
2424 runPendingTasks(); 2343 runPendingTasks();
2425 2344
2426 WebString target = WebString::fromUTF8("target"); 2345 WebString target = WebString::fromUTF8("target");
2427 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); 2346 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse");
2428 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2347 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2429 2348
2430 EXPECT_TRUE( 2349 EXPECT_TRUE(
2431 tapElementById(WebInputEvent::GestureLongPress, onselectstartfalse)); 2350 tapElementById(WebInputEvent::GestureLongPress, onselectstartfalse));
2432 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 2351 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
2433 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); 2352 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
2434 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); 2353 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data()));
2435 } 2354 }
2436 2355
2437 #if !OS(MACOSX) 2356 #if !OS(MACOSX)
2438 TEST_P(WebViewTest, TouchDoesntSelectEmptyTextarea) { 2357 TEST_P(WebViewTest, TouchDoesntSelectEmptyTextarea) {
2439 URLTestHelpers::registerMockedURLFromBaseURL( 2358 registerMockedHttpURLLoad("longpress_textarea.html");
2440 WebString::fromUTF8(m_baseURL.c_str()),
2441 WebString::fromUTF8("longpress_textarea.html"));
2442 2359
2443 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2360 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2444 m_baseURL + "longpress_textarea.html", true); 2361 m_baseURL + "longpress_textarea.html", true);
2445 webView->resize(WebSize(500, 300)); 2362 webView->resize(WebSize(500, 300));
2446 webView->updateAllLifecyclePhases(); 2363 webView->updateAllLifecyclePhases();
2447 runPendingTasks(); 2364 runPendingTasks();
2448 2365
2449 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox"); 2366 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox");
2450 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2367 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2451 2368
(...skipping 22 matching lines...) Expand all
2474 tapElementById(WebInputEvent::GestureLongPress, blanklinestextbox)); 2391 tapElementById(WebInputEvent::GestureLongPress, blanklinestextbox));
2475 EXPECT_TRUE(frame->selectionAsText().isEmpty()); 2392 EXPECT_TRUE(frame->selectionAsText().isEmpty());
2476 2393
2477 // Double-tap past last word of textbox. 2394 // Double-tap past last word of textbox.
2478 webView->handleInputEvent(WebCoalescedInputEvent(event)); 2395 webView->handleInputEvent(WebCoalescedInputEvent(event));
2479 EXPECT_TRUE(frame->selectionAsText().isEmpty()); 2396 EXPECT_TRUE(frame->selectionAsText().isEmpty());
2480 } 2397 }
2481 #endif 2398 #endif
2482 2399
2483 TEST_P(WebViewTest, LongPressImageTextarea) { 2400 TEST_P(WebViewTest, LongPressImageTextarea) {
2484 URLTestHelpers::registerMockedURLFromBaseURL( 2401 registerMockedHttpURLLoad("longpress_image_contenteditable.html");
2485 WebString::fromUTF8(m_baseURL.c_str()),
2486 WebString::fromUTF8("longpress_image_contenteditable.html"));
2487 2402
2488 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2403 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2489 m_baseURL + "longpress_image_contenteditable.html", true); 2404 m_baseURL + "longpress_image_contenteditable.html", true);
2490 webView->resize(WebSize(500, 300)); 2405 webView->resize(WebSize(500, 300));
2491 webView->updateAllLifecyclePhases(); 2406 webView->updateAllLifecyclePhases();
2492 runPendingTasks(); 2407 runPendingTasks();
2493 2408
2494 WebString image = WebString::fromUTF8("purpleimage"); 2409 WebString image = WebString::fromUTF8("purpleimage");
2495 2410
2496 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, image)); 2411 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, image));
2497 WebRange range = webView->caretOrSelectionRange(); 2412 WebRange range = webView->caretOrSelectionRange();
2498 EXPECT_FALSE(range.isNull()); 2413 EXPECT_FALSE(range.isNull());
2499 EXPECT_EQ(0, range.startOffset()); 2414 EXPECT_EQ(0, range.startOffset());
2500 EXPECT_EQ(1, range.length()); 2415 EXPECT_EQ(1, range.length());
2501 } 2416 }
2502 2417
2503 TEST_P(WebViewTest, BlinkCaretAfterLongPress) { 2418 TEST_P(WebViewTest, BlinkCaretAfterLongPress) {
2504 URLTestHelpers::registerMockedURLFromBaseURL( 2419 registerMockedHttpURLLoad("blink_caret_on_typing_after_long_press.html");
2505 WebString::fromUTF8(m_baseURL.c_str()),
2506 WebString::fromUTF8("blink_caret_on_typing_after_long_press.html"));
2507 2420
2508 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2421 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2509 m_baseURL + "blink_caret_on_typing_after_long_press.html", true); 2422 m_baseURL + "blink_caret_on_typing_after_long_press.html", true);
2510 webView->resize(WebSize(640, 480)); 2423 webView->resize(WebSize(640, 480));
2511 webView->updateAllLifecyclePhases(); 2424 webView->updateAllLifecyclePhases();
2512 runPendingTasks(); 2425 runPendingTasks();
2513 2426
2514 WebString target = WebString::fromUTF8("target"); 2427 WebString target = WebString::fromUTF8("target");
2515 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); 2428 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl();
2516 2429
2517 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); 2430 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
2518 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 2431 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
2519 } 2432 }
2520 2433
2521 TEST_P(WebViewTest, BlinkCaretOnClosingContextMenu) { 2434 TEST_P(WebViewTest, BlinkCaretOnClosingContextMenu) {
2522 URLTestHelpers::registerMockedURLFromBaseURL( 2435 registerMockedHttpURLLoad("form.html");
2523 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("form.html"));
2524 WebViewImpl* webView = 2436 WebViewImpl* webView =
2525 m_webViewHelper.initializeAndLoad(m_baseURL + "form.html", true); 2437 m_webViewHelper.initializeAndLoad(m_baseURL + "form.html", true);
2526 2438
2527 webView->setInitialFocus(false); 2439 webView->setInitialFocus(false);
2528 runPendingTasks(); 2440 runPendingTasks();
2529 2441
2530 // We suspend caret blinking when pressing with mouse right button. 2442 // We suspend caret blinking when pressing with mouse right button.
2531 // Note that we do not send MouseUp event here since it will be consumed 2443 // Note that we do not send MouseUp event here since it will be consumed
2532 // by the context menu once it shows up. 2444 // by the context menu once it shows up.
2533 WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers, 2445 WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers,
(...skipping 13 matching lines...) Expand all
2547 webView->showContextMenu(); 2459 webView->showContextMenu();
2548 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 2460 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
2549 2461
2550 // Caret blinking will be resumed only after context menu is closed. 2462 // Caret blinking will be resumed only after context menu is closed.
2551 webView->didCloseContextMenu(); 2463 webView->didCloseContextMenu();
2552 2464
2553 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 2465 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
2554 } 2466 }
2555 2467
2556 TEST_P(WebViewTest, SelectionOnReadOnlyInput) { 2468 TEST_P(WebViewTest, SelectionOnReadOnlyInput) {
2557 URLTestHelpers::registerMockedURLFromBaseURL( 2469 registerMockedHttpURLLoad("selection_readonly.html");
2558 WebString::fromUTF8(m_baseURL.c_str()),
2559 WebString::fromUTF8("selection_readonly.html"));
2560 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2470 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2561 m_baseURL + "selection_readonly.html", true); 2471 m_baseURL + "selection_readonly.html", true);
2562 webView->resize(WebSize(640, 480)); 2472 webView->resize(WebSize(640, 480));
2563 webView->updateAllLifecyclePhases(); 2473 webView->updateAllLifecyclePhases();
2564 runPendingTasks(); 2474 runPendingTasks();
2565 2475
2566 std::string testWord = "This text should be selected."; 2476 std::string testWord = "This text should be selected.";
2567 2477
2568 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2478 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2569 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data())); 2479 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data()));
2570 2480
2571 WebRange range = webView->caretOrSelectionRange(); 2481 WebRange range = webView->caretOrSelectionRange();
2572 EXPECT_FALSE(range.isNull()); 2482 EXPECT_FALSE(range.isNull());
2573 EXPECT_EQ(0, range.startOffset()); 2483 EXPECT_EQ(0, range.startOffset());
2574 EXPECT_EQ(static_cast<int>(testWord.length()), range.length()); 2484 EXPECT_EQ(static_cast<int>(testWord.length()), range.length());
2575 } 2485 }
2576 2486
2577 TEST_P(WebViewTest, KeyDownScrollsHandled) { 2487 TEST_P(WebViewTest, KeyDownScrollsHandled) {
2578 URLTestHelpers::registerMockedURLFromBaseURL( 2488 registerMockedHttpURLLoad("content-width-1000.html");
2579 WebString::fromUTF8(m_baseURL.c_str()),
2580 WebString::fromUTF8("content-width-1000.html"));
2581 2489
2582 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2490 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2583 m_baseURL + "content-width-1000.html", true); 2491 m_baseURL + "content-width-1000.html", true);
2584 webView->resize(WebSize(100, 100)); 2492 webView->resize(WebSize(100, 100));
2585 webView->updateAllLifecyclePhases(); 2493 webView->updateAllLifecyclePhases();
2586 runPendingTasks(); 2494 runPendingTasks();
2587 2495
2588 WebKeyboardEvent keyEvent(WebInputEvent::RawKeyDown, 2496 WebKeyboardEvent keyEvent(WebInputEvent::RawKeyDown,
2589 WebInputEvent::NoModifiers, 2497 WebInputEvent::NoModifiers,
2590 WebInputEvent::TimeStampForTesting); 2498 WebInputEvent::TimeStampForTesting);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 2655
2748 private: 2656 private:
2749 bool m_ignoreTextChanges; 2657 bool m_ignoreTextChanges;
2750 int m_textChangesFromUserGesture; 2658 int m_textChangesFromUserGesture;
2751 int m_textChangesWhileIgnored; 2659 int m_textChangesWhileIgnored;
2752 int m_textChangesWhileNotIgnored; 2660 int m_textChangesWhileNotIgnored;
2753 int m_userGestureNotificationsCount; 2661 int m_userGestureNotificationsCount;
2754 }; 2662 };
2755 2663
2756 TEST_P(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) { 2664 TEST_P(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) {
2757 URLTestHelpers::registerMockedURLFromBaseURL( 2665 registerMockedHttpURLLoad("input_field_populated.html");
2758 WebString::fromUTF8(m_baseURL.c_str()),
2759 WebString::fromUTF8("input_field_populated.html"));
2760 MockAutofillClient client; 2666 MockAutofillClient client;
2761 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2667 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2762 m_baseURL + "input_field_populated.html"); 2668 m_baseURL + "input_field_populated.html");
2763 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2669 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2764 frame->setAutofillClient(&client); 2670 frame->setAutofillClient(&client);
2765 webView->setInitialFocus(false); 2671 webView->setInitialFocus(false);
2766 2672
2767 // Set up a composition that needs to be committed. 2673 // Set up a composition that needs to be committed.
2768 WebVector<WebCompositionUnderline> emptyUnderlines; 2674 WebVector<WebCompositionUnderline> emptyUnderlines;
2769 frame->setEditableSelectionOffsets(4, 10); 2675 frame->setEditableSelectionOffsets(4, 10);
(...skipping 21 matching lines...) Expand all
2791 const char* failMessage) { 2697 const char* failMessage) {
2792 WebTextInputInfo info = 2698 WebTextInputInfo info =
2793 webView->mainFrameImpl()->inputMethodController()->textInputInfo(); 2699 webView->mainFrameImpl()->inputMethodController()->textInputInfo();
2794 EXPECT_EQ(selectionStart, info.selectionStart) << failMessage; 2700 EXPECT_EQ(selectionStart, info.selectionStart) << failMessage;
2795 EXPECT_EQ(selectionEnd, info.selectionEnd) << failMessage; 2701 EXPECT_EQ(selectionEnd, info.selectionEnd) << failMessage;
2796 EXPECT_EQ(compositionStart, info.compositionStart) << failMessage; 2702 EXPECT_EQ(compositionStart, info.compositionStart) << failMessage;
2797 EXPECT_EQ(compositionEnd, info.compositionEnd) << failMessage; 2703 EXPECT_EQ(compositionEnd, info.compositionEnd) << failMessage;
2798 } 2704 }
2799 2705
2800 TEST_P(WebViewTest, CompositionNotCancelledByBackspace) { 2706 TEST_P(WebViewTest, CompositionNotCancelledByBackspace) {
2801 URLTestHelpers::registerMockedURLFromBaseURL( 2707 registerMockedHttpURLLoad("composition_not_cancelled_by_backspace.html");
2802 WebString::fromUTF8(m_baseURL.c_str()),
2803 WebString::fromUTF8("composition_not_cancelled_by_backspace.html"));
2804 MockAutofillClient client; 2708 MockAutofillClient client;
2805 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2709 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2806 m_baseURL + "composition_not_cancelled_by_backspace.html"); 2710 m_baseURL + "composition_not_cancelled_by_backspace.html");
2807 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2711 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2808 frame->setAutofillClient(&client); 2712 frame->setAutofillClient(&client);
2809 webView->setInitialFocus(false); 2713 webView->setInitialFocus(false);
2810 2714
2811 // Test both input elements. 2715 // Test both input elements.
2812 for (int i = 0; i < 2; ++i) { 2716 for (int i = 0; i < 2; ++i) {
2813 // Select composition and do sanity check. 2717 // Select composition and do sanity check.
(...skipping 25 matching lines...) Expand all
2839 keyEvent.setType(WebInputEvent::KeyUp); 2743 keyEvent.setType(WebInputEvent::KeyUp);
2840 webView->handleInputEvent(WebCoalescedInputEvent(keyEvent)); 2744 webView->handleInputEvent(WebCoalescedInputEvent(keyEvent));
2841 2745
2842 webView->advanceFocus(false); 2746 webView->advanceFocus(false);
2843 } 2747 }
2844 2748
2845 frame->setAutofillClient(0); 2749 frame->setAutofillClient(0);
2846 } 2750 }
2847 2751
2848 TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) { 2752 TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) {
2849 URLTestHelpers::registerMockedURLFromBaseURL( 2753 registerMockedHttpURLLoad("input_field_populated.html");
2850 WebString::fromUTF8(m_baseURL.c_str()),
2851 WebString::fromUTF8("input_field_populated.html"));
2852 MockAutofillClient client; 2754 MockAutofillClient client;
2853 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2755 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2854 m_baseURL + "input_field_populated.html"); 2756 m_baseURL + "input_field_populated.html");
2855 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2757 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2856 frame->setAutofillClient(&client); 2758 frame->setAutofillClient(&client);
2857 webView->setInitialFocus(false); 2759 webView->setInitialFocus(false);
2858 WebInputMethodController* activeInputMethodController = 2760 WebInputMethodController* activeInputMethodController =
2859 frame->frameWidget()->getActiveWebInputMethodController(); 2761 frame->frameWidget()->getActiveWebInputMethodController();
2860 // Set up a composition that needs to be committed. 2762 // Set up a composition that needs to be committed.
2861 std::string compositionText("testingtext"); 2763 std::string compositionText("testingtext");
(...skipping 12 matching lines...) Expand all
2874 client.clearChangeCounts(); 2776 client.clearChangeCounts();
2875 activeInputMethodController->finishComposingText( 2777 activeInputMethodController->finishComposingText(
2876 WebInputMethodController::KeepSelection); 2778 WebInputMethodController::KeepSelection);
2877 EXPECT_EQ(0, client.textChangesWhileIgnored()); 2779 EXPECT_EQ(0, client.textChangesWhileIgnored());
2878 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); 2780 EXPECT_EQ(1, client.textChangesWhileNotIgnored());
2879 2781
2880 frame->setAutofillClient(0); 2782 frame->setAutofillClient(0);
2881 } 2783 }
2882 2784
2883 TEST_P(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) { 2785 TEST_P(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) {
2884 URLTestHelpers::registerMockedURLFromBaseURL( 2786 registerMockedHttpURLLoad("input_field_populated.html");
2885 WebString::fromUTF8(m_baseURL.c_str()),
2886 WebString::fromUTF8("input_field_populated.html"));
2887 MockAutofillClient client; 2787 MockAutofillClient client;
2888 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2788 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2889 m_baseURL + "input_field_populated.html", true); 2789 m_baseURL + "input_field_populated.html", true);
2890 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2790 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2891 frame->setAutofillClient(&client); 2791 frame->setAutofillClient(&client);
2892 webView->setInitialFocus(false); 2792 webView->setInitialFocus(false);
2893 2793
2894 WebVector<WebCompositionUnderline> emptyUnderlines; 2794 WebVector<WebCompositionUnderline> emptyUnderlines;
2895 2795
2896 client.clearChangeCounts(); 2796 client.clearChangeCounts();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2986 0, webURLRequestWithTargetStart.toResourceRequest(), "_start"); 2886 0, webURLRequestWithTargetStart.toResourceRequest(), "_start");
2987 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame()) 2887 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame())
2988 ->loader() 2888 ->loader()
2989 .load(requestWithTargetStart); 2889 .load(requestWithTargetStart);
2990 EXPECT_TRUE(client.didFocusCalled()); 2890 EXPECT_TRUE(client.didFocusCalled());
2991 2891
2992 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 2892 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
2993 } 2893 }
2994 2894
2995 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) { 2895 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) {
2996 URLTestHelpers::registerMockedURLFromBaseURL( 2896 registerMockedHttpURLLoad("focusout_focusin_events.html");
2997 WebString::fromUTF8(m_baseURL.c_str()), "focusout_focusin_events.html");
2998 WebView* webView = m_webViewHelper.initializeAndLoad( 2897 WebView* webView = m_webViewHelper.initializeAndLoad(
2999 m_baseURL + "focusout_focusin_events.html", true, 0); 2898 m_baseURL + "focusout_focusin_events.html", true, 0);
3000 2899
3001 webView->setFocus(true); 2900 webView->setFocus(true);
3002 webView->setFocus(false); 2901 webView->setFocus(false);
3003 webView->setFocus(true); 2902 webView->setFocus(true);
3004 2903
3005 WebElement element = 2904 WebElement element =
3006 webView->mainFrame()->document().getElementById("message"); 2905 webView->mainFrame()->document().getElementById("message");
3007 EXPECT_STREQ("focusoutfocusin", element.textContent().utf8().data()); 2906 EXPECT_STREQ("focusoutfocusin", element.textContent().utf8().data());
3008 } 2907 }
3009 2908
3010 TEST_P(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) { 2909 TEST_P(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) {
3011 URLTestHelpers::registerMockedURLFromBaseURL( 2910 registerMockedHttpURLLoad("domfocusout_domfocusin_events.html");
3012 WebString::fromUTF8(m_baseURL.c_str()),
3013 "domfocusout_domfocusin_events.html");
3014 WebView* webView = m_webViewHelper.initializeAndLoad( 2911 WebView* webView = m_webViewHelper.initializeAndLoad(
3015 m_baseURL + "domfocusout_domfocusin_events.html", true, 0); 2912 m_baseURL + "domfocusout_domfocusin_events.html", true, 0);
3016 2913
3017 webView->setFocus(true); 2914 webView->setFocus(true);
3018 webView->setFocus(false); 2915 webView->setFocus(false);
3019 webView->setFocus(true); 2916 webView->setFocus(true);
3020 2917
3021 WebElement element = 2918 WebElement element =
3022 webView->mainFrame()->document().getElementById("message"); 2919 webView->mainFrame()->document().getElementById("message");
3023 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.textContent().utf8().data()); 2920 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.textContent().utf8().data());
(...skipping 17 matching lines...) Expand all
3041 // TODO(crbug.com/605112) This test is crashing on Android (Nexus 4) bot. 2938 // TODO(crbug.com/605112) This test is crashing on Android (Nexus 4) bot.
3042 #if OS(ANDROID) 2939 #if OS(ANDROID)
3043 TEST_P(WebViewTest, DISABLED_ChooseValueFromDateTimeChooser) { 2940 TEST_P(WebViewTest, DISABLED_ChooseValueFromDateTimeChooser) {
3044 #else 2941 #else
3045 TEST_P(WebViewTest, ChooseValueFromDateTimeChooser) { 2942 TEST_P(WebViewTest, ChooseValueFromDateTimeChooser) {
3046 #endif 2943 #endif
3047 bool originalMultipleFieldsFlag = 2944 bool originalMultipleFieldsFlag =
3048 RuntimeEnabledFeatures::inputMultipleFieldsUIEnabled(); 2945 RuntimeEnabledFeatures::inputMultipleFieldsUIEnabled();
3049 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled(false); 2946 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled(false);
3050 DateTimeChooserWebViewClient client; 2947 DateTimeChooserWebViewClient client;
3051 std::string url = m_baseURL + "date_time_chooser.html"; 2948 std::string url = registerMockedHttpURLLoad("date_time_chooser.html");
3052 URLTestHelpers::registerMockedURLLoad(toKURL(url), "date_time_chooser.html");
3053 WebViewImpl* webViewImpl = 2949 WebViewImpl* webViewImpl =
3054 m_webViewHelper.initializeAndLoad(url, true, 0, &client); 2950 m_webViewHelper.initializeAndLoad(url, true, 0, &client);
3055 2951
3056 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 2952 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
3057 2953
3058 HTMLInputElement* inputElement; 2954 HTMLInputElement* inputElement;
3059 2955
3060 inputElement = toHTMLInputElement(document->getElementById("date")); 2956 inputElement = toHTMLInputElement(document->getElementById("date"));
3061 openDateTimeChooser(webViewImpl, inputElement); 2957 openDateTimeChooser(webViewImpl, inputElement);
3062 client.chooserCompletion()->didChooseValue(0); 2958 client.chooserCompletion()->didChooseValue(0);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 EXPECT_STREQ("", inputElement->value().utf8().data()); 3014 EXPECT_STREQ("", inputElement->value().utf8().data());
3119 3015
3120 // Clear the WebViewClient from the webViewHelper to avoid use-after-free in 3016 // Clear the WebViewClient from the webViewHelper to avoid use-after-free in
3121 // the WebViewHelper destructor. 3017 // the WebViewHelper destructor.
3122 m_webViewHelper.reset(); 3018 m_webViewHelper.reset();
3123 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled( 3019 RuntimeEnabledFeatures::setInputMultipleFieldsUIEnabled(
3124 originalMultipleFieldsFlag); 3020 originalMultipleFieldsFlag);
3125 } 3021 }
3126 3022
3127 TEST_P(WebViewTest, DispatchesFocusBlurOnViewToggle) { 3023 TEST_P(WebViewTest, DispatchesFocusBlurOnViewToggle) {
3128 URLTestHelpers::registerMockedURLFromBaseURL( 3024 registerMockedHttpURLLoad("focus_blur_events.html");
3129 WebString::fromUTF8(m_baseURL.c_str()), "focus_blur_events.html");
3130 WebView* webView = m_webViewHelper.initializeAndLoad( 3025 WebView* webView = m_webViewHelper.initializeAndLoad(
3131 m_baseURL + "focus_blur_events.html", true, 0); 3026 m_baseURL + "focus_blur_events.html", true, 0);
3132 3027
3133 webView->setFocus(true); 3028 webView->setFocus(true);
3134 webView->setFocus(false); 3029 webView->setFocus(false);
3135 webView->setFocus(true); 3030 webView->setFocus(true);
3136 3031
3137 WebElement element = 3032 WebElement element =
3138 webView->mainFrame()->document().getElementById("message"); 3033 webView->mainFrame()->document().getElementById("message");
3139 // Expect not to see duplication of events. 3034 // Expect not to see duplication of events.
(...skipping 17 matching lines...) Expand all
3157 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " 3052 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: "
3158 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " 3053 "normal; font-variant-ligatures: normal; font-variant-caps: normal; "
3159 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " 3054 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: "
3160 "start; text-indent: 0px; text-transform: none; white-space: normal; " 3055 "start; text-indent: 0px; text-transform: none; white-space: normal; "
3161 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " 3056 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; "
3162 "text-decoration-style: initial; text-decoration-color: initial;\">Price " 3057 "text-decoration-style: initial; text-decoration-color: initial;\">Price "
3163 "10,000,000won</div>"; 3058 "10,000,000won</div>";
3164 WebString clipText; 3059 WebString clipText;
3165 WebString clipHtml; 3060 WebString clipHtml;
3166 WebRect clipRect; 3061 WebRect clipRect;
3167 URLTestHelpers::registerMockedURLFromBaseURL( 3062 registerMockedHttpURLLoad("Ahem.ttf");
3168 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3063 registerMockedHttpURLLoad("smartclip.html");
3169 URLTestHelpers::registerMockedURLFromBaseURL(
3170 WebString::fromUTF8(m_baseURL.c_str()),
3171 WebString::fromUTF8("smartclip.html"));
3172 WebView* webView = 3064 WebView* webView =
3173 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html"); 3065 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html");
3174 webView->resize(WebSize(500, 500)); 3066 webView->resize(WebSize(500, 500));
3175 webView->updateAllLifecyclePhases(); 3067 webView->updateAllLifecyclePhases();
3176 WebRect cropRect(300, 125, 152, 50); 3068 WebRect cropRect(300, 125, 152, 50);
3177 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 3069 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
3178 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str()); 3070 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str());
3179 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str()); 3071 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str());
3180 } 3072 }
3181 3073
(...skipping 14 matching lines...) Expand all
3196 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " 3088 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: "
3197 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " 3089 "normal; font-variant-ligatures: normal; font-variant-caps: normal; "
3198 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " 3090 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: "
3199 "start; text-indent: 0px; text-transform: none; white-space: normal; " 3091 "start; text-indent: 0px; text-transform: none; white-space: normal; "
3200 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " 3092 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; "
3201 "text-decoration-style: initial; text-decoration-color: initial;\">Price " 3093 "text-decoration-style: initial; text-decoration-color: initial;\">Price "
3202 "10,000,000won</div>"; 3094 "10,000,000won</div>";
3203 WebString clipText; 3095 WebString clipText;
3204 WebString clipHtml; 3096 WebString clipHtml;
3205 WebRect clipRect; 3097 WebRect clipRect;
3206 URLTestHelpers::registerMockedURLFromBaseURL( 3098 registerMockedHttpURLLoad("Ahem.ttf");
3207 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3099 registerMockedHttpURLLoad("smartclip.html");
3208 URLTestHelpers::registerMockedURLFromBaseURL(
3209 WebString::fromUTF8(m_baseURL.c_str()),
3210 WebString::fromUTF8("smartclip.html"));
3211 WebView* webView = 3100 WebView* webView =
3212 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html"); 3101 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html");
3213 webView->resize(WebSize(500, 500)); 3102 webView->resize(WebSize(500, 500));
3214 webView->updateAllLifecyclePhases(); 3103 webView->updateAllLifecyclePhases();
3215 webView->setPageScaleFactor(1.5); 3104 webView->setPageScaleFactor(1.5);
3216 webView->setVisualViewportOffset(WebFloatPoint(167, 100)); 3105 webView->setVisualViewportOffset(WebFloatPoint(167, 100));
3217 WebRect cropRect(200, 38, 228, 75); 3106 WebRect cropRect(200, 38, 228, 75);
3218 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 3107 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
3219 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str()); 3108 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str());
3220 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str()); 3109 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str());
3221 } 3110 }
3222 3111
3223 TEST_P(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone) { 3112 TEST_P(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone) {
3224 WebString clipText; 3113 WebString clipText;
3225 WebString clipHtml; 3114 WebString clipHtml;
3226 WebRect clipRect; 3115 WebRect clipRect;
3227 URLTestHelpers::registerMockedURLFromBaseURL( 3116 registerMockedHttpURLLoad("Ahem.ttf");
3228 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3117 registerMockedHttpURLLoad("smartclip_user_select_none.html");
3229 URLTestHelpers::registerMockedURLFromBaseURL(
3230 WebString::fromUTF8(m_baseURL.c_str()),
3231 WebString::fromUTF8("smartclip_user_select_none.html"));
3232 WebView* webView = m_webViewHelper.initializeAndLoad( 3118 WebView* webView = m_webViewHelper.initializeAndLoad(
3233 m_baseURL + "smartclip_user_select_none.html"); 3119 m_baseURL + "smartclip_user_select_none.html");
3234 webView->resize(WebSize(500, 500)); 3120 webView->resize(WebSize(500, 500));
3235 webView->updateAllLifecyclePhases(); 3121 webView->updateAllLifecyclePhases();
3236 WebRect cropRect(0, 0, 100, 100); 3122 WebRect cropRect(0, 0, 100, 100);
3237 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 3123 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
3238 EXPECT_STREQ("", clipText.utf8().c_str()); 3124 EXPECT_STREQ("", clipText.utf8().c_str());
3239 EXPECT_STREQ("", clipHtml.utf8().c_str()); 3125 EXPECT_STREQ("", clipHtml.utf8().c_str());
3240 } 3126 }
3241 3127
3242 TEST_P(WebViewTest, SmartClipDoesNotCrashPositionReversed) { 3128 TEST_P(WebViewTest, SmartClipDoesNotCrashPositionReversed) {
3243 WebString clipText; 3129 WebString clipText;
3244 WebString clipHtml; 3130 WebString clipHtml;
3245 WebRect clipRect; 3131 WebRect clipRect;
3246 URLTestHelpers::registerMockedURLFromBaseURL( 3132 registerMockedHttpURLLoad("Ahem.ttf");
3247 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3133 registerMockedHttpURLLoad("smartclip_reversed_positions.html");
3248 URLTestHelpers::registerMockedURLFromBaseURL(
3249 WebString::fromUTF8(m_baseURL.c_str()),
3250 WebString::fromUTF8("smartclip_reversed_positions.html"));
3251 WebView* webView = m_webViewHelper.initializeAndLoad( 3134 WebView* webView = m_webViewHelper.initializeAndLoad(
3252 m_baseURL + "smartclip_reversed_positions.html"); 3135 m_baseURL + "smartclip_reversed_positions.html");
3253 webView->resize(WebSize(500, 500)); 3136 webView->resize(WebSize(500, 500));
3254 webView->updateAllLifecyclePhases(); 3137 webView->updateAllLifecyclePhases();
3255 // Left upper corner of the rect will be end position in the DOM hierarchy. 3138 // Left upper corner of the rect will be end position in the DOM hierarchy.
3256 WebRect cropRect(30, 110, 400, 250); 3139 WebRect cropRect(30, 110, 400, 250);
3257 // This should not still crash. See crbug.com/589082 for more details. 3140 // This should not still crash. See crbug.com/589082 for more details.
3258 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 3141 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
3259 } 3142 }
3260 3143
(...skipping 20 matching lines...) Expand all
3281 const WebString& name, 3164 const WebString& name,
3282 const WebString& uniqueName, 3165 const WebString& uniqueName,
3283 WebSandboxFlags sandboxFlags, 3166 WebSandboxFlags sandboxFlags,
3284 const WebFrameOwnerProperties& frameOwnerProperties) { 3167 const WebFrameOwnerProperties& frameOwnerProperties) {
3285 ++m_count; 3168 ++m_count;
3286 return TestWebFrameClient::createChildFrame( 3169 return TestWebFrameClient::createChildFrame(
3287 parent, scope, name, uniqueName, sandboxFlags, frameOwnerProperties); 3170 parent, scope, name, uniqueName, sandboxFlags, frameOwnerProperties);
3288 } 3171 }
3289 3172
3290 TEST_P(WebViewTest, ChangeDisplayMode) { 3173 TEST_P(WebViewTest, ChangeDisplayMode) {
3291 URLTestHelpers::registerMockedURLFromBaseURL( 3174 registerMockedHttpURLLoad("display_mode.html");
3292 WebString::fromUTF8(m_baseURL.c_str()),
3293 WebString::fromUTF8("display_mode.html"));
3294 WebView* webView = 3175 WebView* webView =
3295 m_webViewHelper.initializeAndLoad(m_baseURL + "display_mode.html", true); 3176 m_webViewHelper.initializeAndLoad(m_baseURL + "display_mode.html", true);
3296 3177
3297 std::string content = 3178 std::string content =
3298 WebFrameContentDumper::dumpWebViewAsText(webView, 21).utf8(); 3179 WebFrameContentDumper::dumpWebViewAsText(webView, 21).utf8();
3299 EXPECT_EQ("regular-ui", content); 3180 EXPECT_EQ("regular-ui", content);
3300 3181
3301 webView->setDisplayMode(WebDisplayModeMinimalUi); 3182 webView->setDisplayMode(WebDisplayModeMinimalUi);
3302 content = WebFrameContentDumper::dumpWebViewAsText(webView, 21).utf8(); 3183 content = WebFrameContentDumper::dumpWebViewAsText(webView, 21).utf8();
3303 EXPECT_EQ("minimal-ui", content); 3184 EXPECT_EQ("minimal-ui", content);
3304 m_webViewHelper.reset(); 3185 m_webViewHelper.reset();
3305 } 3186 }
3306 3187
3307 TEST_P(WebViewTest, AddFrameInCloseUnload) { 3188 TEST_P(WebViewTest, AddFrameInCloseUnload) {
3308 CreateChildCounterFrameClient frameClient; 3189 CreateChildCounterFrameClient frameClient;
3309 URLTestHelpers::registerMockedURLFromBaseURL( 3190 registerMockedHttpURLLoad("add_frame_in_unload.html");
3310 WebString::fromUTF8(m_baseURL.c_str()),
3311 WebString::fromUTF8("add_frame_in_unload.html"));
3312 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", 3191 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html",
3313 true, &frameClient); 3192 true, &frameClient);
3314 m_webViewHelper.reset(); 3193 m_webViewHelper.reset();
3315 EXPECT_EQ(0, frameClient.count()); 3194 EXPECT_EQ(0, frameClient.count());
3316 } 3195 }
3317 3196
3318 TEST_P(WebViewTest, AddFrameInCloseURLUnload) { 3197 TEST_P(WebViewTest, AddFrameInCloseURLUnload) {
3319 CreateChildCounterFrameClient frameClient; 3198 CreateChildCounterFrameClient frameClient;
3320 URLTestHelpers::registerMockedURLFromBaseURL( 3199 registerMockedHttpURLLoad("add_frame_in_unload.html");
3321 WebString::fromUTF8(m_baseURL.c_str()),
3322 WebString::fromUTF8("add_frame_in_unload.html"));
3323 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", 3200 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html",
3324 true, &frameClient); 3201 true, &frameClient);
3325 m_webViewHelper.webView()->mainFrame()->dispatchUnloadEvent(); 3202 m_webViewHelper.webView()->mainFrame()->dispatchUnloadEvent();
3326 EXPECT_EQ(0, frameClient.count()); 3203 EXPECT_EQ(0, frameClient.count());
3327 m_webViewHelper.reset(); 3204 m_webViewHelper.reset();
3328 } 3205 }
3329 3206
3330 TEST_P(WebViewTest, AddFrameInNavigateUnload) { 3207 TEST_P(WebViewTest, AddFrameInNavigateUnload) {
3331 CreateChildCounterFrameClient frameClient; 3208 CreateChildCounterFrameClient frameClient;
3332 URLTestHelpers::registerMockedURLFromBaseURL( 3209 registerMockedHttpURLLoad("add_frame_in_unload.html");
3333 WebString::fromUTF8(m_baseURL.c_str()),
3334 WebString::fromUTF8("add_frame_in_unload.html"));
3335 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", 3210 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html",
3336 true, &frameClient); 3211 true, &frameClient);
3337 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), 3212 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(),
3338 "about:blank"); 3213 "about:blank");
3339 EXPECT_EQ(0, frameClient.count()); 3214 EXPECT_EQ(0, frameClient.count());
3340 m_webViewHelper.reset(); 3215 m_webViewHelper.reset();
3341 } 3216 }
3342 3217
3343 TEST_P(WebViewTest, AddFrameInChildInNavigateUnload) { 3218 TEST_P(WebViewTest, AddFrameInChildInNavigateUnload) {
3344 CreateChildCounterFrameClient frameClient; 3219 CreateChildCounterFrameClient frameClient;
3345 URLTestHelpers::registerMockedURLFromBaseURL( 3220 registerMockedHttpURLLoad("add_frame_in_unload_wrapper.html");
3346 WebString::fromUTF8(m_baseURL.c_str()), 3221 registerMockedHttpURLLoad("add_frame_in_unload.html");
3347 WebString::fromUTF8("add_frame_in_unload_wrapper.html"));
3348 URLTestHelpers::registerMockedURLFromBaseURL(
3349 WebString::fromUTF8(m_baseURL.c_str()),
3350 WebString::fromUTF8("add_frame_in_unload.html"));
3351 m_webViewHelper.initializeAndLoad( 3222 m_webViewHelper.initializeAndLoad(
3352 m_baseURL + "add_frame_in_unload_wrapper.html", true, &frameClient); 3223 m_baseURL + "add_frame_in_unload_wrapper.html", true, &frameClient);
3353 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), 3224 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(),
3354 "about:blank"); 3225 "about:blank");
3355 EXPECT_EQ(1, frameClient.count()); 3226 EXPECT_EQ(1, frameClient.count());
3356 m_webViewHelper.reset(); 3227 m_webViewHelper.reset();
3357 } 3228 }
3358 3229
3359 class TouchEventHandlerWebWidgetClient 3230 class TouchEventHandlerWebWidgetClient
3360 : public FrameTestHelpers::TestWebWidgetClient { 3231 : public FrameTestHelpers::TestWebWidgetClient {
(...skipping 18 matching lines...) Expand all
3379 3250
3380 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called 3251 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called
3381 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove| 3252 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove|
3382 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made 3253 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made
3383 // correctly is the job of LayoutTests/fast/events/event-handler-count.html. 3254 // correctly is the job of LayoutTests/fast/events/event-handler-count.html.
3384 TEST_P(WebViewTest, HasTouchEventHandlers) { 3255 TEST_P(WebViewTest, HasTouchEventHandlers) {
3385 TouchEventHandlerWebWidgetClient client; 3256 TouchEventHandlerWebWidgetClient client;
3386 // We need to create a LayerTreeView for the client before loading the page, 3257 // We need to create a LayerTreeView for the client before loading the page,
3387 // otherwise ChromeClient will default to assuming there are touch handlers. 3258 // otherwise ChromeClient will default to assuming there are touch handlers.
3388 WebLayerTreeView* layerTreeView = client.initializeLayerTreeView(); 3259 WebLayerTreeView* layerTreeView = client.initializeLayerTreeView();
3389 std::string url = m_baseURL + "has_touch_event_handlers.html"; 3260 std::string url = registerMockedHttpURLLoad("has_touch_event_handlers.html");
3390 URLTestHelpers::registerMockedURLLoad(toKURL(url),
3391 "has_touch_event_handlers.html");
3392 WebViewImpl* webViewImpl = 3261 WebViewImpl* webViewImpl =
3393 m_webViewHelper.initializeAndLoad(url, true, 0, 0, &client); 3262 m_webViewHelper.initializeAndLoad(url, true, 0, 0, &client);
3394 ASSERT_TRUE(layerTreeView); 3263 ASSERT_TRUE(layerTreeView);
3395 const EventHandlerRegistry::EventHandlerClass touchEvent = 3264 const EventHandlerRegistry::EventHandlerClass touchEvent =
3396 EventHandlerRegistry::TouchStartOrMoveEventBlocking; 3265 EventHandlerRegistry::TouchStartOrMoveEventBlocking;
3397 3266
3398 // The page is initialized with at least one no-handlers call. 3267 // The page is initialized with at least one no-handlers call.
3399 // In practice we get two such calls because WebViewHelper::initializeAndLoad 3268 // In practice we get two such calls because WebViewHelper::initializeAndLoad
3400 // first initializes an empty frame, and then loads a document into it, so 3269 // first initializes an empty frame, and then loads a document into it, so
3401 // there are two FrameLoader::commitProvisionalLoad calls. 3270 // there are two FrameLoader::commitProvisionalLoad calls.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 3376
3508 // Free the webView before the TouchEventHandlerWebViewClient gets freed. 3377 // Free the webView before the TouchEventHandlerWebViewClient gets freed.
3509 m_webViewHelper.reset(); 3378 m_webViewHelper.reset();
3510 } 3379 }
3511 3380
3512 // This test checks that deleting nodes which have only non-JS-registered touch 3381 // This test checks that deleting nodes which have only non-JS-registered touch
3513 // handlers also removes them from the event handler registry. Note that this 3382 // handlers also removes them from the event handler registry. Note that this
3514 // is different from detaching and re-attaching the same node, which is covered 3383 // is different from detaching and re-attaching the same node, which is covered
3515 // by layout tests under fast/events/. 3384 // by layout tests under fast/events/.
3516 TEST_P(WebViewTest, DeleteElementWithRegisteredHandler) { 3385 TEST_P(WebViewTest, DeleteElementWithRegisteredHandler) {
3517 std::string url = m_baseURL + "simple_div.html"; 3386 std::string url = registerMockedHttpURLLoad("simple_div.html");
3518 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html");
3519 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); 3387 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true);
3520 3388
3521 Persistent<Document> document = 3389 Persistent<Document> document =
3522 webViewImpl->mainFrameImpl()->frame()->document(); 3390 webViewImpl->mainFrameImpl()->frame()->document();
3523 Element* div = document->getElementById("div"); 3391 Element* div = document->getElementById("div");
3524 EventHandlerRegistry& registry = 3392 EventHandlerRegistry& registry =
3525 document->frameHost()->eventHandlerRegistry(); 3393 document->frameHost()->eventHandlerRegistry();
3526 3394
3527 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent); 3395 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent);
3528 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); 3396 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent));
3529 3397
3530 DummyExceptionStateForTesting exceptionState; 3398 DummyExceptionStateForTesting exceptionState;
3531 div->remove(exceptionState); 3399 div->remove(exceptionState);
3532 3400
3533 // For oilpan we have to force a GC to ensure the event handlers have been 3401 // For oilpan we have to force a GC to ensure the event handlers have been
3534 // removed when checking below. We do a precise GC (collectAllGarbage does not 3402 // removed when checking below. We do a precise GC (collectAllGarbage does not
3535 // scan the stack) to ensure the div element dies. This is also why the 3403 // scan the stack) to ensure the div element dies. This is also why the
3536 // Document is in a Persistent since we want that to stay around. 3404 // Document is in a Persistent since we want that to stay around.
3537 ThreadState::current()->collectAllGarbage(); 3405 ThreadState::current()->collectAllGarbage();
3538 3406
3539 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); 3407 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent));
3540 } 3408 }
3541 3409
3542 // This test verifies the text input flags are correctly exposed to script. 3410 // This test verifies the text input flags are correctly exposed to script.
3543 TEST_P(WebViewTest, TextInputFlags) { 3411 TEST_P(WebViewTest, TextInputFlags) {
3544 std::string url = m_baseURL + "text_input_flags.html"; 3412 std::string url = registerMockedHttpURLLoad("text_input_flags.html");
3545 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html");
3546 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); 3413 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true);
3547 webViewImpl->setInitialFocus(false); 3414 webViewImpl->setInitialFocus(false);
3548 3415
3549 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); 3416 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl();
3550 WebInputMethodControllerImpl* activeInputMethodController = 3417 WebInputMethodControllerImpl* activeInputMethodController =
3551 frame->inputMethodController(); 3418 frame->inputMethodController();
3552 Document* document = frame->frame()->document(); 3419 Document* document = frame->frame()->document();
3553 3420
3554 // (A) <input> 3421 // (A) <input>
3555 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and 3422 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 EXPECT_FALSE(info1.equals(info2)); 3461 EXPECT_FALSE(info1.equals(info2));
3595 EXPECT_FALSE(info2.equals(info3)); 3462 EXPECT_FALSE(info2.equals(info3));
3596 3463
3597 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. 3464 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient.
3598 m_webViewHelper.reset(); 3465 m_webViewHelper.reset();
3599 } 3466 }
3600 3467
3601 // Check that the WebAutofillClient is correctly notified about first user 3468 // Check that the WebAutofillClient is correctly notified about first user
3602 // gestures after load, following various input events. 3469 // gestures after load, following various input events.
3603 TEST_P(WebViewTest, FirstUserGestureObservedKeyEvent) { 3470 TEST_P(WebViewTest, FirstUserGestureObservedKeyEvent) {
3604 URLTestHelpers::registerMockedURLFromBaseURL( 3471 registerMockedHttpURLLoad("form.html");
3605 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("form.html"));
3606 MockAutofillClient client; 3472 MockAutofillClient client;
3607 WebViewImpl* webView = 3473 WebViewImpl* webView =
3608 m_webViewHelper.initializeAndLoad(m_baseURL + "form.html", true); 3474 m_webViewHelper.initializeAndLoad(m_baseURL + "form.html", true);
3609 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3475 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3610 frame->setAutofillClient(&client); 3476 frame->setAutofillClient(&client);
3611 webView->setInitialFocus(false); 3477 webView->setInitialFocus(false);
3612 3478
3613 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 3479 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
3614 3480
3615 WebKeyboardEvent keyEvent(WebInputEvent::RawKeyDown, 3481 WebKeyboardEvent keyEvent(WebInputEvent::RawKeyDown,
3616 WebInputEvent::NoModifiers, 3482 WebInputEvent::NoModifiers,
3617 WebInputEvent::TimeStampForTesting); 3483 WebInputEvent::TimeStampForTesting);
3618 keyEvent.domKey = Platform::current()->domKeyEnumFromString(" "); 3484 keyEvent.domKey = Platform::current()->domKeyEnumFromString(" ");
3619 keyEvent.windowsKeyCode = VKEY_SPACE; 3485 keyEvent.windowsKeyCode = VKEY_SPACE;
3620 webView->handleInputEvent(WebCoalescedInputEvent(keyEvent)); 3486 webView->handleInputEvent(WebCoalescedInputEvent(keyEvent));
3621 keyEvent.setType(WebInputEvent::KeyUp); 3487 keyEvent.setType(WebInputEvent::KeyUp);
3622 webView->handleInputEvent(WebCoalescedInputEvent(keyEvent)); 3488 webView->handleInputEvent(WebCoalescedInputEvent(keyEvent));
3623 3489
3624 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 3490 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
3625 frame->setAutofillClient(0); 3491 frame->setAutofillClient(0);
3626 } 3492 }
3627 3493
3628 TEST_P(WebViewTest, FirstUserGestureObservedMouseEvent) { 3494 TEST_P(WebViewTest, FirstUserGestureObservedMouseEvent) {
3629 URLTestHelpers::registerMockedURLFromBaseURL( 3495 registerMockedHttpURLLoad("form.html");
3630 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("form.html"));
3631 MockAutofillClient client; 3496 MockAutofillClient client;
3632 WebViewImpl* webView = 3497 WebViewImpl* webView =
3633 m_webViewHelper.initializeAndLoad(m_baseURL + "form.html", true); 3498 m_webViewHelper.initializeAndLoad(m_baseURL + "form.html", true);
3634 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3499 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3635 frame->setAutofillClient(&client); 3500 frame->setAutofillClient(&client);
3636 webView->setInitialFocus(false); 3501 webView->setInitialFocus(false);
3637 3502
3638 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 3503 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
3639 3504
3640 WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers, 3505 WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers,
3641 WebInputEvent::TimeStampForTesting); 3506 WebInputEvent::TimeStampForTesting);
3642 mouseEvent.button = WebMouseEvent::Button::Left; 3507 mouseEvent.button = WebMouseEvent::Button::Left;
3643 mouseEvent.x = 1; 3508 mouseEvent.x = 1;
3644 mouseEvent.y = 1; 3509 mouseEvent.y = 1;
3645 mouseEvent.clickCount = 1; 3510 mouseEvent.clickCount = 1;
3646 webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent)); 3511 webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent));
3647 mouseEvent.setType(WebInputEvent::MouseUp); 3512 mouseEvent.setType(WebInputEvent::MouseUp);
3648 webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent)); 3513 webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent));
3649 3514
3650 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 3515 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
3651 frame->setAutofillClient(0); 3516 frame->setAutofillClient(0);
3652 } 3517 }
3653 3518
3654 TEST_P(WebViewTest, FirstUserGestureObservedGestureTap) { 3519 TEST_P(WebViewTest, FirstUserGestureObservedGestureTap) {
3655 URLTestHelpers::registerMockedURLFromBaseURL( 3520 registerMockedHttpURLLoad("longpress_selection.html");
3656 WebString::fromUTF8(m_baseURL.c_str()),
3657 WebString::fromUTF8("longpress_selection.html"));
3658 MockAutofillClient client; 3521 MockAutofillClient client;
3659 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 3522 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
3660 m_baseURL + "longpress_selection.html", true); 3523 m_baseURL + "longpress_selection.html", true);
3661 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3524 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3662 frame->setAutofillClient(&client); 3525 frame->setAutofillClient(&client);
3663 webView->setInitialFocus(false); 3526 webView->setInitialFocus(false);
3664 3527
3665 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 3528 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
3666 3529
3667 EXPECT_TRUE( 3530 EXPECT_TRUE(
3668 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); 3531 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target")));
3669 3532
3670 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 3533 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
3671 frame->setAutofillClient(0); 3534 frame->setAutofillClient(0);
3672 } 3535 }
3673 3536
3674 TEST_P(WebViewTest, CompositionIsUserGesture) { 3537 TEST_P(WebViewTest, CompositionIsUserGesture) {
3675 URLTestHelpers::registerMockedURLFromBaseURL( 3538 registerMockedHttpURLLoad("input_field_populated.html");
3676 WebString::fromUTF8(m_baseURL.c_str()),
3677 WebString::fromUTF8("input_field_populated.html"));
3678 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 3539 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
3679 m_baseURL + "input_field_populated.html"); 3540 m_baseURL + "input_field_populated.html");
3680 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3541 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3681 MockAutofillClient client; 3542 MockAutofillClient client;
3682 frame->setAutofillClient(&client); 3543 frame->setAutofillClient(&client);
3683 webView->setInitialFocus(false); 3544 webView->setInitialFocus(false);
3684 3545
3685 EXPECT_TRUE( 3546 EXPECT_TRUE(
3686 frame->frameWidget()->getActiveWebInputMethodController()->setComposition( 3547 frame->frameWidget()->getActiveWebInputMethodController()->setComposition(
3687 WebString::fromUTF8(std::string("hello").c_str()), 3548 WebString::fromUTF8(std::string("hello").c_str()),
3688 WebVector<WebCompositionUnderline>(), 3, 3)); 3549 WebVector<WebCompositionUnderline>(), 3, 3));
3689 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3550 EXPECT_EQ(1, client.textChangesFromUserGesture());
3690 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3551 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3691 EXPECT_TRUE(frame->hasMarkedText()); 3552 EXPECT_TRUE(frame->hasMarkedText());
3692 3553
3693 frame->setAutofillClient(0); 3554 frame->setAutofillClient(0);
3694 } 3555 }
3695 3556
3696 TEST_P(WebViewTest, CompareSelectAllToContentAsText) { 3557 TEST_P(WebViewTest, CompareSelectAllToContentAsText) {
3697 URLTestHelpers::registerMockedURLFromBaseURL( 3558 registerMockedHttpURLLoad("longpress_selection.html");
3698 WebString::fromUTF8(m_baseURL.c_str()),
3699 WebString::fromUTF8("longpress_selection.html"));
3700 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 3559 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
3701 m_baseURL + "longpress_selection.html", true); 3560 m_baseURL + "longpress_selection.html", true);
3702 3561
3703 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3562 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3704 frame->executeScript(WebScriptSource( 3563 frame->executeScript(WebScriptSource(
3705 WebString::fromUTF8("document.execCommand('SelectAll', false, null)"))); 3564 WebString::fromUTF8("document.execCommand('SelectAll', false, null)")));
3706 std::string actual = frame->selectionAsText().utf8(); 3565 std::string actual = frame->selectionAsText().utf8();
3707 3566
3708 const int kMaxOutputCharacters = 1024; 3567 const int kMaxOutputCharacters = 1024;
3709 std::string expected = 3568 std::string expected =
3710 WebFrameContentDumper::dumpWebViewAsText(webView, kMaxOutputCharacters) 3569 WebFrameContentDumper::dumpWebViewAsText(webView, kMaxOutputCharacters)
3711 .utf8(); 3570 .utf8();
3712 EXPECT_EQ(expected, actual); 3571 EXPECT_EQ(expected, actual);
3713 } 3572 }
3714 3573
3715 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { 3574 TEST_P(WebViewTest, AutoResizeSubtreeLayout) {
3716 std::string url = m_baseURL + "subtree-layout.html"; 3575 std::string url = registerMockedHttpURLLoad("subtree-layout.html");
3717 URLTestHelpers::registerMockedURLLoad(toKURL(url), "subtree-layout.html");
3718 WebView* webView = m_webViewHelper.initialize(true); 3576 WebView* webView = m_webViewHelper.initialize(true);
3719 3577
3720 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); 3578 webView->enableAutoResizeMode(WebSize(200, 200), WebSize(200, 200));
3721 loadFrame(webView->mainFrame(), url); 3579 loadFrame(webView->mainFrame(), url);
3722 3580
3723 FrameView* frameView = 3581 FrameView* frameView =
3724 m_webViewHelper.webView()->mainFrameImpl()->frameView(); 3582 m_webViewHelper.webView()->mainFrameImpl()->frameView();
3725 3583
3726 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. 3584 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout.
3727 // This EXPECT is merely a dummy. The real test is that we don't trigger 3585 // This EXPECT is merely a dummy. The real test is that we don't trigger
3728 // asserts in debug builds. 3586 // asserts in debug builds.
3729 EXPECT_FALSE(frameView->needsLayout()); 3587 EXPECT_FALSE(frameView->needsLayout());
3730 }; 3588 };
3731 3589
3732 TEST_P(WebViewTest, PreferredSize) { 3590 TEST_P(WebViewTest, PreferredSize) {
3733 std::string url = m_baseURL + "specify_size.html?100px:100px"; 3591 std::string url = m_baseURL + "specify_size.html?100px:100px";
3734 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 3592 URLTestHelpers::registerMockedURLLoad(
3593 toKURL(url), testing::webTestDataPath("specify_size.html"));
3735 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); 3594 WebView* webView = m_webViewHelper.initializeAndLoad(url, true);
3736 3595
3737 WebSize size = webView->contentsPreferredMinimumSize(); 3596 WebSize size = webView->contentsPreferredMinimumSize();
3738 EXPECT_EQ(100, size.width); 3597 EXPECT_EQ(100, size.width);
3739 EXPECT_EQ(100, size.height); 3598 EXPECT_EQ(100, size.height);
3740 3599
3741 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(2.0)); 3600 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(2.0));
3742 size = webView->contentsPreferredMinimumSize(); 3601 size = webView->contentsPreferredMinimumSize();
3743 EXPECT_EQ(200, size.width); 3602 EXPECT_EQ(200, size.width);
3744 EXPECT_EQ(200, size.height); 3603 EXPECT_EQ(200, size.height);
3745 3604
3746 // Verify that both width and height are rounded (in this case up) 3605 // Verify that both width and height are rounded (in this case up)
3747 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(0.9995)); 3606 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(0.9995));
3748 size = webView->contentsPreferredMinimumSize(); 3607 size = webView->contentsPreferredMinimumSize();
3749 EXPECT_EQ(100, size.width); 3608 EXPECT_EQ(100, size.width);
3750 EXPECT_EQ(100, size.height); 3609 EXPECT_EQ(100, size.height);
3751 3610
3752 // Verify that both width and height are rounded (in this case down) 3611 // Verify that both width and height are rounded (in this case down)
3753 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1.0005)); 3612 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1.0005));
3754 size = webView->contentsPreferredMinimumSize(); 3613 size = webView->contentsPreferredMinimumSize();
3755 EXPECT_EQ(100, size.width); 3614 EXPECT_EQ(100, size.width);
3756 EXPECT_EQ(100, size.height); 3615 EXPECT_EQ(100, size.height);
3757 3616
3758 url = m_baseURL + "specify_size.html?1.5px:1.5px"; 3617 url = m_baseURL + "specify_size.html?1.5px:1.5px";
3759 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 3618 URLTestHelpers::registerMockedURLLoad(
3619 toKURL(url), testing::webTestDataPath("specify_size.html"));
3760 webView = m_webViewHelper.initializeAndLoad(url, true); 3620 webView = m_webViewHelper.initializeAndLoad(url, true);
3761 3621
3762 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1)); 3622 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1));
3763 size = webView->contentsPreferredMinimumSize(); 3623 size = webView->contentsPreferredMinimumSize();
3764 EXPECT_EQ(2, size.width); 3624 EXPECT_EQ(2, size.width);
3765 EXPECT_EQ(2, size.height); 3625 EXPECT_EQ(2, size.height);
3766 } 3626 }
3767 3627
3768 TEST_P(WebViewTest, PreferredSizeDirtyLayout) { 3628 TEST_P(WebViewTest, PreferredSizeDirtyLayout) {
3769 std::string url = m_baseURL + "specify_size.html?100px:100px"; 3629 std::string url = m_baseURL + "specify_size.html?100px:100px";
3770 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 3630 URLTestHelpers::registerMockedURLLoad(
3631 toKURL(url), testing::webTestDataPath("specify_size.html"));
3771 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); 3632 WebView* webView = m_webViewHelper.initializeAndLoad(url, true);
3772 WebElement documentElement = 3633 WebElement documentElement =
3773 webView->mainFrame()->document().documentElement(); 3634 webView->mainFrame()->document().documentElement();
3774 3635
3775 WebSize size = webView->contentsPreferredMinimumSize(); 3636 WebSize size = webView->contentsPreferredMinimumSize();
3776 EXPECT_EQ(100, size.width); 3637 EXPECT_EQ(100, size.width);
3777 EXPECT_EQ(100, size.height); 3638 EXPECT_EQ(100, size.height);
3778 3639
3779 documentElement.setAttribute("style", "display: none"); 3640 documentElement.setAttribute("style", "display: none");
3780 3641
(...skipping 27 matching lines...) Expand all
3808 3669
3809 private: 3670 private:
3810 bool m_wasCalled = false; 3671 bool m_wasCalled = false;
3811 IntPoint m_tappedPosition; 3672 IntPoint m_tappedPosition;
3812 WebNode m_tappedNode; 3673 WebNode m_tappedNode;
3813 bool m_pageChanged = false; 3674 bool m_pageChanged = false;
3814 }; 3675 };
3815 3676
3816 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeeded) { 3677 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeeded) {
3817 std::string testFile = "show_unhandled_tap.html"; 3678 std::string testFile = "show_unhandled_tap.html";
3818 URLTestHelpers::registerMockedURLFromBaseURL( 3679 registerMockedHttpURLLoad("Ahem.ttf");
3819 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3680 registerMockedHttpURLLoad(testFile);
3820 URLTestHelpers::registerMockedURLFromBaseURL(
3821 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(testFile));
3822 UnhandledTapWebViewClient client; 3681 UnhandledTapWebViewClient client;
3823 WebView* webView = 3682 WebView* webView =
3824 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client); 3683 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client);
3825 webView->resize(WebSize(500, 300)); 3684 webView->resize(WebSize(500, 300));
3826 webView->updateAllLifecyclePhases(); 3685 webView->updateAllLifecyclePhases();
3827 runPendingTasks(); 3686 runPendingTasks();
3828 3687
3829 // Scroll the bottom into view so we can distinguish window coordinates from 3688 // Scroll the bottom into view so we can distinguish window coordinates from
3830 // document coordinates. 3689 // document coordinates.
3831 EXPECT_TRUE( 3690 EXPECT_TRUE(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3879 WebString::fromUTF8("target"))); \ 3738 WebString::fromUTF8("target"))); \
3880 EXPECT_##EXPECT(client.getPageChanged()); \ 3739 EXPECT_##EXPECT(client.getPageChanged()); \
3881 client.reset(); \ 3740 client.reset(); \
3882 frame->executeScript(WebScriptSource("setTest('click-" handler "');")); \ 3741 frame->executeScript(WebScriptSource("setTest('click-" handler "');")); \
3883 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, \ 3742 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, \
3884 WebString::fromUTF8("target"))); \ 3743 WebString::fromUTF8("target"))); \
3885 EXPECT_##EXPECT(client.getPageChanged()); 3744 EXPECT_##EXPECT(client.getPageChanged());
3886 3745
3887 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateDom) { 3746 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateDom) {
3888 std::string testFile = "show_unhandled_tap.html"; 3747 std::string testFile = "show_unhandled_tap.html";
3889 URLTestHelpers::registerMockedURLFromBaseURL( 3748 registerMockedHttpURLLoad("Ahem.ttf");
3890 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3749 registerMockedHttpURLLoad(testFile);
3891 URLTestHelpers::registerMockedURLFromBaseURL(
3892 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(testFile));
3893 UnhandledTapWebViewClient client; 3750 UnhandledTapWebViewClient client;
3894 WebViewImpl* webView = 3751 WebViewImpl* webView =
3895 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client); 3752 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client);
3896 webView->resize(WebSize(500, 300)); 3753 webView->resize(WebSize(500, 300));
3897 webView->updateAllLifecyclePhases(); 3754 webView->updateAllLifecyclePhases();
3898 runPendingTasks(); 3755 runPendingTasks();
3899 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3756 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3900 3757
3901 // Test dom mutation. 3758 // Test dom mutation.
3902 TEST_EACH_MOUSEEVENT("mutateDom", TRUE); 3759 TEST_EACH_MOUSEEVENT("mutateDom", TRUE);
3903 3760
3904 // Test without any DOM mutation. 3761 // Test without any DOM mutation.
3905 client.reset(); 3762 client.reset();
3906 frame->executeScript(WebScriptSource("setTest('none');")); 3763 frame->executeScript(WebScriptSource("setTest('none');"));
3907 EXPECT_TRUE( 3764 EXPECT_TRUE(
3908 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); 3765 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target")));
3909 EXPECT_FALSE(client.getPageChanged()); 3766 EXPECT_FALSE(client.getPageChanged());
3910 3767
3911 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 3768 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
3912 } 3769 }
3913 3770
3914 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateStyle) { 3771 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithMutateStyle) {
3915 std::string testFile = "show_unhandled_tap.html"; 3772 std::string testFile = "show_unhandled_tap.html";
3916 URLTestHelpers::registerMockedURLFromBaseURL( 3773 registerMockedHttpURLLoad("Ahem.ttf");
3917 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3774 registerMockedHttpURLLoad(testFile);
3918 URLTestHelpers::registerMockedURLFromBaseURL(
3919 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(testFile));
3920 UnhandledTapWebViewClient client; 3775 UnhandledTapWebViewClient client;
3921 WebViewImpl* webView = 3776 WebViewImpl* webView =
3922 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client); 3777 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client);
3923 webView->resize(WebSize(500, 300)); 3778 webView->resize(WebSize(500, 300));
3924 webView->updateAllLifecyclePhases(); 3779 webView->updateAllLifecyclePhases();
3925 runPendingTasks(); 3780 runPendingTasks();
3926 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3781 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3927 3782
3928 // Test style mutation. 3783 // Test style mutation.
3929 TEST_EACH_MOUSEEVENT("mutateStyle", TRUE); 3784 TEST_EACH_MOUSEEVENT("mutateStyle", TRUE);
(...skipping 12 matching lines...) Expand all
3942 frame->executeScript(WebScriptSource("setTest('none');")); 3797 frame->executeScript(WebScriptSource("setTest('none');"));
3943 EXPECT_TRUE( 3798 EXPECT_TRUE(
3944 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target"))); 3799 tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("target")));
3945 EXPECT_FALSE(client.getPageChanged()); 3800 EXPECT_FALSE(client.getPageChanged());
3946 3801
3947 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 3802 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
3948 } 3803 }
3949 3804
3950 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithPreventDefault) { 3805 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeededWithPreventDefault) {
3951 std::string testFile = "show_unhandled_tap.html"; 3806 std::string testFile = "show_unhandled_tap.html";
3952 URLTestHelpers::registerMockedURLFromBaseURL( 3807 registerMockedHttpURLLoad("Ahem.ttf");
3953 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf")); 3808 registerMockedHttpURLLoad(testFile);
3954 URLTestHelpers::registerMockedURLFromBaseURL(
3955 WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(testFile));
3956 UnhandledTapWebViewClient client; 3809 UnhandledTapWebViewClient client;
3957 WebViewImpl* webView = 3810 WebViewImpl* webView =
3958 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client); 3811 m_webViewHelper.initializeAndLoad(m_baseURL + testFile, true, 0, &client);
3959 webView->resize(WebSize(500, 300)); 3812 webView->resize(WebSize(500, 300));
3960 webView->updateAllLifecyclePhases(); 3813 webView->updateAllLifecyclePhases();
3961 runPendingTasks(); 3814 runPendingTasks();
3962 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3815 WebLocalFrameImpl* frame = webView->mainFrameImpl();
3963 3816
3964 // Testswallowing. 3817 // Testswallowing.
3965 TEST_EACH_MOUSEEVENT("preventDefault", FALSE); 3818 TEST_EACH_MOUSEEVENT("preventDefault", FALSE);
(...skipping 24 matching lines...) Expand all
3990 "var win = window.open('javascript:false'); win.document")); 3843 "var win = window.open('javascript:false'); win.document"));
3991 ASSERT_TRUE(v8Value->IsObject()); 3844 ASSERT_TRUE(v8Value->IsObject());
3992 Document* document = 3845 Document* document =
3993 V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent(), v8Value); 3846 V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent(), v8Value);
3994 ASSERT_TRUE(document); 3847 ASSERT_TRUE(document);
3995 EXPECT_FALSE(document->frame()->isLoading()); 3848 EXPECT_FALSE(document->frame()->isLoading());
3996 } 3849 }
3997 3850
3998 #if OS(MACOSX) 3851 #if OS(MACOSX)
3999 TEST_P(WebViewTest, WebSubstringUtil) { 3852 TEST_P(WebViewTest, WebSubstringUtil) {
4000 URLTestHelpers::registerMockedURLFromBaseURL( 3853 registerMockedHttpURLLoad("content_editable_populated.html");
4001 WebString::fromUTF8(m_baseURL.c_str()),
4002 WebString::fromUTF8("content_editable_populated.html"));
4003 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 3854 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
4004 m_baseURL + "content_editable_populated.html"); 3855 m_baseURL + "content_editable_populated.html");
4005 webView->settings()->setDefaultFontSize(12); 3856 webView->settings()->setDefaultFontSize(12);
4006 webView->resize(WebSize(400, 400)); 3857 webView->resize(WebSize(400, 400));
4007 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3858 WebLocalFrameImpl* frame = webView->mainFrameImpl();
4008 FrameView* frameView = frame->frame()->view(); 3859 FrameView* frameView = frame->frame()->view();
4009 3860
4010 WebPoint baselinePoint; 3861 WebPoint baselinePoint;
4011 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange( 3862 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(
4012 frame, 10, 3, &baselinePoint); 3863 frame, 10, 3, &baselinePoint);
(...skipping 10 matching lines...) Expand all
4023 WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baselinePoint); 3874 WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baselinePoint);
4024 ASSERT_TRUE(!!result); 3875 ASSERT_TRUE(!!result);
4025 3876
4026 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); 3877 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y);
4027 result = WebSubstringUtil::attributedWordAtPoint(frame->frameWidget(), point, 3878 result = WebSubstringUtil::attributedWordAtPoint(frame->frameWidget(), point,
4028 baselinePoint); 3879 baselinePoint);
4029 ASSERT_TRUE(!!result); 3880 ASSERT_TRUE(!!result);
4030 } 3881 }
4031 3882
4032 TEST_P(WebViewTest, WebSubstringUtilIframe) { 3883 TEST_P(WebViewTest, WebSubstringUtilIframe) {
4033 URLTestHelpers::registerMockedURLFromBaseURL( 3884 registerMockedHttpURLLoad("single_iframe.html");
4034 WebString::fromUTF8(m_baseURL.c_str()), 3885 registerMockedHttpURLLoad("visible_iframe.html");
4035 WebString::fromUTF8("single_iframe.html"));
4036 URLTestHelpers::registerMockedURLFromBaseURL(
4037 WebString::fromUTF8(m_baseURL.c_str()),
4038 WebString::fromUTF8("visible_iframe.html"));
4039 WebViewImpl* webView = 3886 WebViewImpl* webView =
4040 m_webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html"); 3887 m_webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html");
4041 webView->settings()->setDefaultFontSize(12); 3888 webView->settings()->setDefaultFontSize(12);
4042 webView->settings()->setJavaScriptEnabled(true); 3889 webView->settings()->setJavaScriptEnabled(true);
4043 webView->resize(WebSize(400, 400)); 3890 webView->resize(WebSize(400, 400));
4044 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); 3891 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl();
4045 WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame( 3892 WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame(
4046 toLocalFrame(mainFrame->frame()->tree().firstChild())); 3893 toLocalFrame(mainFrame->frame()->tree().firstChild()));
4047 3894
4048 WebPoint baselinePoint; 3895 WebPoint baselinePoint;
(...skipping 17 matching lines...) Expand all
4066 result = WebSubstringUtil::attributedWordAtPoint(mainFrame->frameWidget(), 3913 result = WebSubstringUtil::attributedWordAtPoint(mainFrame->frameWidget(),
4067 point, baselinePoint); 3914 point, baselinePoint);
4068 ASSERT_NE(result, nullptr); 3915 ASSERT_NE(result, nullptr);
4069 3916
4070 EXPECT_EQ(yBeforeChange, baselinePoint.y + 100); 3917 EXPECT_EQ(yBeforeChange, baselinePoint.y + 100);
4071 } 3918 }
4072 3919
4073 #endif 3920 #endif
4074 3921
4075 TEST_P(WebViewTest, PasswordFieldEditingIsUserGesture) { 3922 TEST_P(WebViewTest, PasswordFieldEditingIsUserGesture) {
4076 URLTestHelpers::registerMockedURLFromBaseURL( 3923 registerMockedHttpURLLoad("input_field_password.html");
4077 WebString::fromUTF8(m_baseURL.c_str()),
4078 WebString::fromUTF8("input_field_password.html"));
4079 MockAutofillClient client; 3924 MockAutofillClient client;
4080 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 3925 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
4081 m_baseURL + "input_field_password.html", true); 3926 m_baseURL + "input_field_password.html", true);
4082 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 3927 WebLocalFrameImpl* frame = webView->mainFrameImpl();
4083 frame->setAutofillClient(&client); 3928 frame->setAutofillClient(&client);
4084 webView->setInitialFocus(false); 3929 webView->setInitialFocus(false);
4085 3930
4086 WebVector<WebCompositionUnderline> emptyUnderlines; 3931 WebVector<WebCompositionUnderline> emptyUnderlines;
4087 3932
4088 EXPECT_TRUE( 3933 EXPECT_TRUE(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4189 // ...but not yet detached. 4034 // ...but not yet detached.
4190 EXPECT_TRUE(mainFrame->host()); 4035 EXPECT_TRUE(mainFrame->host());
4191 4036
4192 { 4037 {
4193 ScopedPageSuspender suspender; 4038 ScopedPageSuspender suspender;
4194 EXPECT_TRUE(page->suspended()); 4039 EXPECT_TRUE(page->suspended());
4195 } 4040 }
4196 } 4041 }
4197 4042
4198 TEST_P(WebViewTest, ForceAndResetViewport) { 4043 TEST_P(WebViewTest, ForceAndResetViewport) {
4199 URLTestHelpers::registerMockedURLFromBaseURL( 4044 registerMockedHttpURLLoad("200-by-300.html");
4200 WebString::fromUTF8(m_baseURL.c_str()),
4201 WebString::fromUTF8("200-by-300.html"));
4202 WebViewImpl* webViewImpl = 4045 WebViewImpl* webViewImpl =
4203 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 4046 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
4204 webViewImpl->resize(WebSize(100, 150)); 4047 webViewImpl->resize(WebSize(100, 150));
4205 webViewImpl->layerTreeView()->setViewportSize(WebSize(100, 150)); 4048 webViewImpl->layerTreeView()->setViewportSize(WebSize(100, 150));
4206 VisualViewport* visualViewport = 4049 VisualViewport* visualViewport =
4207 &webViewImpl->page()->frameHost().visualViewport(); 4050 &webViewImpl->page()->frameHost().visualViewport();
4208 DevToolsEmulator* devToolsEmulator = webViewImpl->devToolsEmulator(); 4051 DevToolsEmulator* devToolsEmulator = webViewImpl->devToolsEmulator();
4209 4052
4210 TransformationMatrix expectedMatrix; 4053 TransformationMatrix expectedMatrix;
4211 expectedMatrix.makeIdentity(); 4054 expectedMatrix.makeIdentity();
(...skipping 25 matching lines...) Expand all
4237 // visual viewport clipping. 4080 // visual viewport clipping.
4238 devToolsEmulator->resetViewport(); 4081 devToolsEmulator->resetViewport();
4239 expectedMatrix.makeIdentity(); 4082 expectedMatrix.makeIdentity();
4240 EXPECT_EQ(expectedMatrix, 4083 EXPECT_EQ(expectedMatrix,
4241 webViewImpl->getDeviceEmulationTransformForTesting()); 4084 webViewImpl->getDeviceEmulationTransformForTesting());
4242 EXPECT_FALSE(devToolsEmulator->visibleContentRectForPainting()); 4085 EXPECT_FALSE(devToolsEmulator->visibleContentRectForPainting());
4243 EXPECT_TRUE(visualViewport->containerLayer()->masksToBounds()); 4086 EXPECT_TRUE(visualViewport->containerLayer()->masksToBounds());
4244 } 4087 }
4245 4088
4246 TEST_P(WebViewTest, ViewportOverrideIntegratesDeviceMetricsOffsetAndScale) { 4089 TEST_P(WebViewTest, ViewportOverrideIntegratesDeviceMetricsOffsetAndScale) {
4247 URLTestHelpers::registerMockedURLFromBaseURL( 4090 registerMockedHttpURLLoad("200-by-300.html");
4248 WebString::fromUTF8(m_baseURL.c_str()),
4249 WebString::fromUTF8("200-by-300.html"));
4250 WebViewImpl* webViewImpl = 4091 WebViewImpl* webViewImpl =
4251 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 4092 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
4252 webViewImpl->resize(WebSize(100, 150)); 4093 webViewImpl->resize(WebSize(100, 150));
4253 4094
4254 TransformationMatrix expectedMatrix; 4095 TransformationMatrix expectedMatrix;
4255 expectedMatrix.makeIdentity(); 4096 expectedMatrix.makeIdentity();
4256 EXPECT_EQ(expectedMatrix, 4097 EXPECT_EQ(expectedMatrix,
4257 webViewImpl->getDeviceEmulationTransformForTesting()); 4098 webViewImpl->getDeviceEmulationTransformForTesting());
4258 4099
4259 WebDeviceEmulationParams emulationParams; 4100 WebDeviceEmulationParams emulationParams;
4260 emulationParams.offset = WebFloatPoint(50, 50); 4101 emulationParams.offset = WebFloatPoint(50, 50);
4261 emulationParams.scale = 2.f; 4102 emulationParams.scale = 2.f;
4262 webViewImpl->enableDeviceEmulation(emulationParams); 4103 webViewImpl->enableDeviceEmulation(emulationParams);
4263 expectedMatrix.makeIdentity().translate(50, 50).scale(2.f); 4104 expectedMatrix.makeIdentity().translate(50, 50).scale(2.f);
4264 EXPECT_EQ(expectedMatrix, 4105 EXPECT_EQ(expectedMatrix,
4265 webViewImpl->getDeviceEmulationTransformForTesting()); 4106 webViewImpl->getDeviceEmulationTransformForTesting());
4266 4107
4267 // Device metrics offset and scale are applied before viewport override. 4108 // Device metrics offset and scale are applied before viewport override.
4268 webViewImpl->devToolsEmulator()->forceViewport(WebFloatPoint(5, 10), 1.5f); 4109 webViewImpl->devToolsEmulator()->forceViewport(WebFloatPoint(5, 10), 1.5f);
4269 expectedMatrix.makeIdentity() 4110 expectedMatrix.makeIdentity()
4270 .scale(1.5f) 4111 .scale(1.5f)
4271 .translate(-5, -10) 4112 .translate(-5, -10)
4272 .translate(50, 50) 4113 .translate(50, 50)
4273 .scale(2.f); 4114 .scale(2.f);
4274 EXPECT_EQ(expectedMatrix, 4115 EXPECT_EQ(expectedMatrix,
4275 webViewImpl->getDeviceEmulationTransformForTesting()); 4116 webViewImpl->getDeviceEmulationTransformForTesting());
4276 } 4117 }
4277 4118
4278 TEST_P(WebViewTest, ViewportOverrideAdaptsToScaleAndScroll) { 4119 TEST_P(WebViewTest, ViewportOverrideAdaptsToScaleAndScroll) {
4279 URLTestHelpers::registerMockedURLFromBaseURL( 4120 registerMockedHttpURLLoad("200-by-300.html");
4280 WebString::fromUTF8(m_baseURL.c_str()),
4281 WebString::fromUTF8("200-by-300.html"));
4282 WebViewImpl* webViewImpl = 4121 WebViewImpl* webViewImpl =
4283 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 4122 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
4284 webViewImpl->resize(WebSize(100, 150)); 4123 webViewImpl->resize(WebSize(100, 150));
4285 webViewImpl->layerTreeView()->setViewportSize(WebSize(100, 150)); 4124 webViewImpl->layerTreeView()->setViewportSize(WebSize(100, 150));
4286 FrameView* frameView = webViewImpl->mainFrameImpl()->frame()->view(); 4125 FrameView* frameView = webViewImpl->mainFrameImpl()->frame()->view();
4287 DevToolsEmulator* devToolsEmulator = webViewImpl->devToolsEmulator(); 4126 DevToolsEmulator* devToolsEmulator = webViewImpl->devToolsEmulator();
4288 4127
4289 TransformationMatrix expectedMatrix; 4128 TransformationMatrix expectedMatrix;
4290 expectedMatrix.makeIdentity(); 4129 expectedMatrix.makeIdentity();
4291 EXPECT_EQ(expectedMatrix, 4130 EXPECT_EQ(expectedMatrix,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
4382 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); 4221 EXPECT_EQ(expectedWidth, vwElement->offsetWidth());
4383 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); 4222 EXPECT_EQ(expectedHeight, vwElement->offsetHeight());
4384 4223
4385 webView->resize(WebSize(800, 600)); 4224 webView->resize(WebSize(800, 600));
4386 frame->printEnd(); 4225 frame->printEnd();
4387 4226
4388 EXPECT_EQ(800, vwElement->offsetWidth()); 4227 EXPECT_EQ(800, vwElement->offsetWidth());
4389 } 4228 }
4390 4229
4391 } // namespace blink 4230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698