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

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

Issue 1972893002: Make sure newly created frames become throttled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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/frame/FrameView.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..97de77747375f97916f864ee4a5668b3f1b7be63 100644
--- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
+++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
@@ -809,4 +809,58 @@ TEST_F(FrameThrottlingTest, SkipPaintingLayersInThrottledFrames)
EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "red"));
}
+TEST_F(FrameThrottlingTest, ThrottleNewlyCreatedFrame)
+{
+ webView().settings()->setAcceleratedCompositingEnabled(true);
+ webView().settings()->setPreferCompositingToLCDTextEnabled(true);
+ webView().settings()->setJavaScriptEnabled(true);
+
+ SimRequest mainResource("https://example.com/", "text/html");
+ SimRequest frameResource("https://example.com/iframe.html", "text/html");
+
+ // Create an intermediate frame which is throttled.
+ loadURL("https://example.com/");
+ mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.html></iframe>");
+ frameResource.complete("");
+ auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"));
+ frameElement->setAttribute(styleAttr, "transform: translateY(480px)");
+ compositeFrame();
+ EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
+ auto* frameDocument = frameElement->contentDocument();
+
+ // Create a new child frame inside the throttled frame. Make sure it also
+ // has a composited layer.
+ LocalFrame* localFrame = toLocalFrame(frameElement->contentFrame());
+ localFrame->script().executeScriptInMainWorld(
+ "var frame = document.createElement('iframe');\n"
+ "frame.setAttribute('id', 'childFrame');\n"
+ "frame.setAttribute('style', 'transform: translateZ(0)');\n"
+ "document.body.appendChild(frame);\n");
+ auto* childFrameElement = toHTMLIFrameElement(frameDocument->getElementById("childFrame"));
+ auto* childFrameDocument = childFrameElement->contentDocument();
+
+ // The frame starts out as unthrottled before it is assigned to a parent.
+ EXPECT_FALSE(childFrameDocument->view()->canThrottleRendering());
+
+ // Do a full lifecycle update including paint and without allowing
+ // throttling. This will cause the creation of graphics layers for the
+ // newly created frame.
+ childFrameDocument->view()->updateAllLifecyclePhases();
+
+ // The new frame should have immediately become throttled even though we
+ // didn't run any of the intersection observers yet.
+ EXPECT_TRUE(childFrameDocument->view()->canThrottleRendering());
+
+ // Invalidate paint for all layers in all views and mutate the child frame
+ // to cause it to repaint.
+ childFrameDocument->view()->layoutView()->invalidatePaintForViewAndCompositedLayers();
+ frameDocument->view()->layoutView()->invalidatePaintForViewAndCompositedLayers();
+ document().view()->layoutView()->invalidatePaintForViewAndCompositedLayers();
+ childFrameDocument->documentElement()->setAttribute(styleAttr, "background: red");
+
+ // Compositing should not fail with a document lifecycle assertion while
+ // while trying to paint the child frame.
+ compositeFrame();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698