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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp

Issue 2893803002: Fix DCHECK failure when PaintLayerContents() paints layer in throttled frame (Closed)
Patch Set: Rebase Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptController.h" 5 #include "bindings/core/v8/ScriptController.h"
6 #include "bindings/core/v8/ScriptSourceCode.h" 6 #include "bindings/core/v8/ScriptSourceCode.h"
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 826
827 // Create a hidden frame which is throttled. 827 // Create a hidden frame which is throttled.
828 SimRequest main_resource("https://example.com/", "text/html"); 828 SimRequest main_resource("https://example.com/", "text/html");
829 SimRequest frame_resource("https://example.com/iframe.html", "text/html"); 829 SimRequest frame_resource("https://example.com/iframe.html", "text/html");
830 830
831 LoadURL("https://example.com/"); 831 LoadURL("https://example.com/");
832 main_resource.Complete("<iframe id=frame sandbox src=iframe.html></iframe>"); 832 main_resource.Complete("<iframe id=frame sandbox src=iframe.html></iframe>");
833 frame_resource.Complete("throttled"); 833 frame_resource.Complete("throttled");
834 CompositeFrame(); 834 CompositeFrame();
835 835
836 // Before the iframe is throttled, we should create all drawing items.
837 MockWebDisplayItemList display_items_not_throttled;
838 EXPECT_CALL(display_items_not_throttled, AppendDrawingItem(_, _, _)).Times(3);
839 PaintRecursively(WebView().RootGraphicsLayer(), &display_items_not_throttled);
840
836 // Move the frame offscreen to throttle it and make sure it is backed by a 841 // Move the frame offscreen to throttle it and make sure it is backed by a
837 // graphics layer. 842 // graphics layer.
838 auto* frame_element = 843 auto* frame_element =
839 toHTMLIFrameElement(GetDocument().getElementById("frame")); 844 toHTMLIFrameElement(GetDocument().getElementById("frame"));
840 frame_element->setAttribute(styleAttr, 845 frame_element->setAttribute(styleAttr,
841 "transform: translateY(480px) translateZ(0px)"); 846 "transform: translateY(480px) translateZ(0px)");
842 EXPECT_FALSE( 847 EXPECT_FALSE(
843 frame_element->contentDocument()->View()->CanThrottleRendering()); 848 frame_element->contentDocument()->View()->CanThrottleRendering());
844 CompositeFrame(); 849 CompositeFrame();
845 EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering()); 850 EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering());
846 851
847 // If painting of the iframe is throttled, we should only receive two 852 // If painting of the iframe is throttled, we should only receive two
848 // drawing items. 853 // drawing items.
849 MockWebDisplayItemList display_items; 854 MockWebDisplayItemList display_items_throttled;
850 EXPECT_CALL(display_items, AppendDrawingItem(_, _, _)).Times(2); 855 EXPECT_CALL(display_items_throttled, AppendDrawingItem(_, _, _)).Times(2);
856 PaintRecursively(WebView().RootGraphicsLayer(), &display_items_throttled);
857 }
851 858
852 GraphicsLayer* layer = WebView().RootGraphicsLayer(); 859 TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) {
853 PaintRecursively(layer, &display_items); 860 WebView().GetSettings()->SetAcceleratedCompositingEnabled(true);
861 WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true);
862
863 // Create a hidden frame which is throttled.
864 SimRequest main_resource("https://example.com/", "text/html");
865 SimRequest frame_resource("https://example.com/iframe.html", "text/html");
866
867 LoadURL("https://example.com/");
868 main_resource.Complete("<iframe id=frame sandbox src=iframe.html></iframe>");
869 frame_resource.Complete(
870 "<div id=div style='will-change: transform; background: blue'>DIV</div>");
871 CompositeFrame();
872
873 auto* frame_element =
874 toHTMLIFrameElement(GetDocument().getElementById("frame"));
875 // The inner div is composited.
876 auto* inner_div = frame_element->contentDocument()->getElementById("div");
877 EXPECT_NE(nullptr,
878 inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
879
880 // Before the iframe is throttled, we should create all drawing items.
881 MockWebDisplayItemList display_items_not_throttled;
882 EXPECT_CALL(display_items_not_throttled, AppendDrawingItem(_, _, _)).Times(4);
883 PaintRecursively(WebView().RootGraphicsLayer(), &display_items_not_throttled);
884
885 // Move the frame offscreen to throttle it.
886 frame_element->setAttribute(styleAttr, "transform: translateY(480px)");
887 EXPECT_FALSE(
888 frame_element->contentDocument()->View()->CanThrottleRendering());
889 CompositeFrame();
890 EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering());
891 // The inner div should still be composited.
892 EXPECT_NE(nullptr,
893 inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
894
895 // If painting of the iframe is throttled, we should only receive two
896 // drawing items.
897 MockWebDisplayItemList display_items_throttled;
898 EXPECT_CALL(display_items_throttled, AppendDrawingItem(_, _, _)).Times(2);
899 PaintRecursively(WebView().RootGraphicsLayer(), &display_items_throttled);
900
901 // Remove compositing trigger of inner_div.
902 inner_div->setAttribute(styleAttr, "background: yellow; overflow: hidden");
903 // Do an unthrottled style and layout update, simulating the situation
904 // triggered by script style/layout access.
905 GetDocument().View()->UpdateLifecycleToLayoutClean();
906 {
907 // And a throttled full lifecycle update.
908 DocumentLifecycle::AllowThrottlingScope throttling_scope(
909 GetDocument().Lifecycle());
910 GetDocument().View()->UpdateAllLifecyclePhases();
911 }
912 // The inner div should still be composited because compositing update is
913 // throttled, though the inner_div's self-painting status has been updated.
914 EXPECT_FALSE(inner_div->GetLayoutBox()->Layer()->IsSelfPaintingLayer());
915 {
916 DisableCompositingQueryAsserts disabler;
917 EXPECT_NE(nullptr,
918 inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
919 }
920
921 MockWebDisplayItemList display_items_throttled1;
922 EXPECT_CALL(display_items_throttled1, AppendDrawingItem(_, _, _)).Times(2);
923 PaintRecursively(WebView().RootGraphicsLayer(), &display_items_throttled1);
924
925 // Move the frame back on screen.
926 frame_element->setAttribute(styleAttr, "");
927 CompositeFrame();
928 EXPECT_FALSE(
929 frame_element->contentDocument()->View()->CanThrottleRendering());
930 CompositeFrame();
931 // The inner div is no longer composited.
932 EXPECT_EQ(nullptr,
933 inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
934
935 // After the iframe is unthrottled, we should create all drawing items.
936 MockWebDisplayItemList display_items_not_throttled1;
937 EXPECT_CALL(display_items_not_throttled1, AppendDrawingItem(_, _, _))
938 .Times(4);
939 PaintRecursively(WebView().RootGraphicsLayer(),
940 &display_items_not_throttled1);
854 } 941 }
855 942
856 TEST_P(FrameThrottlingTest, ThrottleSubtreeAtomically) { 943 TEST_P(FrameThrottlingTest, ThrottleSubtreeAtomically) {
857 // Create two nested frames which are throttled. 944 // Create two nested frames which are throttled.
858 SimRequest main_resource("https://example.com/", "text/html"); 945 SimRequest main_resource("https://example.com/", "text/html");
859 SimRequest frame_resource("https://example.com/iframe.html", "text/html"); 946 SimRequest frame_resource("https://example.com/iframe.html", "text/html");
860 SimRequest child_frame_resource("https://example.com/child-iframe.html", 947 SimRequest child_frame_resource("https://example.com/child-iframe.html",
861 "text/html"); 948 "text/html");
862 949
863 LoadURL("https://example.com/"); 950 LoadURL("https://example.com/");
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 // the child. This behavior matches Safari. 1222 // the child. This behavior matches Safari.
1136 frame_element->setAttribute(styleAttr, "display: none"); 1223 frame_element->setAttribute(styleAttr, "display: none");
1137 CompositeFrame(); 1224 CompositeFrame();
1138 EXPECT_FALSE( 1225 EXPECT_FALSE(
1139 frame_element->contentDocument()->View()->CanThrottleRendering()); 1226 frame_element->contentDocument()->View()->CanThrottleRendering());
1140 EXPECT_TRUE( 1227 EXPECT_TRUE(
1141 child_frame_element->contentDocument()->View()->CanThrottleRendering()); 1228 child_frame_element->contentDocument()->View()->CanThrottleRendering());
1142 } 1229 }
1143 1230
1144 } // namespace blink 1231 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698