| 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 d0637d01cd2e79e7dc3ae407256fc298659d031a..f24b8b79bbb59505c7b24579af1b2c07e0dec803 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 "core/page/FocusController.h"
|
| +#include "core/page/Page.h"
|
| #include "platform/testing/URLTestHelpers.h"
|
| #include "platform/testing/UnitTestHelpers.h"
|
| #include "public/web/WebHitTestResult.h"
|
| +#include "public/web/WebSettings.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "web/WebLocalFrameImpl.h"
|
| #include "web/WebRemoteFrameImpl.h"
|
| @@ -349,6 +352,42 @@ TEST_F(FrameThrottlingTest, ChangeStyleInThrottledFrame)
|
| EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green"));
|
| }
|
|
|
| +TEST_F(FrameThrottlingTest, ThrottledFrameWithFocus)
|
| +{
|
| + webView().settings()->setJavaScriptEnabled(true);
|
| + webView().settings()->setAcceleratedCompositingEnabled(true);
|
| + RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true);
|
| +
|
| + // Create a hidden frame which is throttled and has a text selection.
|
| + SimRequest mainResource("https://example.com/", "text/html");
|
| + SimRequest frameResource("https://example.com/iframe.html", "text/html");
|
| +
|
| + loadURL("https://example.com/");
|
| + mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.html></iframe>");
|
| + frameResource.complete(
|
| + "some text to select\n"
|
| + "<script>\n"
|
| + "var range = document.createRange();\n"
|
| + "range.selectNode(document.body);\n"
|
| + "window.getSelection().addRange(range);\n"
|
| + "</script>\n");
|
| +
|
| + // Move the frame offscreen to throttle it.
|
| + auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"));
|
| + frameElement->setAttribute(styleAttr, "transform: translateY(480px)");
|
| + EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering());
|
| + compositeFrame();
|
| + EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
|
| +
|
| + // Give the frame focus and do another composite. The selection in the
|
| + // compositor should be cleared because the frame is throttled.
|
| + EXPECT_FALSE(compositor().hasSelection());
|
| + document().page()->focusController().setFocusedFrame(frameElement->contentDocument()->frame());
|
| + document().body()->setAttribute(styleAttr, "background: green");
|
| + compositeFrame();
|
| + EXPECT_FALSE(compositor().hasSelection());
|
| +}
|
| +
|
| TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
|
| {
|
| FrameTestHelpers::TestWebViewClient viewClient;
|
|
|