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