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 825586c7cf41ba8bf4b981ba01dd3cac13989a5a..3b8be02190205bd54111384858b809ab24cfe453 100644 |
--- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp |
@@ -6,9 +6,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 "testing/gtest/include/gtest/gtest.h" |
+#include "web/WebLocalFrameImpl.h" |
+#include "web/WebRemoteFrameImpl.h" |
#include "web/tests/sim/SimCompositor.h" |
#include "web/tests/sim/SimDisplayItemList.h" |
#include "web/tests/sim/SimRequest.h" |
@@ -251,4 +254,53 @@ 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); |
+ |
+ WebString baseURL("http://internal.test/"); |
+ URLTestHelpers::registerMockedURLFromBaseURL(baseURL, "simple_div.html"); |
+ FrameTestHelpers::loadFrame(localFrame, baseURL.utf8() + "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(); |
+ 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()); |
+ webView->close(); |
+} |
+ |
} // namespace blink |