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

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: 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 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"
83 #include "platform/PlatformResourceLoader.h" 84 #include "platform/PlatformResourceLoader.h"
84 #include "platform/RuntimeEnabledFeatures.h" 85 #include "platform/RuntimeEnabledFeatures.h"
85 #include "platform/UserGestureIndicator.h" 86 #include "platform/UserGestureIndicator.h"
86 #include "platform/geometry/FloatRect.h" 87 #include "platform/geometry/FloatRect.h"
87 #include "platform/network/ResourceError.h" 88 #include "platform/network/ResourceError.h"
89 #include "platform/scroll/Scrollbar.h"
90 #include "platform/scroll/ScrollbarTestSuite.h"
88 #include "platform/scroll/ScrollbarTheme.h" 91 #include "platform/scroll/ScrollbarTheme.h"
92 #include "platform/scroll/ScrollbarThemeMock.h"
89 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 93 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
90 #include "platform/testing/URLTestHelpers.h" 94 #include "platform/testing/URLTestHelpers.h"
91 #include "platform/testing/UnitTestHelpers.h" 95 #include "platform/testing/UnitTestHelpers.h"
92 #include "platform/weborigin/KURLHash.h" 96 #include "platform/weborigin/KURLHash.h"
93 #include "platform/weborigin/SchemeRegistry.h" 97 #include "platform/weborigin/SchemeRegistry.h"
94 #include "platform/weborigin/SecurityOrigin.h" 98 #include "platform/weborigin/SecurityOrigin.h"
95 #include "public/platform/Platform.h" 99 #include "public/platform/Platform.h"
96 #include "public/platform/WebCachePolicy.h" 100 #include "public/platform/WebCachePolicy.h"
97 #include "public/platform/WebClipboard.h" 101 #include "public/platform/WebClipboard.h"
98 #include "public/platform/WebFloatRect.h" 102 #include "public/platform/WebFloatRect.h"
(...skipping 10221 matching lines...) Expand 10 before | Expand all | Expand 10 after
10320 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); 10324 EXPECT_TRUE(frameView->verticalScrollbar()->enabled());
10321 10325
10322 scrollerArea->setScrollbarsHidden(true); 10326 scrollerArea->setScrollbarsHidden(true);
10323 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); 10327 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled());
10324 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); 10328 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled());
10325 scrollerArea->setScrollbarsHidden(false); 10329 scrollerArea->setScrollbarsHidden(false);
10326 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); 10330 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled());
10327 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); 10331 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled());
10328 } 10332 }
10329 10333
10334 TEST_F(WebFrameTest, MouseOnScrollbarsAndHyperlink) {
bokan 2016/11/01 21:09:38 Nit: Better name would be MouseOverLinkAndOverlayS
10335 FrameTestHelpers::WebViewHelper webViewHelper;
10336 webViewHelper.initialize(true);
10337 webViewHelper.resize(WebSize(800, 600));
10338 WebViewImpl* webView = webViewHelper.webView();
10339
10340 initializeWithHTML(*webView->mainFrameImpl()->frame(),
10341 "<!DOCTYPE html>"
10342 "<a id='a' href='http://example.com'>a</a>");
10343
10344 webView->updateAllLifecyclePhases();
10345
10346 Document* document = webView->mainFrameImpl()->frame()->document();
10347 Element* aTag = document->getElementById("a");
10348
10349 HitTestRequest::HitTestRequestType hitType =
10350 HitTestRequest::Move | HitTestRequest::Active;
10351 HitTestRequest request(hitType);
10352
10353 HitTestResult hitTestResult = webView->coreHitTestResultAt(
10354 WebPoint(aTag->offsetLeft(), aTag->offsetTop()));
10355
10356 EXPECT_TRUE(hitTestResult.URLElement());
10357 EXPECT_TRUE(hitTestResult.innerElement());
10358 EXPECT_FALSE(hitTestResult.scrollbar());
10359
10360 document->updateHoverActiveState(request, hitTestResult.innerElement(),
10361 false);
10362 EXPECT_TRUE(document->activeHoverElement());
10363 EXPECT_TRUE(document->hoverElement());
10364
10365 Cursor::Type cursorType =
10366 document->frame()->eventHandler().selectCursorTypeForTest(hitTestResult);
bokan 2016/11/01 21:09:38 We should avoid these type of "ForTest" methods un
10367 EXPECT_EQ(cursorType, Cursor::Type::Hand);
10368
10369 // HitTest with scrollbar
10370 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
10371 ScrollbarThemeMock mockTheme;
10372 Scrollbar* mockScrollbar = Scrollbar::createForTesting(
10373 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme);
10374
10375 // put disabled scrollbar to hitTestResult, hitTestResult.scrollbar() should
bokan 2016/11/01 21:09:38 Nit: Capitalize "put" -> "Put"
10376 // be null.
10377 mockScrollbar->setEnabled(false);
10378 hitTestResult.setScrollbar(mockScrollbar);
10379
10380 EXPECT_FALSE(hitTestResult.scrollbar());
10381
10382 // 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
10383 // and cursorType should be pointer
10384 mockScrollbar->setEnabled(true);
10385 hitTestResult.setScrollbar(mockScrollbar);
10386
10387 EXPECT_TRUE(hitTestResult.scrollbar());
10388
10389 document->updateHoverActiveState(request, hitTestResult.innerElement(),
10390 hitTestResult.scrollbar());
10391 EXPECT_FALSE(document->activeHoverElement());
10392 EXPECT_FALSE(document->hoverElement());
10393
10394 cursorType =
10395 document->frame()->eventHandler().selectCursorTypeForTest(hitTestResult);
10396 EXPECT_EQ(cursorType, Cursor::Type::Pointer);
10397
10398 ThreadState::current()->collectAllGarbage();
10399 }
10400
10330 TEST_F(WebFrameTest, UniqueNames) { 10401 TEST_F(WebFrameTest, UniqueNames) {
10331 registerMockedHttpURLLoad("frameset-repeated-name.html"); 10402 registerMockedHttpURLLoad("frameset-repeated-name.html");
10332 registerMockedHttpURLLoad("frameset-dest.html"); 10403 registerMockedHttpURLLoad("frameset-dest.html");
10333 FrameTestHelpers::WebViewHelper webViewHelper; 10404 FrameTestHelpers::WebViewHelper webViewHelper;
10334 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); 10405 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html");
10335 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); 10406 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame();
10336 HashSet<AtomicString> names; 10407 HashSet<AtomicString> names;
10337 for (Frame* frame = mainFrame->tree().firstChild(); frame; 10408 for (Frame* frame = mainFrame->tree().firstChild(); frame;
10338 frame = frame->tree().traverseNext()) { 10409 frame = frame->tree().traverseNext()) {
10339 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); 10410 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry);
10340 } 10411 }
10341 EXPECT_EQ(10u, names.size()); 10412 EXPECT_EQ(10u, names.size());
10342 } 10413 }
10343 10414
10344 } // namespace blink 10415 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698