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