OLD | NEW |
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 27 matching lines...) Expand all Loading... |
38 using namespace HTMLNames; | 38 using namespace HTMLNames; |
39 | 39 |
40 // NOTE: This test uses <iframe sandbox> to create cross origin iframes. | 40 // NOTE: This test uses <iframe sandbox> to create cross origin iframes. |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 class MockWebDisplayItemList : public WebDisplayItemList { | 44 class MockWebDisplayItemList : public WebDisplayItemList { |
45 public: | 45 public: |
46 ~MockWebDisplayItemList() override {} | 46 ~MockWebDisplayItemList() override {} |
47 | 47 |
48 MOCK_METHOD2(AppendDrawingItem, | 48 MOCK_METHOD3(AppendDrawingItem, |
49 void(const WebRect&, sk_sp<const PaintRecord>)); | 49 void(const WebRect& visual_rect, |
| 50 sk_sp<const cc::PaintRecord>, |
| 51 const WebRect& record_bounds)); |
50 }; | 52 }; |
51 | 53 |
52 void PaintRecursively(GraphicsLayer* layer, WebDisplayItemList* display_items) { | 54 void PaintRecursively(GraphicsLayer* layer, WebDisplayItemList* display_items) { |
53 if (layer->DrawsContent()) { | 55 if (layer->DrawsContent()) { |
54 layer->SetNeedsDisplay(); | 56 layer->SetNeedsDisplay(); |
55 layer->ContentLayerDelegateForTesting()->PaintContents( | 57 layer->ContentLayerDelegateForTesting()->PaintContents( |
56 display_items, ContentLayerDelegate::kPaintDefaultBehaviorForTest); | 58 display_items, ContentLayerDelegate::kPaintDefaultBehaviorForTest); |
57 } | 59 } |
58 for (const auto& child : layer->Children()) | 60 for (const auto& child : layer->Children()) |
59 PaintRecursively(child, display_items); | 61 PaintRecursively(child, display_items); |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 frame_element->setAttribute(styleAttr, | 840 frame_element->setAttribute(styleAttr, |
839 "transform: translateY(480px) translateZ(0px)"); | 841 "transform: translateY(480px) translateZ(0px)"); |
840 EXPECT_FALSE( | 842 EXPECT_FALSE( |
841 frame_element->contentDocument()->View()->CanThrottleRendering()); | 843 frame_element->contentDocument()->View()->CanThrottleRendering()); |
842 CompositeFrame(); | 844 CompositeFrame(); |
843 EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering()); | 845 EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering()); |
844 | 846 |
845 // If painting of the iframe is throttled, we should only receive two | 847 // If painting of the iframe is throttled, we should only receive two |
846 // drawing items. | 848 // drawing items. |
847 MockWebDisplayItemList display_items; | 849 MockWebDisplayItemList display_items; |
848 EXPECT_CALL(display_items, AppendDrawingItem(_, _)).Times(2); | 850 EXPECT_CALL(display_items, AppendDrawingItem(_, _, _)).Times(2); |
849 | 851 |
850 GraphicsLayer* layer = WebView().RootGraphicsLayer(); | 852 GraphicsLayer* layer = WebView().RootGraphicsLayer(); |
851 PaintRecursively(layer, &display_items); | 853 PaintRecursively(layer, &display_items); |
852 } | 854 } |
853 | 855 |
854 TEST_P(FrameThrottlingTest, ThrottleSubtreeAtomically) { | 856 TEST_P(FrameThrottlingTest, ThrottleSubtreeAtomically) { |
855 // Create two nested frames which are throttled. | 857 // Create two nested frames which are throttled. |
856 SimRequest main_resource("https://example.com/", "text/html"); | 858 SimRequest main_resource("https://example.com/", "text/html"); |
857 SimRequest frame_resource("https://example.com/iframe.html", "text/html"); | 859 SimRequest frame_resource("https://example.com/iframe.html", "text/html"); |
858 SimRequest child_frame_resource("https://example.com/child-iframe.html", | 860 SimRequest child_frame_resource("https://example.com/child-iframe.html", |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 // the child. This behavior matches Safari. | 1135 // the child. This behavior matches Safari. |
1134 frame_element->setAttribute(styleAttr, "display: none"); | 1136 frame_element->setAttribute(styleAttr, "display: none"); |
1135 CompositeFrame(); | 1137 CompositeFrame(); |
1136 EXPECT_FALSE( | 1138 EXPECT_FALSE( |
1137 frame_element->contentDocument()->View()->CanThrottleRendering()); | 1139 frame_element->contentDocument()->View()->CanThrottleRendering()); |
1138 EXPECT_TRUE( | 1140 EXPECT_TRUE( |
1139 child_frame_element->contentDocument()->View()->CanThrottleRendering()); | 1141 child_frame_element->contentDocument()->View()->CanThrottleRendering()); |
1140 } | 1142 } |
1141 | 1143 |
1142 } // namespace blink | 1144 } // namespace blink |
OLD | NEW |