| 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 73fdb7a20d2691f44a11151b6d97d4362385b084..942c1c7ef165f60eebc6f25c304259bba9bd1f76 100644
|
| --- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
|
| @@ -6,6 +6,8 @@
|
| #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"
|
| @@ -350,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;
|
|
|