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 3cf525b4b3b4c1016fab1b12c33111700b20dba3..26d0c87787839786dbbf754d48f386e93416f6dd 100644 |
--- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
@@ -8,9 +8,12 @@ |
#include "core/dom/Element.h" |
#include "core/frame/FrameView.h" |
#include "core/html/HTMLIFrameElement.h" |
+#include "platform/testing/URLTestHelpers.h" |
#include "platform/testing/UnitTestHelpers.h" |
#include "public/web/WebHitTestResult.h" |
+#include "public/web/WebRemoteFrame.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "web/WebLocalFrameImpl.h" |
#include "web/tests/sim/SimCompositor.h" |
#include "web/tests/sim/SimDisplayItemList.h" |
#include "web/tests/sim/SimRequest.h" |
@@ -253,4 +256,52 @@ TEST_F(FrameThrottlingTest, SynchronousLayoutInThrottledFrame) |
EXPECT_EQ(50, divElement->clientWidth()); |
} |
+TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot) |
+{ |
+ FrameTestHelpers::TestWebViewClient viewClient; |
+ WebViewImpl* webView = WebViewImpl::create(&viewClient); |
+ webView->resize(WebSize(640, 480)); |
+ |
+ // Create a remote root frame with a local child frame. |
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
+ webView->setMainFrame(remoteClient.frame()); |
+ remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()); |
+ |
+ WebFrameOwnerProperties properties; |
+ FrameTestHelpers::TestWebFrameClient localFrameClient; |
+ WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame(); |
+ WebLocalFrame* localFrame = rootFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties); |
+ |
+ std::string baseURL("http://internal.test/"); |
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("simple_div.html")); |
+ FrameTestHelpers::loadFrame(localFrame, baseURL + "simple_div.html"); |
+ |
+ FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); |
+ EXPECT_TRUE(frameView->frame().isLocalRoot()); |
+ |
+ // Enable throttling for the child frame. |
+ frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->height())); |
+ frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::createUnique()); |
+ frameView->updateAllLifecyclePhases(); |
ojan
2015/12/01 01:11:05
Can this be tested via pumping a frame through the
Charlie Reis
2015/12/01 23:24:46
Daniel, can you check whether there's a better way
dcheng
2015/12/02 22:42:28
oopi isn't really controlled by any flags in Blink
|
+ testing::runPendingTasks(); |
+ EXPECT_TRUE(frameView->shouldThrottleRendering()); |
+ |
+ Document* frameDocument = frameView->frame().document(); |
+ if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) |
+ EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state()); |
+ else |
+ EXPECT_EQ(DocumentLifecycle::PaintInvalidationClean, frameDocument->lifecycle().state()); |
+ |
+ // Mutate the local child frame contents. |
+ auto* divElement = frameDocument->getElementById("div"); |
+ divElement->setAttribute(styleAttr, "width: 50px"); |
+ EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle().state()); |
+ |
+ // Update the lifecycle again. The frame's lifecycle should not advance |
+ // because of throttling even though it is the local root. |
+ frameView->updateAllLifecyclePhases(); |
+ testing::runPendingTasks(); |
+ EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle().state()); |
+} |
+ |
} // namespace blink |