Chromium Code Reviews| 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()->layoutView()->invalidatePaintForViewAndCompositedLaye rs(); | 805 frameDocument->view()->layoutView()->invalidatePaintForViewAndCompositedLaye rs(); |
| 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, SynchronousLayoutInRequestAnimationFrameCallback) | |
| 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 page has a script which, inside a requestAnimationFrame | |
| 831 // callback, mutates the first (throttled) frame's contents and then | |
| 832 // requests a synchronous style computation of that first frame. | |
| 833 secondFrameResource.complete( | |
| 834 "<script>" | |
| 835 "window.addEventListener('load', function() {\n" | |
| 836 // Set up the rAF callback after a delay. Otherwise it will get serviced | |
| 837 // as a part of the first composition pass. | |
| 838 " window.setTimeout(function() {\n" | |
|
esprehn
2016/05/19 18:53:59
I don't think we want this delay, just run the rig
Sami
2016/05/19 19:05:20
Good point, done.
| |
| 839 " window.requestAnimationFrame(function() {\n" | |
| 840 " var throttledFrame = window.parent.frames['first'];\n" | |
| 841 " throttledFrame.document.documentElement.style = 'margin: 50px';\n " | |
| 842 " throttledFrame.document.querySelector('#d').getBoundingClientRect ();\n" | |
| 843 " });\n" | |
| 844 " }, 0);\n" | |
| 845 "});\n" | |
| 846 "</script>\n"); | |
| 847 | |
| 848 // Throttle the first frame. | |
| 849 auto* firstFrameElement = toHTMLIFrameElement(document().getElementById("fir st")); | |
| 850 firstFrameElement->setAttribute(styleAttr, "transform: translateY(480px)"); | |
| 851 compositeFrame(); | |
| 852 EXPECT_TRUE(firstFrameElement->contentDocument()->view()->canThrottleRenderi ng()); | |
| 853 | |
| 854 // Service the requestAnimationFrame for the second frame. This should not | |
| 855 // result in an unexpected lifecycle state even if the first frame is | |
| 856 // throttled during the requestAnimationFrame callback. | |
| 857 compositeFrame(); | |
| 858 } | |
| 859 | |
| 812 } // namespace blink | 860 } // namespace blink |
| OLD | NEW |