OLD | NEW |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/DragImage.h" | 82 #include "platform/DragImage.h" |
83 #include "platform/PlatformResourceLoader.h" | 83 #include "platform/PlatformResourceLoader.h" |
84 #include "platform/RuntimeEnabledFeatures.h" | 84 #include "platform/RuntimeEnabledFeatures.h" |
85 #include "platform/UserGestureIndicator.h" | 85 #include "platform/UserGestureIndicator.h" |
86 #include "platform/geometry/FloatRect.h" | 86 #include "platform/geometry/FloatRect.h" |
87 #include "platform/network/ResourceError.h" | 87 #include "platform/network/ResourceError.h" |
88 #include "platform/scroll/ScrollbarTheme.h" | 88 #include "platform/scroll/ScrollbarTheme.h" |
| 89 #include "platform/scroll/ScrollbarThemeOverlayMock.h" |
89 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 90 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
90 #include "platform/testing/URLTestHelpers.h" | 91 #include "platform/testing/URLTestHelpers.h" |
91 #include "platform/testing/UnitTestHelpers.h" | 92 #include "platform/testing/UnitTestHelpers.h" |
92 #include "platform/weborigin/KURLHash.h" | 93 #include "platform/weborigin/KURLHash.h" |
93 #include "platform/weborigin/SchemeRegistry.h" | 94 #include "platform/weborigin/SchemeRegistry.h" |
94 #include "platform/weborigin/SecurityOrigin.h" | 95 #include "platform/weborigin/SecurityOrigin.h" |
95 #include "public/platform/Platform.h" | 96 #include "public/platform/Platform.h" |
96 #include "public/platform/WebCachePolicy.h" | 97 #include "public/platform/WebCachePolicy.h" |
97 #include "public/platform/WebClipboard.h" | 98 #include "public/platform/WebClipboard.h" |
98 #include "public/platform/WebFloatRect.h" | 99 #include "public/platform/WebFloatRect.h" |
(...skipping 10239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10338 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); | 10339 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); |
10339 | 10340 |
10340 scrollerArea->setScrollbarsHidden(true); | 10341 scrollerArea->setScrollbarsHidden(true); |
10341 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); | 10342 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); |
10342 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); | 10343 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); |
10343 scrollerArea->setScrollbarsHidden(false); | 10344 scrollerArea->setScrollbarsHidden(false); |
10344 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); | 10345 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); |
10345 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); | 10346 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); |
10346 } | 10347 } |
10347 | 10348 |
| 10349 static void disableCompositing(WebSettings* settings) { |
| 10350 settings->setAcceleratedCompositingEnabled(false); |
| 10351 settings->setPreferCompositingToLCDTextEnabled(false); |
| 10352 } |
| 10353 |
| 10354 // Make sure overlay scrollbars on non-composited scrollers fade out and set |
| 10355 // the hidden bit as needed. |
| 10356 TEST_F(WebFrameTest, TestNonCompositedOverlayScrollbarsFade) { |
| 10357 FrameTestHelpers::WebViewHelper webViewHelper; |
| 10358 WebViewImpl* webViewImpl = webViewHelper.initialize( |
| 10359 true, nullptr, nullptr, nullptr, &disableCompositing); |
| 10360 |
| 10361 constexpr double kMockOverlayFadeOutDelayMs = 5.0; |
| 10362 |
| 10363 ScrollbarTheme& theme = ScrollbarTheme::theme(); |
| 10364 // This test relies on mock overlay scrollbars. |
| 10365 ASSERT_TRUE(theme.isMockTheme()); |
| 10366 ASSERT_TRUE(theme.usesOverlayScrollbars()); |
| 10367 ScrollbarThemeOverlayMock& mockOverlayTheme = |
| 10368 (ScrollbarThemeOverlayMock&)theme; |
| 10369 mockOverlayTheme.setOverlayScrollbarFadeOutDelay(kMockOverlayFadeOutDelayMs / |
| 10370 1000.0); |
| 10371 |
| 10372 webViewImpl->resizeWithBrowserControls(WebSize(640, 480), 0, false); |
| 10373 |
| 10374 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
| 10375 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), |
| 10376 "<!DOCTYPE html>" |
| 10377 "<style>" |
| 10378 " #space {" |
| 10379 " width: 1000px;" |
| 10380 " height: 1000px;" |
| 10381 " }" |
| 10382 " #container {" |
| 10383 " width: 200px;" |
| 10384 " height: 200px;" |
| 10385 " overflow: scroll;" |
| 10386 " }" |
| 10387 " div { height:1000px; width: 200px; }" |
| 10388 "</style>" |
| 10389 "<div id='container'>" |
| 10390 " <div id='space'></div>" |
| 10391 "</div>", |
| 10392 baseURL); |
| 10393 webViewImpl->updateAllLifecyclePhases(); |
| 10394 |
| 10395 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 10396 Document* document = |
| 10397 toLocalFrame(webViewImpl->page()->mainFrame())->document(); |
| 10398 Element* container = document->getElementById("container"); |
| 10399 ScrollableArea* scrollableArea = |
| 10400 toLayoutBox(container->layoutObject())->getScrollableArea(); |
| 10401 |
| 10402 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10403 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10404 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10405 |
| 10406 scrollableArea->setScrollOffset(ScrollOffset(10, 10), ProgrammaticScroll, |
| 10407 ScrollBehaviorInstant); |
| 10408 |
| 10409 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10410 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10411 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10412 |
| 10413 frame->executeScript(WebScriptSource( |
| 10414 "document.getElementById('space').style.height = '500px';")); |
| 10415 frame->view()->updateAllLifecyclePhases(); |
| 10416 |
| 10417 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10418 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10419 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10420 |
| 10421 frame->executeScript(WebScriptSource( |
| 10422 "document.getElementById('container').style.height = '300px';")); |
| 10423 frame->view()->updateAllLifecyclePhases(); |
| 10424 |
| 10425 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10426 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10427 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10428 |
| 10429 mockOverlayTheme.setOverlayScrollbarFadeOutDelay(0.0); |
| 10430 } |
| 10431 |
10348 TEST_F(WebFrameTest, UniqueNames) { | 10432 TEST_F(WebFrameTest, UniqueNames) { |
10349 registerMockedHttpURLLoad("frameset-repeated-name.html"); | 10433 registerMockedHttpURLLoad("frameset-repeated-name.html"); |
10350 registerMockedHttpURLLoad("frameset-dest.html"); | 10434 registerMockedHttpURLLoad("frameset-dest.html"); |
10351 FrameTestHelpers::WebViewHelper webViewHelper; | 10435 FrameTestHelpers::WebViewHelper webViewHelper; |
10352 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); | 10436 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); |
10353 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); | 10437 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); |
10354 HashSet<AtomicString> names; | 10438 HashSet<AtomicString> names; |
10355 for (Frame* frame = mainFrame->tree().firstChild(); frame; | 10439 for (Frame* frame = mainFrame->tree().firstChild(); frame; |
10356 frame = frame->tree().traverseNext()) { | 10440 frame = frame->tree().traverseNext()) { |
10357 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); | 10441 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); |
10358 } | 10442 } |
10359 EXPECT_EQ(10u, names.size()); | 10443 EXPECT_EQ(10u, names.size()); |
10360 } | 10444 } |
10361 | 10445 |
10362 } // namespace blink | 10446 } // namespace blink |
OLD | NEW |