| 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 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 // Initially the frame is throttled as it is offscreen. | 1044 // Initially the frame is throttled as it is offscreen. |
| 1045 compositeFrame(); | 1045 compositeFrame(); |
| 1046 EXPECT_TRUE(frameDocument->view()->canThrottleRendering()); | 1046 EXPECT_TRUE(frameDocument->view()->canThrottleRendering()); |
| 1047 | 1047 |
| 1048 // Setting display:none unthrottles the frame. | 1048 // Setting display:none unthrottles the frame. |
| 1049 frameElement->setAttribute(styleAttr, "display: none"); | 1049 frameElement->setAttribute(styleAttr, "display: none"); |
| 1050 compositeFrame(); | 1050 compositeFrame(); |
| 1051 EXPECT_FALSE(frameDocument->view()->canThrottleRendering()); | 1051 EXPECT_FALSE(frameDocument->view()->canThrottleRendering()); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 TEST_P(FrameThrottlingTest, DisplayNoneChildrenRemainThrottled) { |
| 1055 // Create two nested frames which are throttled. |
| 1056 SimRequest mainResource("https://example.com/", "text/html"); |
| 1057 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| 1058 SimRequest childFrameResource("https://example.com/child-iframe.html", |
| 1059 "text/html"); |
| 1060 |
| 1061 loadURL("https://example.com/"); |
| 1062 mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>"); |
| 1063 frameResource.complete( |
| 1064 "<iframe id=child-frame sandbox src=child-iframe.html></iframe>"); |
| 1065 childFrameResource.complete(""); |
| 1066 |
| 1067 // Move both frames offscreen to make them throttled. |
| 1068 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")); |
| 1069 auto* childFrameElement = toHTMLIFrameElement( |
| 1070 frameElement->contentDocument()->getElementById("child-frame")); |
| 1071 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
| 1072 compositeFrame(); |
| 1073 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()); |
| 1074 EXPECT_TRUE( |
| 1075 childFrameElement->contentDocument()->view()->canThrottleRendering()); |
| 1076 |
| 1077 // Setting display:none for the parent frame unthrottles the parent but not |
| 1078 // the child. This behavior matches Safari. |
| 1079 frameElement->setAttribute(styleAttr, "display: none"); |
| 1080 compositeFrame(); |
| 1081 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()); |
| 1082 EXPECT_TRUE( |
| 1083 childFrameElement->contentDocument()->view()->canThrottleRendering()); |
| 1084 } |
| 1085 |
| 1054 } // namespace blink | 1086 } // namespace blink |
| OLD | NEW |