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(); |
ojan
2016/10/31 19:37:10
I know this isn't new in this patch, so obviously
ojan
2016/10/31 19:38:27
Oh, I see stefan already asked this. nm.
|
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) { |
ojan
2016/10/31 19:37:10
Did we end up finding always doing the first rAF t
Sami
2016/11/01 10:44:48
I don't have definite proof that it's required --
|
+ 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 |