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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp

Issue 1603983002: Fix partial painting with render pipeline throttling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Invalidate paint for unthrottled frame. Created 4 years, 10 months 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/Document.h" 5 #include "core/dom/Document.h"
6 #include "core/dom/Element.h" 6 #include "core/dom/Element.h"
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/html/HTMLIFrameElement.h" 8 #include "core/html/HTMLIFrameElement.h"
9 #include "platform/testing/URLTestHelpers.h" 9 #include "platform/testing/URLTestHelpers.h"
10 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 // Move the frame offscreen to throttle it. 205 // Move the frame offscreen to throttle it.
206 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); 206 frameElement->setAttribute(styleAttr, "transform: translateY(480px)");
207 compositeFrame(); 207 compositeFrame();
208 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()) ; 208 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()) ;
209 209
210 // Mutating the throttled frame should not cause an animation to be schedule d. 210 // Mutating the throttled frame should not cause an animation to be schedule d.
211 frameElement->contentDocument()->documentElement()->setAttribute(styleAttr, "background: green"); 211 frameElement->contentDocument()->documentElement()->setAttribute(styleAttr, "background: green");
212 EXPECT_FALSE(compositor().needsAnimate()); 212 EXPECT_FALSE(compositor().needsAnimate());
213 213
214 // Moving the frame back on screen to unthrottle it. 214 // Move the frame back on screen to unthrottle it.
215 frameElement->setAttribute(styleAttr, ""); 215 frameElement->setAttribute(styleAttr, "");
216 EXPECT_TRUE(compositor().needsAnimate()); 216 EXPECT_TRUE(compositor().needsAnimate());
217 217
218 // The first frame we composite after unthrottling won't contain the 218 // The first frame we composite after unthrottling won't contain the
219 // frame's new contents because unthrottling happens at the end of the 219 // frame's new contents because unthrottling happens at the end of the
220 // lifecycle update. We need to do another composite to refresh the frame's 220 // lifecycle update. We need to do another composite to refresh the frame's
221 // contents. 221 // contents.
222 auto displayItems2 = compositeFrame(); 222 auto displayItems2 = compositeFrame();
223 EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "green")); 223 EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "green"));
224 EXPECT_TRUE(compositor().needsAnimate()); 224 EXPECT_TRUE(compositor().needsAnimate());
(...skipping 19 matching lines...) Expand all
244 244
245 // Change the size of a div in the throttled frame. 245 // Change the size of a div in the throttled frame.
246 auto* divElement = frameElement->contentDocument()->getElementById("div"); 246 auto* divElement = frameElement->contentDocument()->getElementById("div");
247 divElement->setAttribute(styleAttr, "width: 50px"); 247 divElement->setAttribute(styleAttr, "width: 50px");
248 248
249 // Querying the width of the div should do a synchronous layout update even 249 // Querying the width of the div should do a synchronous layout update even
250 // though the frame is being throttled. 250 // though the frame is being throttled.
251 EXPECT_EQ(50, divElement->clientWidth()); 251 EXPECT_EQ(50, divElement->clientWidth());
252 } 252 }
253 253
254 TEST_F(FrameThrottlingTest, UnthrottlingTriggersRepaint)
255 {
256 // Create a hidden frame which is throttled.
257 SimRequest mainResource("https://example.com/", "text/html");
258 SimRequest frameResource("https://example.com/iframe.html", "text/html");
259
260 loadURL("https://example.com/");
261 mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>");
262 frameResource.complete("<style> html { background: green; } </style>");
263
264 // Move the frame offscreen to throttle it.
265 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")) ;
266 frameElement->setAttribute(styleAttr, "transform: translateY(480px)");
267 EXPECT_FALSE(frameElement->contentDocument()->view()->shouldThrottleRenderin g());
268 compositeFrame();
269 EXPECT_TRUE(frameElement->contentDocument()->view()->shouldThrottleRendering ());
270
271 // Scroll down to unthrottle the frame. The first frame we composite after
272 // scrolling won't contain the frame yet, but will schedule another repaint.
273 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll);
274 auto displayItems = compositeFrame();
275 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "green"));
276
277 // Now the frame contents should be visible again.
278 auto displayItems2 = compositeFrame();
279 EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green"));
280 }
281
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.
254 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot) 282 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
255 { 283 {
256 FrameTestHelpers::TestWebViewClient viewClient; 284 FrameTestHelpers::TestWebViewClient viewClient;
257 WebViewImpl* webView = WebViewImpl::create(&viewClient); 285 WebViewImpl* webView = WebViewImpl::create(&viewClient);
258 webView->resize(WebSize(640, 480)); 286 webView->resize(WebSize(640, 480));
259 287
260 // Create a remote root frame with a local child frame. 288 // Create a remote root frame with a local child frame.
261 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 289 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
262 webView->setMainFrame(remoteClient.frame()); 290 webView->setMainFrame(remoteClient.frame());
263 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ; 291 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ;
(...skipping 27 matching lines...) Expand all
291 319
292 // Update the lifecycle again. The frame's lifecycle should not advance 320 // Update the lifecycle again. The frame's lifecycle should not advance
293 // because of throttling even though it is the local root. 321 // because of throttling even though it is the local root.
294 frameView->updateAllLifecyclePhases(); 322 frameView->updateAllLifecyclePhases();
295 testing::runPendingTasks(); 323 testing::runPendingTasks();
296 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state()); 324 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
297 webView->close(); 325 webView->close();
298 } 326 }
299 327
300 } // namespace blink 328 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698