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

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

Issue 1972893002: Make sure newly created frames become throttled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, ThrottleNewlyCreatedFrame)
813 {
814 webView().settings()->setAcceleratedCompositingEnabled(true);
815 webView().settings()->setPreferCompositingToLCDTextEnabled(true);
816 webView().settings()->setJavaScriptEnabled(true);
817
818 SimRequest mainResource("https://example.com/", "text/html");
819 SimRequest frameResource("https://example.com/iframe.html", "text/html");
820
821 // Create an intermediate frame which is throttled.
822 loadURL("https://example.com/");
823 mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.htm l></iframe>");
824 frameResource.complete("");
825 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")) ;
826 frameElement->setAttribute(styleAttr, "transform: translateY(480px)");
827 compositeFrame();
828 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()) ;
829 auto* frameDocument = frameElement->contentDocument();
830
831 // Create a new child frame inside the throttled frame. Make sure it also
832 // has a composited layer.
833 LocalFrame* localFrame = toLocalFrame(frameElement->contentFrame());
834 localFrame->script().executeScriptInMainWorld(
835 "var frame = document.createElement('iframe');\n"
836 "frame.setAttribute('id', 'childFrame');\n"
837 "frame.setAttribute('style', 'transform: translateZ(0)');\n"
838 "document.body.appendChild(frame);\n");
839 auto* childFrameElement = toHTMLIFrameElement(frameDocument->getElementById( "childFrame"));
840 auto* childFrameDocument = childFrameElement->contentDocument();
841
842 // The frame starts out as unthrottled before it is assigned to a parent.
843 EXPECT_FALSE(childFrameDocument->view()->canThrottleRendering());
844
845 // Do a full lifecycle update including paint and without allowing
846 // throttling. This will cause the creation of graphics layers for the
847 // newly created frame.
848 childFrameDocument->view()->updateAllLifecyclePhases();
849
850 // The new frame should have immediately become throttled even though we
851 // didn't run any of the intersection observers yet.
852 EXPECT_TRUE(childFrameDocument->view()->canThrottleRendering());
853
854 // Invalidate paint for all layers in all views and mutate the child frame
855 // to cause it to repaint.
856 childFrameDocument->view()->layoutView()->invalidatePaintForViewAndComposite dLayers();
857 frameDocument->view()->layoutView()->invalidatePaintForViewAndCompositedLaye rs();
858 document().view()->layoutView()->invalidatePaintForViewAndCompositedLayers() ;
859 childFrameDocument->documentElement()->setAttribute(styleAttr, "background: red");
860
861 // Compositing should not fail with a document lifecycle assertion while
862 // while trying to paint the child frame.
863 compositeFrame();
864 }
865
812 } // namespace blink 866 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698