Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Unified Diff: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp

Issue 1898813002: Allow throttling in painting microbenchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 60faa0b895dc7efc0cd86d439d21682d141153f4..355b06b78cab3b15d5354e3f22a4824b1da5ecd5 100644
--- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
+++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
@@ -11,6 +11,7 @@
#include "core/paint/PaintLayer.h"
#include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
+#include "public/platform/WebDisplayItemList.h"
#include "public/platform/WebLayer.h"
#include "public/web/WebHitTestResult.h"
#include "public/web/WebSettings.h"
@@ -22,12 +23,35 @@
#include "web/tests/sim/SimRequest.h"
#include "web/tests/sim/SimTest.h"
+using testing::_;
+
namespace blink {
using namespace HTMLNames;
// NOTE: This test uses <iframe sandbox> to create cross origin iframes.
+namespace {
+
+class MockWebDisplayItemList : public WebDisplayItemList {
+public:
+ ~MockWebDisplayItemList() override {}
+
+ MOCK_METHOD2(appendDrawingItem, void(const WebRect&, sk_sp<const SkPicture>));
+};
+
+void paintRecursively(GraphicsLayer* layer, WebDisplayItemList* displayItems)
+{
+ if (layer->drawsContent()) {
+ layer->setNeedsDisplay();
+ layer->contentLayerDelegateForTesting()->paintContents(displayItems, ContentLayerDelegate::PaintDefaultBehaviorForTest);
+ }
+ for (const auto& child : layer->children())
+ paintRecursively(child, displayItems);
+}
+
+} // namespace
+
class FrameThrottlingTest : public SimTest {
protected:
FrameThrottlingTest()
@@ -621,4 +645,36 @@ TEST_F(FrameThrottlingTest, ThrottledEventHandlerIgnored)
EXPECT_EQ(1u, touchHandlerRegionSize());
}
+TEST_F(FrameThrottlingTest, PaintingViaContentLayerDelegateIsThrottled)
+{
+ webView().settings()->setAcceleratedCompositingEnabled(true);
+ webView().settings()->setPreferCompositingToLCDTextEnabled(true);
+
+ // Create a hidden frame which is throttled.
+ 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 src=iframe.html></iframe>");
+ frameResource.complete("throttled");
+ compositeFrame();
+
+ // Move the frame offscreen to throttle it and make sure it is backed by a
+ // graphics layer.
+ auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"));
+ frameElement->setAttribute(styleAttr, "transform: translateY(480px) translateZ(0px)");
+ EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering());
+ compositeFrame();
+ EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
+
+ // If painting of the iframe is throttled, we should only receive two
+ // drawing items.
+ MockWebDisplayItemList displayItems;
+ EXPECT_CALL(displayItems, appendDrawingItem(_, _))
+ .Times(2);
+
+ GraphicsLayer* layer = webView().rootGraphicsLayer();
+ paintRecursively(layer, &displayItems);
ojan 2016/04/28 21:47:27 Specifically, this is not a thing that can happen
Xianzhu 2016/04/28 21:56:32 Right. However, I think this is why we call raste
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698