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

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

Issue 2272773002: Use intersection observer to control frame throttling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update LeakExpectations Created 4 years, 1 month 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
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 b2e6e095f0f9840e161dccf0f2c46bc41dcfda51..7e022a42b2eabb0f0b29719a3d16f0b2ced210ff 100644
--- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
+++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/ScriptSourceCode.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/frame/FrameView.h"
@@ -778,7 +779,7 @@ TEST_F(FrameThrottlingTest, ThrottleSubtreeAtomically) {
// observer notifications.
frameElement->contentDocument()
->view()
- ->notifyRenderThrottlingObserversForTesting();
+ ->updateRenderThrottlingStatusForTesting();
EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
EXPECT_TRUE(
childFrameElement->contentDocument()->view()->canThrottleRendering());
@@ -786,10 +787,34 @@ TEST_F(FrameThrottlingTest, ThrottleSubtreeAtomically) {
// Both frames should still be throttled after the second notification.
childFrameElement->contentDocument()
->view()
- ->notifyRenderThrottlingObserversForTesting();
+ ->updateRenderThrottlingStatusForTesting();
EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
EXPECT_TRUE(
childFrameElement->contentDocument()->view()->canThrottleRendering());
+
+ // Move the frame back on screen but don't update throttling yet.
+ frameElement->setAttribute(styleAttr, "transform: translateY(0px)");
+ compositor().beginFrame();
+ EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
+ EXPECT_TRUE(
+ childFrameElement->contentDocument()->view()->canThrottleRendering());
+
+ // Update throttling for the child. It should remain throttled because the
+ // parent is still throttled.
+ childFrameElement->contentDocument()
+ ->view()
+ ->updateRenderThrottlingStatusForTesting();
+ EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
+ EXPECT_TRUE(
+ childFrameElement->contentDocument()->view()->canThrottleRendering());
+
+ // Updating throttling on the parent should unthrottle both frames.
+ frameElement->contentDocument()
+ ->view()
+ ->updateRenderThrottlingStatusForTesting();
+ EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering());
+ EXPECT_FALSE(
+ childFrameElement->contentDocument()->view()->canThrottleRendering());
}
TEST_F(FrameThrottlingTest, SkipPaintingLayersInThrottledFrames) {
@@ -874,4 +899,33 @@ TEST_F(FrameThrottlingTest, SynchronousLayoutInAnimationFrameCallback) {
compositeFrame();
}
+TEST_F(FrameThrottlingTest, AllowOneAnimationFrame) {
+ 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 frameResource("https://thirdparty.com/frame.html", "text/html");
+ loadURL("https://example.com/");
+ mainResource.complete(
+ "<iframe id=frame style=\"position: fixed; top: -10000px\" "
+ "src='https://thirdparty.com/frame.html'></iframe>");
+
+ frameResource.complete(
+ "<script>"
+ "window.requestAnimationFrame(() => { window.didRaf = true; });"
+ "</script>");
+
+ auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"));
+ compositeFrame();
+ EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
+
+ LocalFrame* localFrame = toLocalFrame(frameElement->contentFrame());
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Local<v8::Value> result =
+ localFrame->script().executeScriptInMainWorldAndReturnValue(
+ ScriptSourceCode("window.didRaf;"));
+ EXPECT_TRUE(result->IsTrue());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698