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

Unified Diff: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp

Issue 1994133002: Disallow throttling while running requestAnimationFrame callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/page/PageAnimator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ae063ee128ba1fe7491c4ff8669534796e37d68c..dc31adacdf21f618f6bc9328d26e08cf3e2f8e4f 100644
--- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
+++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
@@ -809,4 +809,52 @@ TEST_F(FrameThrottlingTest, SkipPaintingLayersInThrottledFrames)
EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "red"));
}
+TEST_F(FrameThrottlingTest, SynchronousLayoutInRequestAnimationFrameCallback)
+{
+ webView().settings()->setJavaScriptEnabled(true);
+
+ // Prepare a page with two cross origin frames (from the same origin so they
+ // are able to access eachother).
+ SimRequest mainResource("https://example.com/", "text/html");
+ SimRequest firstFrameResource("https://thirdparty.com/first.html", "text/html");
+ SimRequest secondFrameResource("https://thirdparty.com/second.html", "text/html");
+ loadURL("https://example.com/");
+ mainResource.complete(
+ "<iframe id=first name=first src='https://thirdparty.com/first.html'></iframe>\n"
+ "<iframe id=second name=second src='https://thirdparty.com/second.html'></iframe>");
+
+ // The first frame contains just a simple div. This frame will be made
+ // throttled.
+ firstFrameResource.complete("<div id=d>first frame</div>");
+
+ // The second page has a script which, inside a requestAnimationFrame
+ // callback, mutates the first (throttled) frame's contents and then
+ // requests a synchronous style computation of that first frame.
+ secondFrameResource.complete(
+ "<script>"
+ "window.addEventListener('load', function() {\n"
+ // Set up the rAF callback after a delay. Otherwise it will get serviced
+ // as a part of the first composition pass.
+ " window.setTimeout(function() {\n"
esprehn 2016/05/19 18:53:59 I don't think we want this delay, just run the rig
Sami 2016/05/19 19:05:20 Good point, done.
+ " window.requestAnimationFrame(function() {\n"
+ " var throttledFrame = window.parent.frames['first'];\n"
+ " throttledFrame.document.documentElement.style = 'margin: 50px';\n"
+ " throttledFrame.document.querySelector('#d').getBoundingClientRect();\n"
+ " });\n"
+ " }, 0);\n"
+ "});\n"
+ "</script>\n");
+
+ // Throttle the first frame.
+ auto* firstFrameElement = toHTMLIFrameElement(document().getElementById("first"));
+ firstFrameElement->setAttribute(styleAttr, "transform: translateY(480px)");
+ compositeFrame();
+ EXPECT_TRUE(firstFrameElement->contentDocument()->view()->canThrottleRendering());
+
+ // Service the requestAnimationFrame for the second frame. This should not
+ // result in an unexpected lifecycle state even if the first frame is
+ // throttled during the requestAnimationFrame callback.
+ compositeFrame();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/page/PageAnimator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698