| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 5303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5314 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); | 5314 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); |
| 5315 registerMockedHttpURLLoad("Ahem.ttf"); | 5315 registerMockedHttpURLLoad("Ahem.ttf"); |
| 5316 | 5316 |
| 5317 m_webViewHelper.initialize(true, nullptr, &m_fakeSelectionWebViewClient, | 5317 m_webViewHelper.initialize(true, nullptr, &m_fakeSelectionWebViewClient, |
| 5318 nullptr); | 5318 nullptr); |
| 5319 m_webViewHelper.webView()->settings()->setDefaultFontSize(12); | 5319 m_webViewHelper.webView()->settings()->setDefaultFontSize(12); |
| 5320 m_webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); | 5320 m_webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); |
| 5321 m_webViewHelper.resize(WebSize(640, 480)); | 5321 m_webViewHelper.resize(WebSize(640, 480)); |
| 5322 } | 5322 } |
| 5323 | 5323 |
| 5324 void runTest(const char* testFile) { | 5324 void runTestWithNoSelection(const char* testFile) { |
| 5325 registerMockedHttpURLLoad(testFile); | 5325 registerMockedHttpURLLoad(testFile); |
| 5326 m_webViewHelper.webView()->setFocus(true); | 5326 m_webViewHelper.webView()->setFocus(true); |
| 5327 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), | 5327 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), |
| 5328 m_baseURL + testFile); | 5328 m_baseURL + testFile); |
| 5329 m_webViewHelper.webView()->updateAllLifecyclePhases(); | 5329 m_webViewHelper.webView()->updateAllLifecyclePhases(); |
| 5330 | 5330 |
| 5331 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection(); | 5331 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection(); |
| 5332 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.start(); | 5332 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.start(); |
| 5333 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); | 5333 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
| 5334 | 5334 |
| 5335 EXPECT_FALSE(selection); |
| 5336 EXPECT_FALSE(selectStart); |
| 5337 EXPECT_FALSE(selectEnd); |
| 5338 } |
| 5339 |
| 5340 void runTest(const char* testFile) { |
| 5341 registerMockedHttpURLLoad(testFile); |
| 5342 m_webViewHelper.webView()->setFocus(true); |
| 5343 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), |
| 5344 m_baseURL + testFile); |
| 5345 m_webViewHelper.webView()->updateAllLifecyclePhases(); |
| 5346 |
| 5335 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 5347 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 5336 v8::Local<v8::Value> result = | 5348 v8::Local<v8::Value> result = |
| 5337 m_webViewHelper.webView()->mainFrameImpl()->executeScriptAndReturnValue( | 5349 m_webViewHelper.webView()->mainFrameImpl()->executeScriptAndReturnValue( |
| 5338 WebScriptSource("expectedResult")); | 5350 WebScriptSource("expectedResult")); |
| 5339 if (result.IsEmpty() || (*result)->IsUndefined()) { | 5351 ASSERT_FALSE(result.IsEmpty() || (*result)->IsUndefined()); |
| 5340 EXPECT_FALSE(selection); | 5352 |
| 5341 EXPECT_FALSE(selectStart); | 5353 ASSERT_TRUE((*result)->IsArray()); |
| 5342 EXPECT_FALSE(selectEnd); | 5354 v8::Array& expectedResult = *v8::Array::Cast(*result); |
| 5343 return; | 5355 ASSERT_GE(expectedResult.Length(), 10u); |
| 5344 } | 5356 |
| 5357 v8::Local<v8::Context> context = |
| 5358 v8::Isolate::GetCurrent()->GetCurrentContext(); |
| 5359 |
| 5360 int startEdgeTopInLayerX = expectedResult.Get(context, 1) |
| 5361 .ToLocalChecked() |
| 5362 .As<v8::Int32>() |
| 5363 ->Value(); |
| 5364 int startEdgeTopInLayerY = expectedResult.Get(context, 2) |
| 5365 .ToLocalChecked() |
| 5366 .As<v8::Int32>() |
| 5367 ->Value(); |
| 5368 int startEdgeBottomInLayerX = expectedResult.Get(context, 3) |
| 5369 .ToLocalChecked() |
| 5370 .As<v8::Int32>() |
| 5371 ->Value(); |
| 5372 int startEdgeBottomInLayerY = expectedResult.Get(context, 4) |
| 5373 .ToLocalChecked() |
| 5374 .As<v8::Int32>() |
| 5375 ->Value(); |
| 5376 |
| 5377 int endEdgeTopInLayerX = expectedResult.Get(context, 6) |
| 5378 .ToLocalChecked() |
| 5379 .As<v8::Int32>() |
| 5380 ->Value(); |
| 5381 int endEdgeTopInLayerY = expectedResult.Get(context, 7) |
| 5382 .ToLocalChecked() |
| 5383 .As<v8::Int32>() |
| 5384 ->Value(); |
| 5385 int endEdgeBottomInLayerX = expectedResult.Get(context, 8) |
| 5386 .ToLocalChecked() |
| 5387 .As<v8::Int32>() |
| 5388 ->Value(); |
| 5389 int endEdgeBottomInLayerY = expectedResult.Get(context, 9) |
| 5390 .ToLocalChecked() |
| 5391 .As<v8::Int32>() |
| 5392 ->Value(); |
| 5393 |
| 5394 IntPoint hitPoint = |
| 5395 IntPoint((startEdgeTopInLayerX + startEdgeBottomInLayerX + |
| 5396 endEdgeTopInLayerX + endEdgeBottomInLayerX) / |
| 5397 4, |
| 5398 (startEdgeTopInLayerY + startEdgeBottomInLayerY + |
| 5399 endEdgeTopInLayerY + endEdgeBottomInLayerY) / |
| 5400 4 + |
| 5401 3); |
| 5402 |
| 5403 PlatformGestureEvent gestureEvent( |
| 5404 PlatformEvent::EventType::GestureTap, hitPoint, hitPoint, IntSize(0, 0), |
| 5405 0, PlatformEvent::NoModifiers, PlatformGestureSourceTouchscreen); |
| 5406 m_webViewHelper.webView() |
| 5407 ->mainFrameImpl() |
| 5408 ->frame() |
| 5409 ->eventHandler() |
| 5410 .handleGestureEvent(gestureEvent); |
| 5411 |
| 5412 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection(); |
| 5413 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.start(); |
| 5414 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
| 5345 | 5415 |
| 5346 ASSERT_TRUE(selection); | 5416 ASSERT_TRUE(selection); |
| 5347 ASSERT_TRUE(selectStart); | 5417 ASSERT_TRUE(selectStart); |
| 5348 ASSERT_TRUE(selectEnd); | 5418 ASSERT_TRUE(selectEnd); |
| 5349 | 5419 |
| 5350 EXPECT_FALSE(selection->isNone()); | 5420 EXPECT_FALSE(selection->isNone()); |
| 5351 | 5421 |
| 5352 ASSERT_TRUE((*result)->IsArray()); | |
| 5353 v8::Array& expectedResult = *v8::Array::Cast(*result); | |
| 5354 ASSERT_GE(expectedResult.Length(), 10u); | |
| 5355 | |
| 5356 blink::Node* layerOwnerNodeForStart = V8Node::toImplWithTypeCheck( | 5422 blink::Node* layerOwnerNodeForStart = V8Node::toImplWithTypeCheck( |
| 5357 v8::Isolate::GetCurrent(), expectedResult.Get(0)); | 5423 v8::Isolate::GetCurrent(), expectedResult.Get(0)); |
| 5358 ASSERT_TRUE(layerOwnerNodeForStart); | 5424 ASSERT_TRUE(layerOwnerNodeForStart); |
| 5359 EXPECT_EQ(layerOwnerNodeForStart->layoutObject() | 5425 EXPECT_EQ(layerOwnerNodeForStart->layoutObject() |
| 5360 ->enclosingLayer() | 5426 ->enclosingLayer() |
| 5361 ->enclosingLayerForPaintInvalidation() | 5427 ->enclosingLayerForPaintInvalidation() |
| 5362 ->graphicsLayerBacking() | 5428 ->graphicsLayerBacking() |
| 5363 ->platformLayer() | 5429 ->platformLayer() |
| 5364 ->id(), | 5430 ->id(), |
| 5365 selectStart->layerId); | 5431 selectStart->layerId); |
| 5366 v8::Local<v8::Context> context = | 5432 |
| 5367 v8::Isolate::GetCurrent()->GetCurrentContext(); | 5433 EXPECT_EQ(startEdgeTopInLayerX, selectStart->edgeTopInLayer.x); |
| 5368 EXPECT_EQ(expectedResult.Get(context, 1) | 5434 EXPECT_EQ(startEdgeTopInLayerY, selectStart->edgeTopInLayer.y); |
| 5369 .ToLocalChecked() | 5435 EXPECT_EQ(startEdgeBottomInLayerX, selectStart->edgeBottomInLayer.x); |
| 5370 .As<v8::Int32>() | |
| 5371 ->Value(), | |
| 5372 selectStart->edgeTopInLayer.x); | |
| 5373 EXPECT_EQ(expectedResult.Get(context, 2) | |
| 5374 .ToLocalChecked() | |
| 5375 .As<v8::Int32>() | |
| 5376 ->Value(), | |
| 5377 selectStart->edgeTopInLayer.y); | |
| 5378 EXPECT_EQ(expectedResult.Get(context, 3) | |
| 5379 .ToLocalChecked() | |
| 5380 .As<v8::Int32>() | |
| 5381 ->Value(), | |
| 5382 selectStart->edgeBottomInLayer.x); | |
| 5383 | 5436 |
| 5384 blink::Node* layerOwnerNodeForEnd = V8Node::toImplWithTypeCheck( | 5437 blink::Node* layerOwnerNodeForEnd = V8Node::toImplWithTypeCheck( |
| 5385 v8::Isolate::GetCurrent(), | 5438 v8::Isolate::GetCurrent(), |
| 5386 expectedResult.Get(context, 5).ToLocalChecked()); | 5439 expectedResult.Get(context, 5).ToLocalChecked()); |
| 5387 | 5440 |
| 5388 ASSERT_TRUE(layerOwnerNodeForEnd); | 5441 ASSERT_TRUE(layerOwnerNodeForEnd); |
| 5389 EXPECT_EQ(layerOwnerNodeForEnd->layoutObject() | 5442 EXPECT_EQ(layerOwnerNodeForEnd->layoutObject() |
| 5390 ->enclosingLayer() | 5443 ->enclosingLayer() |
| 5391 ->enclosingLayerForPaintInvalidation() | 5444 ->enclosingLayerForPaintInvalidation() |
| 5392 ->graphicsLayerBacking() | 5445 ->graphicsLayerBacking() |
| 5393 ->platformLayer() | 5446 ->platformLayer() |
| 5394 ->id(), | 5447 ->id(), |
| 5395 selectEnd->layerId); | 5448 selectEnd->layerId); |
| 5396 EXPECT_EQ(expectedResult.Get(context, 6) | 5449 |
| 5397 .ToLocalChecked() | 5450 EXPECT_EQ(endEdgeTopInLayerX, selectEnd->edgeTopInLayer.x); |
| 5398 .As<v8::Int32>() | 5451 EXPECT_EQ(endEdgeTopInLayerY, selectEnd->edgeTopInLayer.y); |
| 5399 ->Value(), | 5452 EXPECT_EQ(endEdgeBottomInLayerX, selectEnd->edgeBottomInLayer.x); |
| 5400 selectEnd->edgeTopInLayer.x); | |
| 5401 EXPECT_EQ(expectedResult.Get(context, 7) | |
| 5402 .ToLocalChecked() | |
| 5403 .As<v8::Int32>() | |
| 5404 ->Value(), | |
| 5405 selectEnd->edgeTopInLayer.y); | |
| 5406 EXPECT_EQ(expectedResult.Get(context, 8) | |
| 5407 .ToLocalChecked() | |
| 5408 .As<v8::Int32>() | |
| 5409 ->Value(), | |
| 5410 selectEnd->edgeBottomInLayer.x); | |
| 5411 | 5453 |
| 5412 // Platform differences can introduce small stylistic deviations in | 5454 // Platform differences can introduce small stylistic deviations in |
| 5413 // y-axis positioning, the details of which aren't relevant to | 5455 // y-axis positioning, the details of which aren't relevant to |
| 5414 // selection behavior. However, such deviations from the expected value | 5456 // selection behavior. However, such deviations from the expected value |
| 5415 // should be consistent for the corresponding y coordinates. | 5457 // should be consistent for the corresponding y coordinates. |
| 5416 int yBottomEpsilon = 0; | 5458 int yBottomEpsilon = 0; |
| 5417 if (expectedResult.Length() == 13) | 5459 if (expectedResult.Length() == 13) |
| 5418 yBottomEpsilon = expectedResult.Get(context, 12) | 5460 yBottomEpsilon = expectedResult.Get(context, 12) |
| 5419 .ToLocalChecked() | 5461 .ToLocalChecked() |
| 5420 .As<v8::Int32>() | 5462 .As<v8::Int32>() |
| 5421 ->Value(); | 5463 ->Value(); |
| 5422 int yBottomDeviation = expectedResult.Get(context, 4) | 5464 int yBottomDeviation = |
| 5423 .ToLocalChecked() | 5465 startEdgeBottomInLayerY - selectStart->edgeBottomInLayer.y; |
| 5424 .As<v8::Int32>() | |
| 5425 ->Value() - | |
| 5426 selectStart->edgeBottomInLayer.y; | |
| 5427 EXPECT_GE(yBottomEpsilon, std::abs(yBottomDeviation)); | 5466 EXPECT_GE(yBottomEpsilon, std::abs(yBottomDeviation)); |
| 5428 EXPECT_EQ(yBottomDeviation, expectedResult.Get(context, 9) | 5467 EXPECT_EQ(yBottomDeviation, |
| 5429 .ToLocalChecked() | 5468 endEdgeBottomInLayerY - selectEnd->edgeBottomInLayer.y); |
| 5430 .As<v8::Int32>() | |
| 5431 ->Value() - | |
| 5432 selectEnd->edgeBottomInLayer.y); | |
| 5433 | 5469 |
| 5434 if (expectedResult.Length() >= 12) { | 5470 if (expectedResult.Length() >= 12) { |
| 5435 EXPECT_EQ(expectedResult.Get(context, 10) | 5471 EXPECT_EQ(expectedResult.Get(context, 10) |
| 5436 .ToLocalChecked() | 5472 .ToLocalChecked() |
| 5437 .As<v8::Boolean>() | 5473 .As<v8::Boolean>() |
| 5438 ->Value(), | 5474 ->Value(), |
| 5439 m_fakeSelectionLayerTreeView.selection()->isEditable()); | 5475 m_fakeSelectionLayerTreeView.selection()->isEditable()); |
| 5440 EXPECT_EQ( | 5476 EXPECT_EQ( |
| 5441 expectedResult.Get(context, 11) | 5477 expectedResult.Get(context, 11) |
| 5442 .ToLocalChecked() | 5478 .ToLocalChecked() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5455 | 5491 |
| 5456 runTest(testFile); | 5492 runTest(testFile); |
| 5457 } | 5493 } |
| 5458 | 5494 |
| 5459 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; | 5495 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; |
| 5460 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; | 5496 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; |
| 5461 FrameTestHelpers::WebViewHelper m_webViewHelper; | 5497 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 5462 }; | 5498 }; |
| 5463 | 5499 |
| 5464 TEST_F(CompositedSelectionBoundsTest, None) { | 5500 TEST_F(CompositedSelectionBoundsTest, None) { |
| 5465 runTest("composited_selection_bounds_none.html"); | 5501 runTestWithNoSelection("composited_selection_bounds_none.html"); |
| 5466 } | 5502 } |
| 5467 TEST_F(CompositedSelectionBoundsTest, NoneReadonlyCaret) { | 5503 TEST_F(CompositedSelectionBoundsTest, NoneReadonlyCaret) { |
| 5468 runTest("composited_selection_bounds_none_readonly_caret.html"); | 5504 runTestWithNoSelection( |
| 5505 "composited_selection_bounds_none_readonly_caret.html"); |
| 5469 } | 5506 } |
| 5507 TEST_F(CompositedSelectionBoundsTest, DetachedFrame) { |
| 5508 runTestWithNoSelection("composited_selection_bounds_detached_frame.html"); |
| 5509 } |
| 5510 |
| 5470 TEST_F(CompositedSelectionBoundsTest, Basic) { | 5511 TEST_F(CompositedSelectionBoundsTest, Basic) { |
| 5471 runTest("composited_selection_bounds_basic.html"); | 5512 runTest("composited_selection_bounds_basic.html"); |
| 5472 } | 5513 } |
| 5473 TEST_F(CompositedSelectionBoundsTest, Transformed) { | 5514 TEST_F(CompositedSelectionBoundsTest, Transformed) { |
| 5474 runTest("composited_selection_bounds_transformed.html"); | 5515 runTest("composited_selection_bounds_transformed.html"); |
| 5475 } | 5516 } |
| 5476 TEST_F(CompositedSelectionBoundsTest, VerticalRightToLeft) { | 5517 TEST_F(CompositedSelectionBoundsTest, VerticalRightToLeft) { |
| 5477 runTest("composited_selection_bounds_vertical_rl.html"); | 5518 runTest("composited_selection_bounds_vertical_rl.html"); |
| 5478 } | 5519 } |
| 5479 TEST_F(CompositedSelectionBoundsTest, VerticalLeftToRight) { | 5520 TEST_F(CompositedSelectionBoundsTest, VerticalLeftToRight) { |
| 5480 runTest("composited_selection_bounds_vertical_lr.html"); | 5521 runTest("composited_selection_bounds_vertical_lr.html"); |
| 5481 } | 5522 } |
| 5482 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { | 5523 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { |
| 5483 runTest("composited_selection_bounds_split_layer.html"); | 5524 runTest("composited_selection_bounds_split_layer.html"); |
| 5484 } | 5525 } |
| 5485 TEST_F(CompositedSelectionBoundsTest, EmptyLayer) { | |
| 5486 runTest("composited_selection_bounds_empty_layer.html"); | |
| 5487 } | |
| 5488 TEST_F(CompositedSelectionBoundsTest, Iframe) { | 5526 TEST_F(CompositedSelectionBoundsTest, Iframe) { |
| 5489 runTestWithMultipleFiles("composited_selection_bounds_iframe.html", | 5527 runTestWithMultipleFiles("composited_selection_bounds_iframe.html", |
| 5490 "composited_selection_bounds_basic.html", nullptr); | 5528 "composited_selection_bounds_basic.html", nullptr); |
| 5491 } | 5529 } |
| 5492 TEST_F(CompositedSelectionBoundsTest, DetachedFrame) { | |
| 5493 runTest("composited_selection_bounds_detached_frame.html"); | |
| 5494 } | |
| 5495 TEST_F(CompositedSelectionBoundsTest, Editable) { | 5530 TEST_F(CompositedSelectionBoundsTest, Editable) { |
| 5496 runTest("composited_selection_bounds_editable.html"); | 5531 runTest("composited_selection_bounds_editable.html"); |
| 5497 } | 5532 } |
| 5498 TEST_F(CompositedSelectionBoundsTest, EditableDiv) { | 5533 TEST_F(CompositedSelectionBoundsTest, EditableDiv) { |
| 5499 runTest("composited_selection_bounds_editable_div.html"); | 5534 runTest("composited_selection_bounds_editable_div.html"); |
| 5500 } | 5535 } |
| 5501 TEST_F(CompositedSelectionBoundsTest, EmptyEditableInput) { | |
| 5502 runTest("composited_selection_bounds_empty_editable_input.html"); | |
| 5503 } | |
| 5504 TEST_F(CompositedSelectionBoundsTest, EmptyEditableArea) { | |
| 5505 runTest("composited_selection_bounds_empty_editable_area.html"); | |
| 5506 } | |
| 5507 | |
| 5508 // Fails on Mac ASan 64 bot. https://crbug.com/588769. | |
| 5509 #if OS(MACOSX) && defined(ADDRESS_SANITIZER) | |
| 5510 TEST_P(ParameterizedWebFrameTest, DISABLED_CompositedSelectionBoundsCleared) | |
| 5511 #else | |
| 5512 TEST_P(ParameterizedWebFrameTest, CompositedSelectionBoundsCleared) | |
| 5513 #endif | |
| 5514 { | |
| 5515 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); | |
| 5516 | |
| 5517 registerMockedHttpURLLoad("select_range_basic.html"); | |
| 5518 registerMockedHttpURLLoad("select_range_scroll.html"); | |
| 5519 | |
| 5520 int viewWidth = 500; | |
| 5521 int viewHeight = 500; | |
| 5522 | |
| 5523 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; | |
| 5524 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = | |
| 5525 fakeSelectionWebViewClient.selectionLayerTreeView(); | |
| 5526 | |
| 5527 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 5528 webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr); | |
| 5529 webViewHelper.webView()->settings()->setDefaultFontSize(12); | |
| 5530 webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); | |
| 5531 webViewHelper.resize(WebSize(viewWidth, viewHeight)); | |
| 5532 webViewHelper.webView()->setFocus(true); | |
| 5533 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | |
| 5534 m_baseURL + "select_range_basic.html"); | |
| 5535 | |
| 5536 // The frame starts with no selection. | |
| 5537 WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl(); | |
| 5538 ASSERT_TRUE(frame->hasSelection()); | |
| 5539 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5540 | |
| 5541 // The selection cleared notification should be triggered upon layout. | |
| 5542 frame->executeCommand(WebString::fromUTF8("Unselect")); | |
| 5543 ASSERT_FALSE(frame->hasSelection()); | |
| 5544 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5545 webViewHelper.webView()->updateAllLifecyclePhases(); | |
| 5546 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5547 | |
| 5548 frame->executeCommand(WebString::fromUTF8("SelectAll")); | |
| 5549 webViewHelper.webView()->updateAllLifecyclePhases(); | |
| 5550 ASSERT_TRUE(frame->hasSelection()); | |
| 5551 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5552 | |
| 5553 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | |
| 5554 m_baseURL + "select_range_scroll.html"); | |
| 5555 ASSERT_TRUE(frame->hasSelection()); | |
| 5556 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5557 | |
| 5558 // Transitions between non-empty selections should not trigger a clearing. | |
| 5559 WebRect startWebRect; | |
| 5560 WebRect endWebRect; | |
| 5561 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); | |
| 5562 WebPoint movedEnd(bottomRightMinusOne(endWebRect)); | |
| 5563 endWebRect.x -= 20; | |
| 5564 frame->selectRange(topLeft(startWebRect), movedEnd); | |
| 5565 webViewHelper.webView()->updateAllLifecyclePhases(); | |
| 5566 ASSERT_TRUE(frame->hasSelection()); | |
| 5567 EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5568 | |
| 5569 frame = webViewHelper.webView()->mainFrameImpl(); | |
| 5570 frame->executeCommand(WebString::fromUTF8("Unselect")); | |
| 5571 webViewHelper.webView()->updateAllLifecyclePhases(); | |
| 5572 ASSERT_FALSE(frame->hasSelection()); | |
| 5573 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | |
| 5574 } | |
| 5575 | 5536 |
| 5576 class DisambiguationPopupTestWebViewClient | 5537 class DisambiguationPopupTestWebViewClient |
| 5577 : public FrameTestHelpers::TestWebViewClient { | 5538 : public FrameTestHelpers::TestWebViewClient { |
| 5578 public: | 5539 public: |
| 5579 bool didTapMultipleTargets(const WebSize&, | 5540 bool didTapMultipleTargets(const WebSize&, |
| 5580 const WebRect&, | 5541 const WebRect&, |
| 5581 const WebVector<WebRect>& targetRects) override { | 5542 const WebVector<WebRect>& targetRects) override { |
| 5582 EXPECT_GE(targetRects.size(), 2u); | 5543 EXPECT_GE(targetRects.size(), 2u); |
| 5583 m_triggered = true; | 5544 m_triggered = true; |
| 5584 return true; | 5545 return true; |
| (...skipping 4579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10164 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); | 10125 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); |
| 10165 | 10126 |
| 10166 Document* document = | 10127 Document* document = |
| 10167 toLocalFrame(helper.webView()->page()->mainFrame())->document(); | 10128 toLocalFrame(helper.webView()->page()->mainFrame())->document(); |
| 10168 EXPECT_TRUE(document->isImageDocument()); | 10129 EXPECT_TRUE(document->isImageDocument()); |
| 10169 EXPECT_EQ(Resource::DecodeError, | 10130 EXPECT_EQ(Resource::DecodeError, |
| 10170 toImageDocument(document)->cachedImage()->getStatus()); | 10131 toImageDocument(document)->cachedImage()->getStatus()); |
| 10171 } | 10132 } |
| 10172 | 10133 |
| 10173 } // namespace blink | 10134 } // namespace blink |
| OLD | NEW |