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

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: fix for bokan's comments 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
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/testing/RuntimeEnabledFeaturesTestHelpers.h" 94 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
90 #include "platform/testing/URLTestHelpers.h" 95 #include "platform/testing/URLTestHelpers.h"
91 #include "platform/testing/UnitTestHelpers.h" 96 #include "platform/testing/UnitTestHelpers.h"
92 #include "platform/weborigin/KURLHash.h" 97 #include "platform/weborigin/KURLHash.h"
93 #include "platform/weborigin/SchemeRegistry.h" 98 #include "platform/weborigin/SchemeRegistry.h"
94 #include "platform/weborigin/SecurityOrigin.h" 99 #include "platform/weborigin/SecurityOrigin.h"
95 #include "public/platform/Platform.h" 100 #include "public/platform/Platform.h"
96 #include "public/platform/WebCachePolicy.h" 101 #include "public/platform/WebCachePolicy.h"
97 #include "public/platform/WebClipboard.h" 102 #include "public/platform/WebClipboard.h"
98 #include "public/platform/WebFloatRect.h" 103 #include "public/platform/WebFloatRect.h"
(...skipping 10221 matching lines...) Expand 10 before | Expand all | Expand 10 after
10320 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); 10325 EXPECT_TRUE(frameView->verticalScrollbar()->enabled());
10321 10326
10322 scrollerArea->setScrollbarsHidden(true); 10327 scrollerArea->setScrollbarsHidden(true);
10323 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); 10328 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled());
10324 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); 10329 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled());
10325 scrollerArea->setScrollbarsHidden(false); 10330 scrollerArea->setScrollbarsHidden(false);
10326 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); 10331 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled());
10327 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); 10332 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled());
10328 } 10333 }
10329 10334
10335 // Makes sure that mouse hover over an overlay scrollbar doesn't activate
10336 // elements below unless the scrollbar is faded out.
10337 TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) {
10338 FrameTestHelpers::WebViewHelper webViewHelper;
10339 webViewHelper.initialize(
10340 true, nullptr, nullptr, nullptr,
10341 [](WebSettings* settings) { settings->setDeviceSupportsMouse(true); });
10342 webViewHelper.resize(WebSize(20, 20));
10343 WebViewImpl* webView = webViewHelper.webView();
10344
10345 initializeWithHTML(*webView->mainFrameImpl()->frame(),
10346 "<!DOCTYPE html>"
10347 "<a id='a' href='javascript:void(0);'>"
10348 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10349 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10350 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10351 "</a>"
10352 "<div style='position: absolute; top: 1000px'>end</div>");
10353
10354 webView->updateAllLifecyclePhases();
10355
10356 Document* document = webView->mainFrameImpl()->frame()->document();
10357 Element* aTag = document->getElementById("a");
10358
10359 // Ensure hittest has scrollbar and link
10360 HitTestResult hitTestResult =
10361 webView->coreHitTestResultAt(WebPoint(18, aTag->offsetTop()));
10362
10363 EXPECT_TRUE(hitTestResult.URLElement());
10364 EXPECT_TRUE(hitTestResult.innerElement());
10365 EXPECT_TRUE(hitTestResult.scrollbar());
10366
10367 // Mouse over link. Mouse cursor should be hand.
10368 PlatformMouseEvent mouseMoveOverLinkEvent(
10369 IntPoint(aTag->offsetLeft(), aTag->offsetTop()),
10370 IntPoint(aTag->offsetLeft(), aTag->offsetTop()),
10371 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0,
10372 PlatformEvent::NoModifiers, WTF::monotonicallyIncreasingTime());
10373 document->frame()->eventHandler().handleMouseMoveEvent(
10374 mouseMoveOverLinkEvent);
10375
10376 EXPECT_EQ(
10377 Cursor::Type::Hand,
10378 document->frame()->chromeClient().lastSetCursorForTesting().getType());
10379
10380 // Mouse over enabled overlay scrollbar. Mouse cursor should be pointer and no
10381 // active hover element.
10382 PlatformMouseEvent mouseMoveEvent(
10383 IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()),
10384 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0,
10385 PlatformEvent::NoModifiers, WTF::monotonicallyIncreasingTime());
10386 document->frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
10387
10388 EXPECT_EQ(
10389 Cursor::Type::Pointer,
10390 document->frame()->chromeClient().lastSetCursorForTesting().getType());
10391
10392 PlatformMouseEvent mousePressEvent(
10393 IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()),
10394 WebPointerProperties::Button::Left, PlatformEvent::MousePressed, 0,
10395 PlatformEvent::Modifiers::LeftButtonDown,
10396 WTF::monotonicallyIncreasingTime());
10397 document->frame()->eventHandler().handleMousePressEvent(mousePressEvent);
10398
10399 EXPECT_FALSE(document->activeHoverElement());
10400 EXPECT_FALSE(document->hoverNode());
10401
10402 PlatformMouseEvent MouseReleaseEvent(
10403 IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()),
10404 WebPointerProperties::Button::Left, PlatformEvent::MouseReleased, 0,
10405 PlatformEvent::Modifiers::LeftButtonDown,
10406 WTF::monotonicallyIncreasingTime());
10407 document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent);
10408
10409 // Mouse over disabled overlay scrollbar. Mouse cursor should be hand and has
10410 // active hover element.
10411 webView->mainFrameImpl()->frameView()->setScrollbarsHidden(true);
10412
10413 // Ensure hittest only has link
10414 hitTestResult = webView->coreHitTestResultAt(WebPoint(18, aTag->offsetTop()));
10415
10416 EXPECT_TRUE(hitTestResult.URLElement());
10417 EXPECT_TRUE(hitTestResult.innerElement());
10418 EXPECT_FALSE(hitTestResult.scrollbar());
10419
10420 document->frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
10421
10422 EXPECT_EQ(
10423 Cursor::Type::Hand,
10424 document->frame()->chromeClient().lastSetCursorForTesting().getType());
10425
10426 document->frame()->eventHandler().handleMousePressEvent(mousePressEvent);
10427
10428 EXPECT_TRUE(document->activeHoverElement());
10429 EXPECT_TRUE(document->hoverNode());
10430
10431 document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent);
10432 }
10433
10330 TEST_F(WebFrameTest, UniqueNames) { 10434 TEST_F(WebFrameTest, UniqueNames) {
10331 registerMockedHttpURLLoad("frameset-repeated-name.html"); 10435 registerMockedHttpURLLoad("frameset-repeated-name.html");
10332 registerMockedHttpURLLoad("frameset-dest.html"); 10436 registerMockedHttpURLLoad("frameset-dest.html");
10333 FrameTestHelpers::WebViewHelper webViewHelper; 10437 FrameTestHelpers::WebViewHelper webViewHelper;
10334 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); 10438 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html");
10335 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); 10439 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame();
10336 HashSet<AtomicString> names; 10440 HashSet<AtomicString> names;
10337 for (Frame* frame = mainFrame->tree().firstChild(); frame; 10441 for (Frame* frame = mainFrame->tree().firstChild(); frame;
10338 frame = frame->tree().traverseNext()) { 10442 frame = frame->tree().traverseNext()) {
10339 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); 10443 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry);
10340 } 10444 }
10341 EXPECT_EQ(10u, names.size()); 10445 EXPECT_EQ(10u, names.size());
10342 } 10446 }
10343 10447
10344 } // namespace blink 10448 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698