Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
| index beca4dd5faba0d8e57f0e39b2aa12e710fb4f5f1..7ead20d2c0e74b269da8a7c6c1abf43d46de7f90 100644 |
| --- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
| @@ -211,7 +211,7 @@ TEST_F(FrameThrottlingTest, MutatingThrottledFrameDoesNotCauseAnimation) |
| frameElement->contentDocument()->documentElement()->setAttribute(styleAttr, "background: green"); |
| EXPECT_FALSE(compositor().needsAnimate()); |
| - // Moving the frame back on screen to unthrottle it. |
| + // Move the frame back on screen to unthrottle it. |
| frameElement->setAttribute(styleAttr, ""); |
| EXPECT_TRUE(compositor().needsAnimate()); |
| @@ -251,6 +251,34 @@ TEST_F(FrameThrottlingTest, SynchronousLayoutInThrottledFrame) |
| EXPECT_EQ(50, divElement->clientWidth()); |
| } |
| +TEST_F(FrameThrottlingTest, UnthrottlingTriggersRepaint) |
| +{ |
| + // Create a hidden frame which is throttled. |
| + SimRequest mainResource("https://example.com/", "text/html"); |
| + SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| + |
| + loadURL("https://example.com/"); |
| + mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>"); |
| + frameResource.complete("<style> html { background: green; } </style>"); |
| + |
| + // Move the frame offscreen to throttle it. |
| + auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")); |
| + frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
| + EXPECT_FALSE(frameElement->contentDocument()->view()->shouldThrottleRendering()); |
| + compositeFrame(); |
| + EXPECT_TRUE(frameElement->contentDocument()->view()->shouldThrottleRendering()); |
| + |
| + // Scroll down to unthrottle the frame. The first frame we composite after |
| + // scrolling won't contain the frame yet, but will schedule another repaint. |
| + webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480), ProgrammaticScroll); |
| + auto displayItems = compositeFrame(); |
| + EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "green")); |
| + |
| + // Now the frame contents should be visible again. |
| + auto displayItems2 = compositeFrame(); |
| + EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green")); |
| +} |
| + |
|
Xianzhu
2016/01/25 18:33:17
Can you add a test for the following scenario (or
Sami
2016/01/25 18:44:23
Great idea, done.
|
| TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot) |
| { |
| FrameTestHelpers::TestWebViewClient viewClient; |