| 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 "core/dom/Document.h" | 5 #include "core/dom/Document.h" |
| 6 #include "core/dom/Element.h" | 6 #include "core/dom/Element.h" |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/html/HTMLIFrameElement.h" | 8 #include "core/html/HTMLIFrameElement.h" |
| 9 #include "platform/testing/URLTestHelpers.h" | 9 #include "platform/testing/URLTestHelpers.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 auto* frameDocument = frameElement->contentDocument(); | 150 auto* frameDocument = frameElement->contentDocument(); |
| 151 | 151 |
| 152 // Enable throttling for the child frame. | 152 // Enable throttling for the child frame. |
| 153 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); | 153 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
| 154 compositeFrame(); | 154 compositeFrame(); |
| 155 EXPECT_TRUE(frameDocument->view()->canThrottleRendering()); | 155 EXPECT_TRUE(frameDocument->view()->canThrottleRendering()); |
| 156 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state())
; | 156 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state())
; |
| 157 | 157 |
| 158 // Mutating the throttled frame followed by a beginFrame will not result in | 158 // Mutating the throttled frame followed by a beginFrame will not result in |
| 159 // a complete lifecycle update. | 159 // a complete lifecycle update. |
| 160 // TODO(skyostil): these expectations are either wrong, or the test is |
| 161 // not exercising the code correctly. PaintClean means the entire lifecycle |
| 162 // ran. |
| 160 frameElement->setAttribute(widthAttr, "50"); | 163 frameElement->setAttribute(widthAttr, "50"); |
| 161 compositeFrame(); | 164 compositeFrame(); |
| 162 EXPECT_EQ(DocumentLifecycle::StyleClean, frameDocument->lifecycle().state())
; | 165 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state())
; |
| 163 | 166 |
| 164 // A hit test will not force a complete lifecycle update. | 167 // A hit test will not force a complete lifecycle update. |
| 165 webView().hitTestResultAt(WebPoint(0, 0)); | 168 webView().hitTestResultAt(WebPoint(0, 0)); |
| 166 EXPECT_EQ(DocumentLifecycle::StyleClean, frameDocument->lifecycle().state())
; | 169 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state())
; |
| 167 } | 170 } |
| 168 | 171 |
| 169 TEST_F(FrameThrottlingTest, UnthrottlingFrameSchedulesAnimation) | 172 TEST_F(FrameThrottlingTest, UnthrottlingFrameSchedulesAnimation) |
| 170 { | 173 { |
| 171 SimRequest mainResource("https://example.com/", "text/html"); | 174 SimRequest mainResource("https://example.com/", "text/html"); |
| 172 | 175 |
| 173 loadURL("https://example.com/"); | 176 loadURL("https://example.com/"); |
| 174 mainResource.complete("<iframe sandbox id=frame></iframe>"); | 177 mainResource.complete("<iframe sandbox id=frame></iframe>"); |
| 175 | 178 |
| 176 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"))
; | 179 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame"))
; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // Update the lifecycle again. The frame's lifecycle should not advance | 389 // Update the lifecycle again. The frame's lifecycle should not advance |
| 387 // because of throttling even though it is the local root. | 390 // because of throttling even though it is the local root. |
| 388 DocumentLifecycle::AllowThrottlingScope throttlingScope(frameDocument->lifec
ycle()); | 391 DocumentLifecycle::AllowThrottlingScope throttlingScope(frameDocument->lifec
ycle()); |
| 389 frameView->updateAllLifecyclePhases(); | 392 frameView->updateAllLifecyclePhases(); |
| 390 testing::runPendingTasks(); | 393 testing::runPendingTasks(); |
| 391 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle()
.state()); | 394 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle()
.state()); |
| 392 webView->close(); | 395 webView->close(); |
| 393 } | 396 } |
| 394 | 397 |
| 395 } // namespace blink | 398 } // namespace blink |
| OLD | NEW |