Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp

Issue 2272773002: Use intersection observer to control frame throttling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase typo Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()); 771 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering());
772 EXPECT_FALSE( 772 EXPECT_FALSE(
773 childFrameElement->contentDocument()->view()->canThrottleRendering()); 773 childFrameElement->contentDocument()->view()->canThrottleRendering());
774 774
775 // Only run the intersection observer for the parent frame. Both frames 775 // Only run the intersection observer for the parent frame. Both frames
776 // should immediately become throttled. This simulates the case where a task 776 // should immediately become throttled. This simulates the case where a task
777 // such as BeginMainFrame runs in the middle of dispatching intersection 777 // such as BeginMainFrame runs in the middle of dispatching intersection
778 // observer notifications. 778 // observer notifications.
779 frameElement->contentDocument() 779 frameElement->contentDocument()
780 ->view() 780 ->view()
781 ->notifyRenderThrottlingObserversForTesting(); 781 ->updateRenderThrottlingStatusForTesting();
782 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()); 782 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
783 EXPECT_TRUE( 783 EXPECT_TRUE(
784 childFrameElement->contentDocument()->view()->canThrottleRendering()); 784 childFrameElement->contentDocument()->view()->canThrottleRendering());
785 785
786 // Both frames should still be throttled after the second notification. 786 // Both frames should still be throttled after the second notification.
787 childFrameElement->contentDocument() 787 childFrameElement->contentDocument()
788 ->view() 788 ->view()
789 ->notifyRenderThrottlingObserversForTesting(); 789 ->updateRenderThrottlingStatusForTesting();
790 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()); 790 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
791 EXPECT_TRUE( 791 EXPECT_TRUE(
792 childFrameElement->contentDocument()->view()->canThrottleRendering()); 792 childFrameElement->contentDocument()->view()->canThrottleRendering());
793
794 // Move the frame back on screen but don't update throttling yet.
795 frameElement->setAttribute(styleAttr, "transform: translateY(0px)");
796 compositor().beginFrame();
797 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
798 EXPECT_TRUE(
799 childFrameElement->contentDocument()->view()->canThrottleRendering());
800
801 // Update throttling for the child. It should remain throttled because the
802 // parent is still throttled.
803 childFrameElement->contentDocument()
804 ->view()
805 ->updateRenderThrottlingStatusForTesting();
806 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering());
807 EXPECT_TRUE(
808 childFrameElement->contentDocument()->view()->canThrottleRendering());
809
810 // Updating throttling on the parent should unthrottle both frames.
811 frameElement->contentDocument()
812 ->view()
813 ->updateRenderThrottlingStatusForTesting();
814 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering());
815 EXPECT_FALSE(
816 childFrameElement->contentDocument()->view()->canThrottleRendering());
793 } 817 }
794 818
795 TEST_F(FrameThrottlingTest, SkipPaintingLayersInThrottledFrames) { 819 TEST_F(FrameThrottlingTest, SkipPaintingLayersInThrottledFrames) {
796 webView().settings()->setAcceleratedCompositingEnabled(true); 820 webView().settings()->setAcceleratedCompositingEnabled(true);
797 webView().settings()->setPreferCompositingToLCDTextEnabled(true); 821 webView().settings()->setPreferCompositingToLCDTextEnabled(true);
798 822
799 SimRequest mainResource("https://example.com/", "text/html"); 823 SimRequest mainResource("https://example.com/", "text/html");
800 SimRequest frameResource("https://example.com/iframe.html", "text/html"); 824 SimRequest frameResource("https://example.com/iframe.html", "text/html");
801 825
802 loadURL("https://example.com/"); 826 loadURL("https://example.com/");
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 localFrame->script().executeScriptInMainWorld( 892 localFrame->script().executeScriptInMainWorld(
869 "window.requestAnimationFrame(function() {\n" 893 "window.requestAnimationFrame(function() {\n"
870 " var throttledFrame = window.parent.frames.first;\n" 894 " var throttledFrame = window.parent.frames.first;\n"
871 " throttledFrame.document.documentElement.style = 'margin: 50px';\n" 895 " throttledFrame.document.documentElement.style = 'margin: 50px';\n"
872 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\n" 896 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\n"
873 "});\n"); 897 "});\n");
874 compositeFrame(); 898 compositeFrame();
875 } 899 }
876 900
877 } // namespace blink 901 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698