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 10323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10422 Element* scroller = document->getElementById("scroller"); | 10423 Element* scroller = document->getElementById("scroller"); |
10423 ScrollableArea* scrollerArea = | 10424 ScrollableArea* scrollerArea = |
10424 toLayoutBox(scroller->layoutObject())->getScrollableArea(); | 10425 toLayoutBox(scroller->layoutObject())->getScrollableArea(); |
10425 | 10426 |
10426 ASSERT_TRUE(scrollerArea->horizontalScrollbar()); | 10427 ASSERT_TRUE(scrollerArea->horizontalScrollbar()); |
10427 ASSERT_TRUE(scrollerArea->verticalScrollbar()); | 10428 ASSERT_TRUE(scrollerArea->verticalScrollbar()); |
10428 ASSERT_TRUE(frameView->horizontalScrollbar()); | 10429 ASSERT_TRUE(frameView->horizontalScrollbar()); |
10429 ASSERT_TRUE(frameView->verticalScrollbar()); | 10430 ASSERT_TRUE(frameView->verticalScrollbar()); |
10430 | 10431 |
10431 EXPECT_FALSE(frameView->scrollbarsHidden()); | 10432 EXPECT_FALSE(frameView->scrollbarsHidden()); |
10432 EXPECT_TRUE(frameView->horizontalScrollbar()->enabled()); | 10433 EXPECT_TRUE( |
10433 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); | 10434 frameView->horizontalScrollbar()->shouldParticipateInHitTesting()); |
| 10435 EXPECT_TRUE(frameView->verticalScrollbar()->shouldParticipateInHitTesting()); |
10434 | 10436 |
10435 EXPECT_FALSE(scrollerArea->scrollbarsHidden()); | 10437 EXPECT_FALSE(scrollerArea->scrollbarsHidden()); |
10436 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); | 10438 EXPECT_TRUE( |
10437 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); | 10439 scrollerArea->horizontalScrollbar()->shouldParticipateInHitTesting()); |
| 10440 EXPECT_TRUE( |
| 10441 scrollerArea->verticalScrollbar()->shouldParticipateInHitTesting()); |
10438 | 10442 |
10439 frameView->setScrollbarsHidden(true); | 10443 frameView->setScrollbarsHidden(true); |
10440 EXPECT_FALSE(frameView->horizontalScrollbar()->enabled()); | 10444 EXPECT_FALSE( |
10441 EXPECT_FALSE(frameView->verticalScrollbar()->enabled()); | 10445 frameView->horizontalScrollbar()->shouldParticipateInHitTesting()); |
| 10446 EXPECT_FALSE(frameView->verticalScrollbar()->shouldParticipateInHitTesting()); |
10442 frameView->setScrollbarsHidden(false); | 10447 frameView->setScrollbarsHidden(false); |
10443 EXPECT_TRUE(frameView->horizontalScrollbar()->enabled()); | 10448 EXPECT_TRUE( |
10444 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); | 10449 frameView->horizontalScrollbar()->shouldParticipateInHitTesting()); |
| 10450 EXPECT_TRUE(frameView->verticalScrollbar()->shouldParticipateInHitTesting()); |
10445 | 10451 |
10446 scrollerArea->setScrollbarsHidden(true); | 10452 scrollerArea->setScrollbarsHidden(true); |
10447 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); | 10453 EXPECT_FALSE( |
10448 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); | 10454 scrollerArea->horizontalScrollbar()->shouldParticipateInHitTesting()); |
| 10455 EXPECT_FALSE( |
| 10456 scrollerArea->verticalScrollbar()->shouldParticipateInHitTesting()); |
10449 scrollerArea->setScrollbarsHidden(false); | 10457 scrollerArea->setScrollbarsHidden(false); |
10450 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); | 10458 EXPECT_TRUE( |
10451 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); | 10459 scrollerArea->horizontalScrollbar()->shouldParticipateInHitTesting()); |
| 10460 EXPECT_TRUE( |
| 10461 scrollerArea->verticalScrollbar()->shouldParticipateInHitTesting()); |
| 10462 } |
| 10463 |
| 10464 static void disableCompositing(WebSettings* settings) { |
| 10465 settings->setAcceleratedCompositingEnabled(false); |
| 10466 settings->setPreferCompositingToLCDTextEnabled(false); |
| 10467 } |
| 10468 |
| 10469 // Make sure overlay scrollbars on non-composited scrollers fade out and set |
| 10470 // the hidden bit as needed. |
| 10471 TEST_F(WebFrameTest, TestNonCompositedOverlayScrollbarsFade) { |
| 10472 FrameTestHelpers::WebViewHelper webViewHelper; |
| 10473 WebViewImpl* webViewImpl = webViewHelper.initialize( |
| 10474 true, nullptr, nullptr, nullptr, &disableCompositing); |
| 10475 |
| 10476 constexpr double kMockOverlayFadeOutDelayMs = 5.0; |
| 10477 |
| 10478 ScrollbarTheme& theme = ScrollbarTheme::theme(); |
| 10479 // This test relies on mock overlay scrollbars. |
| 10480 ASSERT_TRUE(theme.isMockTheme()); |
| 10481 ASSERT_TRUE(theme.usesOverlayScrollbars()); |
| 10482 ScrollbarThemeOverlayMock& mockOverlayTheme = |
| 10483 (ScrollbarThemeOverlayMock&)theme; |
| 10484 mockOverlayTheme.setOverlayScrollbarFadeOutDelay(kMockOverlayFadeOutDelayMs / |
| 10485 1000.0); |
| 10486 |
| 10487 webViewImpl->resizeWithBrowserControls(WebSize(640, 480), 0, false); |
| 10488 |
| 10489 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
| 10490 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), |
| 10491 "<!DOCTYPE html>" |
| 10492 "<style>" |
| 10493 " #space {" |
| 10494 " width: 1000px;" |
| 10495 " height: 1000px;" |
| 10496 " }" |
| 10497 " #container {" |
| 10498 " width: 200px;" |
| 10499 " height: 200px;" |
| 10500 " overflow: scroll;" |
| 10501 " }" |
| 10502 " div { height:1000px; width: 200px; }" |
| 10503 "</style>" |
| 10504 "<div id='container'>" |
| 10505 " <div id='space'></div>" |
| 10506 "</div>", |
| 10507 baseURL); |
| 10508 webViewImpl->updateAllLifecyclePhases(); |
| 10509 |
| 10510 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 10511 Document* document = |
| 10512 toLocalFrame(webViewImpl->page()->mainFrame())->document(); |
| 10513 Element* container = document->getElementById("container"); |
| 10514 ScrollableArea* scrollableArea = |
| 10515 toLayoutBox(container->layoutObject())->getScrollableArea(); |
| 10516 |
| 10517 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10518 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10519 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10520 |
| 10521 scrollableArea->setScrollOffset(ScrollOffset(10, 10), ProgrammaticScroll, |
| 10522 ScrollBehaviorInstant); |
| 10523 |
| 10524 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10525 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10526 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10527 |
| 10528 frame->executeScript(WebScriptSource( |
| 10529 "document.getElementById('space').style.height = '500px';")); |
| 10530 frame->view()->updateAllLifecyclePhases(); |
| 10531 |
| 10532 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10533 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10534 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10535 |
| 10536 frame->executeScript(WebScriptSource( |
| 10537 "document.getElementById('container').style.height = '300px';")); |
| 10538 frame->view()->updateAllLifecyclePhases(); |
| 10539 |
| 10540 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
| 10541 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
| 10542 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
| 10543 |
| 10544 mockOverlayTheme.setOverlayScrollbarFadeOutDelay(0.0); |
10452 } | 10545 } |
10453 | 10546 |
10454 TEST_F(WebFrameTest, UniqueNames) { | 10547 TEST_F(WebFrameTest, UniqueNames) { |
10455 registerMockedHttpURLLoad("frameset-repeated-name.html"); | 10548 registerMockedHttpURLLoad("frameset-repeated-name.html"); |
10456 registerMockedHttpURLLoad("frameset-dest.html"); | 10549 registerMockedHttpURLLoad("frameset-dest.html"); |
10457 FrameTestHelpers::WebViewHelper webViewHelper; | 10550 FrameTestHelpers::WebViewHelper webViewHelper; |
10458 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); | 10551 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); |
10459 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); | 10552 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); |
10460 HashSet<AtomicString> names; | 10553 HashSet<AtomicString> names; |
10461 for (Frame* frame = mainFrame->tree().firstChild(); frame; | 10554 for (Frame* frame = mainFrame->tree().firstChild(); frame; |
10462 frame = frame->tree().traverseNext()) { | 10555 frame = frame->tree().traverseNext()) { |
10463 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); | 10556 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); |
10464 } | 10557 } |
10465 EXPECT_EQ(10u, names.size()); | 10558 EXPECT_EQ(10u, names.size()); |
10466 } | 10559 } |
10467 | 10560 |
10468 } // namespace blink | 10561 } // namespace blink |
OLD | NEW |