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