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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2389073002: Fix link's hover state if the link under scrollbar (Closed)
Patch Set: add test 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 1df7d0d1e9ae977d9264371c3b44f9991e9e4072..7a9aa2e62900d25e1f9b53beb6dc8ba2893394e8 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -79,13 +79,17 @@
#include "core/testing/NullExecutionContext.h"
#include "modules/mediastream/MediaStream.h"
#include "modules/mediastream/MediaStreamRegistry.h"
+#include "platform/Cursor.h"
#include "platform/DragImage.h"
#include "platform/PlatformResourceLoader.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "platform/geometry/FloatRect.h"
#include "platform/network/ResourceError.h"
+#include "platform/scroll/Scrollbar.h"
+#include "platform/scroll/ScrollbarTestSuite.h"
#include "platform/scroll/ScrollbarTheme.h"
+#include "platform/scroll/ScrollbarThemeMock.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
@@ -10327,6 +10331,73 @@ TEST_F(WebFrameTest, HidingScrollbarsOnScrollableAreaDisablesScrollbars) {
EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled());
}
+TEST_F(WebFrameTest, MouseOnScrollbarsAndHyperlink) {
bokan 2016/11/01 21:09:38 Nit: Better name would be MouseOverLinkAndOverlayS
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initialize(true);
+ webViewHelper.resize(WebSize(800, 600));
+ WebViewImpl* webView = webViewHelper.webView();
+
+ initializeWithHTML(*webView->mainFrameImpl()->frame(),
+ "<!DOCTYPE html>"
+ "<a id='a' href='http://example.com'>a</a>");
+
+ webView->updateAllLifecyclePhases();
+
+ Document* document = webView->mainFrameImpl()->frame()->document();
+ Element* aTag = document->getElementById("a");
+
+ HitTestRequest::HitTestRequestType hitType =
+ HitTestRequest::Move | HitTestRequest::Active;
+ HitTestRequest request(hitType);
+
+ HitTestResult hitTestResult = webView->coreHitTestResultAt(
+ WebPoint(aTag->offsetLeft(), aTag->offsetTop()));
+
+ EXPECT_TRUE(hitTestResult.URLElement());
+ EXPECT_TRUE(hitTestResult.innerElement());
+ EXPECT_FALSE(hitTestResult.scrollbar());
+
+ document->updateHoverActiveState(request, hitTestResult.innerElement(),
+ false);
+ EXPECT_TRUE(document->activeHoverElement());
+ EXPECT_TRUE(document->hoverElement());
+
+ Cursor::Type cursorType =
+ document->frame()->eventHandler().selectCursorTypeForTest(hitTestResult);
bokan 2016/11/01 21:09:38 We should avoid these type of "ForTest" methods un
+ EXPECT_EQ(cursorType, Cursor::Type::Hand);
+
+ // HitTest with scrollbar
+ MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
+ ScrollbarThemeMock mockTheme;
+ Scrollbar* mockScrollbar = Scrollbar::createForTesting(
+ mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme);
+
+ // put disabled scrollbar to hitTestResult, hitTestResult.scrollbar() should
bokan 2016/11/01 21:09:38 Nit: Capitalize "put" -> "Put"
+ // be null.
+ mockScrollbar->setEnabled(false);
+ hitTestResult.setScrollbar(mockScrollbar);
+
+ EXPECT_FALSE(hitTestResult.scrollbar());
+
+ // put enabled scrollbar to hitTestResult, activeHoverElement() should be null
bokan 2016/11/01 21:09:37 Nit: ditto here and period at end. (We're pretty f
+ // and cursorType should be pointer
+ mockScrollbar->setEnabled(true);
+ hitTestResult.setScrollbar(mockScrollbar);
+
+ EXPECT_TRUE(hitTestResult.scrollbar());
+
+ document->updateHoverActiveState(request, hitTestResult.innerElement(),
+ hitTestResult.scrollbar());
+ EXPECT_FALSE(document->activeHoverElement());
+ EXPECT_FALSE(document->hoverElement());
+
+ cursorType =
+ document->frame()->eventHandler().selectCursorTypeForTest(hitTestResult);
+ EXPECT_EQ(cursorType, Cursor::Type::Pointer);
+
+ ThreadState::current()->collectAllGarbage();
+}
+
TEST_F(WebFrameTest, UniqueNames) {
registerMockedHttpURLLoad("frameset-repeated-name.html");
registerMockedHttpURLLoad("frameset-dest.html");

Powered by Google App Engine
This is Rietveld 408576698