| 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 "core/dom/Document.h" | 6 #include "core/dom/Document.h" |
| 7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/html/HTMLIFrameElement.h" | 10 #include "core/html/HTMLIFrameElement.h" |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 802 |
| 803 // Simulate the paint for a graphics layer being externally invalidated | 803 // Simulate the paint for a graphics layer being externally invalidated |
| 804 // (e.g., by video playback). | 804 // (e.g., by video playback). |
| 805 frameDocument->view()->layoutViewItem().invalidatePaintForViewAndCompositedL
ayers(); | 805 frameDocument->view()->layoutViewItem().invalidatePaintForViewAndCompositedL
ayers(); |
| 806 | 806 |
| 807 // The layer inside the throttled frame should not get painted. | 807 // The layer inside the throttled frame should not get painted. |
| 808 auto displayItems2 = compositeFrame(); | 808 auto displayItems2 = compositeFrame(); |
| 809 EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "red")); | 809 EXPECT_FALSE(displayItems2.contains(SimCanvas::Rect, "red")); |
| 810 } | 810 } |
| 811 | 811 |
| 812 TEST_F(FrameThrottlingTest, SynchronousLayoutInAnimationFrameCallback) |
| 813 { |
| 814 webView().settings()->setJavaScriptEnabled(true); |
| 815 |
| 816 // Prepare a page with two cross origin frames (from the same origin so they |
| 817 // are able to access eachother). |
| 818 SimRequest mainResource("https://example.com/", "text/html"); |
| 819 SimRequest firstFrameResource("https://thirdparty.com/first.html", "text/htm
l"); |
| 820 SimRequest secondFrameResource("https://thirdparty.com/second.html", "text/h
tml"); |
| 821 loadURL("https://example.com/"); |
| 822 mainResource.complete( |
| 823 "<iframe id=first name=first src='https://thirdparty.com/first.html'></i
frame>\n" |
| 824 "<iframe id=second name=second src='https://thirdparty.com/second.html'>
</iframe>"); |
| 825 |
| 826 // The first frame contains just a simple div. This frame will be made |
| 827 // throttled. |
| 828 firstFrameResource.complete("<div id=d>first frame</div>"); |
| 829 |
| 830 // The second frame just used to execute a requestAnimationFrame callback. |
| 831 secondFrameResource.complete(""); |
| 832 |
| 833 // Throttle the first frame. |
| 834 auto* firstFrameElement = toHTMLIFrameElement(document().getElementById("fir
st")); |
| 835 firstFrameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
| 836 compositeFrame(); |
| 837 EXPECT_TRUE(firstFrameElement->contentDocument()->view()->canThrottleRenderi
ng()); |
| 838 |
| 839 // Run a animation frame callback in the second frame which mutates the |
| 840 // contents of the first frame and causes a synchronous style update. This |
| 841 // should not result in an unexpected lifecycle state even if the first |
| 842 // frame is throttled during the animation frame callback. |
| 843 auto* secondFrameElement = toHTMLIFrameElement(document().getElementById("se
cond")); |
| 844 LocalFrame* localFrame = toLocalFrame(secondFrameElement->contentFrame()); |
| 845 localFrame->script().executeScriptInMainWorld( |
| 846 "window.requestAnimationFrame(function() {\n" |
| 847 " var throttledFrame = window.parent.frames.first;\n" |
| 848 " throttledFrame.document.documentElement.style = 'margin: 50px';\n" |
| 849 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\
n" |
| 850 "});\n"); |
| 851 compositeFrame(); |
| 852 } |
| 853 |
| 812 } // namespace blink | 854 } // namespace blink |
| OLD | NEW |