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

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

Issue 2389073002: Fix link's hover state if the link under scrollbar (Closed)
Patch Set: Merge patch-2467693002 to fix testcase failed in OSX Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "core/loader/DocumentThreadableLoader.h" 72 #include "core/loader/DocumentThreadableLoader.h"
73 #include "core/loader/DocumentThreadableLoaderClient.h" 73 #include "core/loader/DocumentThreadableLoaderClient.h"
74 #include "core/loader/FrameLoadRequest.h" 74 #include "core/loader/FrameLoadRequest.h"
75 #include "core/loader/ThreadableLoader.h" 75 #include "core/loader/ThreadableLoader.h"
76 #include "core/page/Page.h" 76 #include "core/page/Page.h"
77 #include "core/page/ScopedPageLoadDeferrer.h" 77 #include "core/page/ScopedPageLoadDeferrer.h"
78 #include "core/paint/PaintLayer.h" 78 #include "core/paint/PaintLayer.h"
79 #include "core/testing/NullExecutionContext.h" 79 #include "core/testing/NullExecutionContext.h"
80 #include "modules/mediastream/MediaStream.h" 80 #include "modules/mediastream/MediaStream.h"
81 #include "modules/mediastream/MediaStreamRegistry.h" 81 #include "modules/mediastream/MediaStreamRegistry.h"
82 #include "platform/Cursor.h"
82 #include "platform/DragImage.h" 83 #include "platform/DragImage.h"
84 #include "platform/PlatformMouseEvent.h"
83 #include "platform/PlatformResourceLoader.h" 85 #include "platform/PlatformResourceLoader.h"
84 #include "platform/RuntimeEnabledFeatures.h" 86 #include "platform/RuntimeEnabledFeatures.h"
85 #include "platform/UserGestureIndicator.h" 87 #include "platform/UserGestureIndicator.h"
86 #include "platform/geometry/FloatRect.h" 88 #include "platform/geometry/FloatRect.h"
87 #include "platform/network/ResourceError.h" 89 #include "platform/network/ResourceError.h"
90 #include "platform/scroll/Scrollbar.h"
91 #include "platform/scroll/ScrollbarTestSuite.h"
88 #include "platform/scroll/ScrollbarTheme.h" 92 #include "platform/scroll/ScrollbarTheme.h"
93 #include "platform/scroll/ScrollbarThemeMock.h"
89 #include "platform/scroll/ScrollbarThemeOverlayMock.h" 94 #include "platform/scroll/ScrollbarThemeOverlayMock.h"
90 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 95 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
91 #include "platform/testing/URLTestHelpers.h" 96 #include "platform/testing/URLTestHelpers.h"
92 #include "platform/testing/UnitTestHelpers.h" 97 #include "platform/testing/UnitTestHelpers.h"
93 #include "platform/weborigin/KURLHash.h" 98 #include "platform/weborigin/KURLHash.h"
94 #include "platform/weborigin/SchemeRegistry.h" 99 #include "platform/weborigin/SchemeRegistry.h"
95 #include "platform/weborigin/SecurityOrigin.h" 100 #include "platform/weborigin/SecurityOrigin.h"
96 #include "public/platform/Platform.h" 101 #include "public/platform/Platform.h"
97 #include "public/platform/WebCachePolicy.h" 102 #include "public/platform/WebCachePolicy.h"
98 #include "public/platform/WebClipboard.h" 103 #include "public/platform/WebClipboard.h"
(...skipping 10240 matching lines...) Expand 10 before | Expand all | Expand 10 after
10339 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); 10344 EXPECT_TRUE(frameView->verticalScrollbar()->enabled());
10340 10345
10341 scrollerArea->setScrollbarsHidden(true); 10346 scrollerArea->setScrollbarsHidden(true);
10342 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); 10347 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled());
10343 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); 10348 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled());
10344 scrollerArea->setScrollbarsHidden(false); 10349 scrollerArea->setScrollbarsHidden(false);
10345 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); 10350 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled());
10346 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); 10351 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled());
10347 } 10352 }
10348 10353
10354 // Makes sure that mouse hover over an overlay scrollbar doesn't activate
10355 // elements below unless the scrollbar is faded out.
10356 TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) {
10357 FrameTestHelpers::WebViewHelper webViewHelper;
10358 webViewHelper.initialize(
10359 true, nullptr, nullptr, nullptr,
10360 [](WebSettings* settings) { settings->setDeviceSupportsMouse(true); });
10361 webViewHelper.resize(WebSize(20, 20));
10362 WebViewImpl* webView = webViewHelper.webView();
10363
10364 initializeWithHTML(*webView->mainFrameImpl()->frame(),
10365 "<!DOCTYPE html>"
10366 "<a id='a' href='javascript:void(0);'>"
10367 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10368 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10369 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10370 "</a>"
10371 "<div style='position: absolute; top: 1000px'>end</div>");
10372
10373 webView->updateAllLifecyclePhases();
10374
10375 Document* document = webView->mainFrameImpl()->frame()->document();
10376 Element* aTag = document->getElementById("a");
10377
10378 // Ensure hittest has scrollbar and link
10379 HitTestResult hitTestResult =
10380 webView->coreHitTestResultAt(WebPoint(18, aTag->offsetTop()));
10381
10382 EXPECT_TRUE(hitTestResult.URLElement());
10383 EXPECT_TRUE(hitTestResult.innerElement());
10384 EXPECT_TRUE(hitTestResult.scrollbar());
10385
10386 // Mouse over link. Mouse cursor should be hand.
10387 PlatformMouseEvent mouseMoveOverLinkEvent(
10388 IntPoint(aTag->offsetLeft(), aTag->offsetTop()),
10389 IntPoint(aTag->offsetLeft(), aTag->offsetTop()),
10390 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0,
10391 PlatformEvent::NoModifiers, WTF::monotonicallyIncreasingTime());
10392 document->frame()->eventHandler().handleMouseMoveEvent(
10393 mouseMoveOverLinkEvent);
10394
10395 EXPECT_EQ(
10396 Cursor::Type::Hand,
10397 document->frame()->chromeClient().lastSetCursorForTesting().getType());
10398
10399 // Mouse over enabled overlay scrollbar. Mouse cursor should be pointer and no
10400 // active hover element.
10401 PlatformMouseEvent mouseMoveEvent(
10402 IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()),
10403 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0,
10404 PlatformEvent::NoModifiers, WTF::monotonicallyIncreasingTime());
10405 document->frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
10406
10407 EXPECT_EQ(
10408 Cursor::Type::Pointer,
10409 document->frame()->chromeClient().lastSetCursorForTesting().getType());
10410
10411 PlatformMouseEvent mousePressEvent(
10412 IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()),
10413 WebPointerProperties::Button::Left, PlatformEvent::MousePressed, 0,
10414 PlatformEvent::Modifiers::LeftButtonDown,
10415 WTF::monotonicallyIncreasingTime());
10416 document->frame()->eventHandler().handleMousePressEvent(mousePressEvent);
10417
10418 EXPECT_FALSE(document->activeHoverElement());
10419 EXPECT_FALSE(document->hoverNode());
10420
10421 PlatformMouseEvent MouseReleaseEvent(
10422 IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()),
10423 WebPointerProperties::Button::Left, PlatformEvent::MouseReleased, 0,
10424 PlatformEvent::Modifiers::LeftButtonDown,
10425 WTF::monotonicallyIncreasingTime());
10426 document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent);
10427
10428 // Mouse over disabled overlay scrollbar. Mouse cursor should be hand and has
10429 // active hover element.
10430 webView->mainFrameImpl()->frameView()->setScrollbarsHidden(true);
10431
10432 // Ensure hittest only has link
10433 hitTestResult = webView->coreHitTestResultAt(WebPoint(18, aTag->offsetTop()));
10434
10435 EXPECT_TRUE(hitTestResult.URLElement());
10436 EXPECT_TRUE(hitTestResult.innerElement());
10437 EXPECT_FALSE(hitTestResult.scrollbar());
10438
10439 document->frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
10440
10441 EXPECT_EQ(
10442 Cursor::Type::Hand,
10443 document->frame()->chromeClient().lastSetCursorForTesting().getType());
10444
10445 document->frame()->eventHandler().handleMousePressEvent(mousePressEvent);
10446
10447 EXPECT_TRUE(document->activeHoverElement());
10448 EXPECT_TRUE(document->hoverNode());
10449
10450 document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent);
10451 }
10349 static void disableCompositing(WebSettings* settings) { 10452 static void disableCompositing(WebSettings* settings) {
10350 settings->setAcceleratedCompositingEnabled(false); 10453 settings->setAcceleratedCompositingEnabled(false);
10351 settings->setPreferCompositingToLCDTextEnabled(false); 10454 settings->setPreferCompositingToLCDTextEnabled(false);
10352 } 10455 }
10353 10456
10354 // Make sure overlay scrollbars on non-composited scrollers fade out and set 10457 // Make sure overlay scrollbars on non-composited scrollers fade out and set
10355 // the hidden bit as needed. 10458 // the hidden bit as needed.
10356 TEST_F(WebFrameTest, TestNonCompositedOverlayScrollbarsFade) { 10459 TEST_F(WebFrameTest, TestNonCompositedOverlayScrollbarsFade) {
10357 FrameTestHelpers::WebViewHelper webViewHelper; 10460 FrameTestHelpers::WebViewHelper webViewHelper;
10358 WebViewImpl* webViewImpl = webViewHelper.initialize( 10461 WebViewImpl* webViewImpl = webViewHelper.initialize(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
10437 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); 10540 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame();
10438 HashSet<AtomicString> names; 10541 HashSet<AtomicString> names;
10439 for (Frame* frame = mainFrame->tree().firstChild(); frame; 10542 for (Frame* frame = mainFrame->tree().firstChild(); frame;
10440 frame = frame->tree().traverseNext()) { 10543 frame = frame->tree().traverseNext()) {
10441 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); 10544 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry);
10442 } 10545 }
10443 EXPECT_EQ(10u, names.size()); 10546 EXPECT_EQ(10u, names.size());
10444 } 10547 }
10445 10548
10446 } // namespace blink 10549 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698