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

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: Fixed a memory leak in the test. Created 4 years, 11 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 "core/dom/Document.h" 5 #include "core/dom/Document.h"
6 #include "core/dom/Element.h" 6 #include "core/dom/Element.h"
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/html/HTMLIFrameElement.h" 8 #include "core/html/HTMLIFrameElement.h"
9 #include "platform/testing/URLTestHelpers.h"
9 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
10 #include "public/web/WebHitTestResult.h" 11 #include "public/web/WebHitTestResult.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "web/WebLocalFrameImpl.h"
14 #include "web/WebRemoteFrameImpl.h"
12 #include "web/tests/sim/SimCompositor.h" 15 #include "web/tests/sim/SimCompositor.h"
13 #include "web/tests/sim/SimDisplayItemList.h" 16 #include "web/tests/sim/SimDisplayItemList.h"
14 #include "web/tests/sim/SimRequest.h" 17 #include "web/tests/sim/SimRequest.h"
15 #include "web/tests/sim/SimTest.h" 18 #include "web/tests/sim/SimTest.h"
16 19
17 namespace blink { 20 namespace blink {
18 21
19 using namespace HTMLNames; 22 using namespace HTMLNames;
20 23
21 // NOTE: This test uses <iframe sandbox> to create cross origin iframes. 24 // NOTE: This test uses <iframe sandbox> to create cross origin iframes.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 247
245 // Change the size of a div in the throttled frame. 248 // Change the size of a div in the throttled frame.
246 auto* divElement = frameElement->contentDocument()->getElementById("div"); 249 auto* divElement = frameElement->contentDocument()->getElementById("div");
247 divElement->setAttribute(styleAttr, "width: 50px"); 250 divElement->setAttribute(styleAttr, "width: 50px");
248 251
249 // Querying the width of the div should do a synchronous layout update even 252 // Querying the width of the div should do a synchronous layout update even
250 // though the frame is being throttled. 253 // though the frame is being throttled.
251 EXPECT_EQ(50, divElement->clientWidth()); 254 EXPECT_EQ(50, divElement->clientWidth());
252 } 255 }
253 256
257 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
258 {
259 FrameTestHelpers::TestWebViewClient viewClient;
260 WebViewImpl* webView = WebViewImpl::create(&viewClient);
261 webView->resize(WebSize(640, 480));
262
263 // Create a remote root frame with a local child frame.
264 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
265 webView->setMainFrame(remoteClient.frame());
266 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ;
267
268 WebFrameOwnerProperties properties;
269 FrameTestHelpers::TestWebFrameClient localFrameClient;
270 WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame();
271 WebLocalFrame* localFrame = rootFrame->createLocalChild(WebTreeScopeType::Do cument, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
272
273 WebString baseURL("http://internal.test/");
274 URLTestHelpers::registerMockedURLFromBaseURL(baseURL, "simple_div.html");
275 FrameTestHelpers::loadFrame(localFrame, baseURL.utf8() + "simple_div.html");
276
277 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
278 EXPECT_TRUE(frameView->frame().isLocalRoot());
279
280 // Enable throttling for the child frame.
281 frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->heigh t()));
282 frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::crea teUnique());
283 frameView->updateAllLifecyclePhases();
284 testing::runPendingTasks();
285 EXPECT_TRUE(frameView->shouldThrottleRendering());
286
287 Document* frameDocument = frameView->frame().document();
288 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled())
289 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().stat e());
290 else
291 EXPECT_EQ(DocumentLifecycle::PaintInvalidationClean, frameDocument->life cycle().state());
292
293 // Mutate the local child frame contents.
294 auto* divElement = frameDocument->getElementById("div");
295 divElement->setAttribute(styleAttr, "width: 50px");
296 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
297
298 // Update the lifecycle again. The frame's lifecycle should not advance
299 // because of throttling even though it is the local root.
300 frameView->updateAllLifecyclePhases();
301 testing::runPendingTasks();
302 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
303 webView->close();
304 }
305
254 } // namespace blink 306 } // 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