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

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

Issue 2668133003: Change hover element to scrollbar's parent when hit test contains scrollbar (Closed)
Patch Set: add test Created 3 years, 10 months 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 10815 matching lines...) Expand 10 before | Expand all | Expand 10 after
10826 document->frame()->eventHandler().handleMouseMoveEvent( 10826 document->frame()->eventHandler().handleMouseMoveEvent(
10827 mouseMoveEvent, Vector<WebMouseEvent>()); 10827 mouseMoveEvent, Vector<WebMouseEvent>());
10828 10828
10829 EXPECT_EQ(document->hoverNode(), 10829 EXPECT_EQ(document->hoverNode(),
10830 document->frame()->chromeClient().lastSetTooltipNodeForTesting()); 10830 document->frame()->chromeClient().lastSetTooltipNodeForTesting());
10831 EXPECT_EQ(div2Tag, 10831 EXPECT_EQ(div2Tag,
10832 document->frame()->chromeClient().lastSetTooltipNodeForTesting()); 10832 document->frame()->chromeClient().lastSetTooltipNodeForTesting());
10833 } 10833 }
10834 10834
10835 // Makes sure that mouse hover over an overlay scrollbar doesn't activate 10835 // Makes sure that mouse hover over an overlay scrollbar doesn't activate
10836 // elements below unless the scrollbar is faded out. 10836 // elements below(not the scrollbar's parent) unless the scrollbar is faded out.
bokan 2017/02/02 23:29:26 I'd change this to "except the Element that owns t
10837 TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { 10837 TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) {
10838 FrameTestHelpers::WebViewHelper webViewHelper; 10838 FrameTestHelpers::WebViewHelper webViewHelper;
10839 webViewHelper.initialize(true, nullptr, nullptr, nullptr, 10839 webViewHelper.initialize(true, nullptr, nullptr, nullptr,
10840 [](WebSettings* settings) {}); 10840 [](WebSettings* settings) {});
10841 webViewHelper.resize(WebSize(20, 20)); 10841 webViewHelper.resize(WebSize(20, 20));
10842 WebViewImpl* webView = webViewHelper.webView(); 10842 WebViewImpl* webView = webViewHelper.webView();
10843 10843
10844 initializeWithHTML(*webView->mainFrameImpl()->frame(), 10844 initializeWithHTML(*webView->mainFrameImpl()->frame(),
10845 "<!DOCTYPE html>" 10845 "<!DOCTYPE html>"
10846 "<a id='a' href='javascript:void(0);'>" 10846 "<a id='a' href='javascript:void(0);'>"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
10988 TimeTicks::Now().InSeconds()); 10988 TimeTicks::Now().InSeconds());
10989 mouseMoveOverDivAndScrollbar.setFrameScale(1); 10989 mouseMoveOverDivAndScrollbar.setFrameScale(1);
10990 document->frame()->eventHandler().handleMouseMoveEvent( 10990 document->frame()->eventHandler().handleMouseMoveEvent(
10991 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); 10991 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>());
10992 10992
10993 // Custom not change the DIV :hover 10993 // Custom not change the DIV :hover
10994 EXPECT_EQ(document->hoverNode(), scrollbarDiv); 10994 EXPECT_EQ(document->hoverNode(), scrollbarDiv);
10995 EXPECT_EQ(hitTestResult.scrollbar()->hoveredPart(), ScrollbarPart::ThumbPart); 10995 EXPECT_EQ(hitTestResult.scrollbar()->hoveredPart(), ScrollbarPart::ThumbPart);
10996 } 10996 }
10997 10997
10998 // Makes sure that mouse hover over a scrollbar also hover the element owns the
10999 // scrollbar.
11000 TEST_F(WebFrameTest, MouseOverScrollbarAndParentElement) {
11001 registerMockedHttpURLLoad("scrollbar-and-element-hover.html");
11002 FrameTestHelpers::WebViewHelper webViewHelper;
11003 WebViewImpl* webView = webViewHelper.initializeAndLoad(
11004 m_baseURL + "scrollbar-and-element-hover.html");
11005
11006 webViewHelper.resize(WebSize(200, 200));
11007
11008 webView->updateAllLifecyclePhases();
11009
11010 Document* document = toLocalFrame(webView->page()->mainFrame())->document();
11011
11012 Element* scrollbarDiv = document->getElementById("scrollbar");
11013 EXPECT_TRUE(scrollbarDiv);
11014
11015 // Ensure hittest only has DIV.
11016 HitTestResult hitTestResult = webView->coreHitTestResultAt(WebPoint(1, 1));
11017
11018 EXPECT_TRUE(hitTestResult.innerElement());
11019 EXPECT_FALSE(hitTestResult.scrollbar());
11020
11021 // Mouse over DIV.
11022 WebMouseEvent mouseMoveOverDiv(
11023 WebInputEvent::MouseMove, WebFloatPoint(1, 1), WebFloatPoint(1, 1),
11024 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers,
11025 TimeTicks::Now().InSeconds());
11026 mouseMoveOverDiv.setFrameScale(1);
11027 document->frame()->eventHandler().handleMouseMoveEvent(
11028 mouseMoveOverDiv, Vector<WebMouseEvent>());
11029
11030 // DIV :hover.
11031 EXPECT_EQ(document->hoverNode(), scrollbarDiv);
11032
11033 // Ensure hittest has DIV and scrollbar.
11034 hitTestResult = webView->coreHitTestResultAt(WebPoint(175, 5));
11035
11036 EXPECT_TRUE(hitTestResult.innerElement());
11037 EXPECT_TRUE(hitTestResult.scrollbar());
11038 EXPECT_FALSE(hitTestResult.scrollbar()->isCustomScrollbar());
11039
11040 // Mouse over scrollbar.
11041 WebMouseEvent mouseMoveOverDivAndScrollbar(
11042 WebInputEvent::MouseMove, WebFloatPoint(175, 5), WebFloatPoint(175, 5),
11043 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers,
11044 TimeTicks::Now().InSeconds());
11045 mouseMoveOverDivAndScrollbar.setFrameScale(1);
11046 document->frame()->eventHandler().handleMouseMoveEvent(
11047 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>());
11048
11049 // Not change the DIV :hover.
11050 EXPECT_EQ(document->hoverNode(), scrollbarDiv);
11051 }
bokan 2017/02/02 23:29:26 I think it'll work, but please add to this test ca
11052
10998 TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) { 11053 TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) {
10999 registerMockedHttpURLLoad("custom-scrollbar-hover.html"); 11054 registerMockedHttpURLLoad("custom-scrollbar-hover.html");
11000 FrameTestHelpers::WebViewHelper webViewHelper; 11055 FrameTestHelpers::WebViewHelper webViewHelper;
11001 WebViewImpl* webView = webViewHelper.initializeAndLoad( 11056 WebViewImpl* webView = webViewHelper.initializeAndLoad(
11002 m_baseURL + "custom-scrollbar-hover.html"); 11057 m_baseURL + "custom-scrollbar-hover.html");
11003 11058
11004 webViewHelper.resize(WebSize(200, 200)); 11059 webViewHelper.resize(WebSize(200, 200));
11005 11060
11006 webView->updateAllLifecyclePhases(); 11061 webView->updateAllLifecyclePhases();
11007 11062
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
11257 11312
11258 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); 11313 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached());
11259 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); 11314 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading());
11260 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); 11315 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad());
11261 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); 11316 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents());
11262 11317
11263 webViewHelper.reset(); 11318 webViewHelper.reset();
11264 } 11319 }
11265 11320
11266 } // namespace blink 11321 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698