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

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

Issue 1411463004: Allow local root FrameView to be throttled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 1 month 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 "config.h" 5 #include "config.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/html/HTMLIFrameElement.h" 10 #include "core/html/HTMLIFrameElement.h"
11 #include "platform/testing/URLTestHelpers.h"
11 #include "platform/testing/UnitTestHelpers.h" 12 #include "platform/testing/UnitTestHelpers.h"
12 #include "public/web/WebHitTestResult.h" 13 #include "public/web/WebHitTestResult.h"
14 #include "public/web/WebRemoteFrame.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "web/WebLocalFrameImpl.h"
14 #include "web/tests/sim/SimCompositor.h" 17 #include "web/tests/sim/SimCompositor.h"
15 #include "web/tests/sim/SimDisplayItemList.h" 18 #include "web/tests/sim/SimDisplayItemList.h"
16 #include "web/tests/sim/SimRequest.h" 19 #include "web/tests/sim/SimRequest.h"
17 #include "web/tests/sim/SimTest.h" 20 #include "web/tests/sim/SimTest.h"
18 21
19 namespace blink { 22 namespace blink {
20 23
21 using namespace HTMLNames; 24 using namespace HTMLNames;
22 25
23 // NOTE: This test uses <iframe sandbox> to create cross origin iframes. 26 // NOTE: This test uses <iframe sandbox> to create cross origin iframes.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 249
247 // Change the size of a div in the throttled frame. 250 // Change the size of a div in the throttled frame.
248 auto* divElement = frameElement->contentDocument()->getElementById("div"); 251 auto* divElement = frameElement->contentDocument()->getElementById("div");
249 divElement->setAttribute(styleAttr, "width: 50px"); 252 divElement->setAttribute(styleAttr, "width: 50px");
250 253
251 // Querying the width of the div should do a synchronous layout update even 254 // Querying the width of the div should do a synchronous layout update even
252 // though the frame is being throttled. 255 // though the frame is being throttled.
253 EXPECT_EQ(50, divElement->clientWidth()); 256 EXPECT_EQ(50, divElement->clientWidth());
254 } 257 }
255 258
259 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
260 {
261 FrameTestHelpers::TestWebViewClient viewClient;
262 WebViewImpl* webView = WebViewImpl::create(&viewClient);
263 webView->resize(WebSize(640, 480));
264
265 // Create a remote root frame with a local child frame.
266 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
267 webView->setMainFrame(remoteClient.frame());
268 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ;
269
270 WebFrameOwnerProperties properties;
271 FrameTestHelpers::TestWebFrameClient localFrameClient;
272 WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame();
273 WebLocalFrame* localFrame = rootFrame->createLocalChild(WebTreeScopeType::Do cument, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
274
275 std::string baseURL("http://internal.test/");
276 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("simple_div.html"));
277 FrameTestHelpers::loadFrame(localFrame, baseURL + "simple_div.html");
278
279 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
280 EXPECT_TRUE(frameView->frame().isLocalRoot());
281
282 // Enable throttling for the child frame.
283 frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->heigh t()));
284 frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::crea teUnique());
285 frameView->updateAllLifecyclePhases();
ojan 2015/12/01 01:11:05 Can this be tested via pumping a frame through the
Charlie Reis 2015/12/01 23:24:46 Daniel, can you check whether there's a better way
dcheng 2015/12/02 22:42:28 oopi isn't really controlled by any flags in Blink
286 testing::runPendingTasks();
287 EXPECT_TRUE(frameView->shouldThrottleRendering());
288
289 Document* frameDocument = frameView->frame().document();
290 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled())
291 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().stat e());
292 else
293 EXPECT_EQ(DocumentLifecycle::PaintInvalidationClean, frameDocument->life cycle().state());
294
295 // Mutate the local child frame contents.
296 auto* divElement = frameDocument->getElementById("div");
297 divElement->setAttribute(styleAttr, "width: 50px");
298 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
299
300 // Update the lifecycle again. The frame's lifecycle should not advance
301 // because of throttling even though it is the local root.
302 frameView->updateAllLifecyclePhases();
303 testing::runPendingTasks();
304 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
305 }
306
256 } // namespace blink 307 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698