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

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

Issue 2036403002: Always use the WebFrameWidget when attaching the root graphics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 webView->resize(WebSize(640, 480)); 430 webView->resize(WebSize(640, 480));
431 431
432 // Create a remote root frame with a local child frame. 432 // Create a remote root frame with a local child frame.
433 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 433 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
434 webView->setMainFrame(remoteClient.frame()); 434 webView->setMainFrame(remoteClient.frame());
435 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ; 435 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ;
436 436
437 WebFrameOwnerProperties properties; 437 WebFrameOwnerProperties properties;
438 WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame(); 438 WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame();
439 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(rootFrame); 439 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(rootFrame);
440 FrameTestHelpers::TestWebWidgetClient widgetClient;
441 WebWidget* widget = WebFrameWidget::create(&widgetClient, localFrame);
440 442
441 WebString baseURL("http://internal.test/"); 443 WebString baseURL("http://internal.test/");
442 URLTestHelpers::registerMockedURLFromBaseURL(baseURL, "simple_div.html"); 444 URLTestHelpers::registerMockedURLFromBaseURL(baseURL, "simple_div.html");
443 FrameTestHelpers::loadFrame(localFrame, baseURL.utf8() + "simple_div.html"); 445 FrameTestHelpers::loadFrame(localFrame, baseURL.utf8() + "simple_div.html");
444 446
445 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); 447 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
446 EXPECT_TRUE(frameView->frame().isLocalRoot()); 448 EXPECT_TRUE(frameView->frame().isLocalRoot());
447 449
448 // Enable throttling for the child frame. 450 // Enable throttling for the child frame.
449 frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->heigh t())); 451 frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->heigh t()));
450 frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::crea teUnique()); 452 frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::crea teUnique());
451 frameView->updateAllLifecyclePhases(); 453 frameView->updateAllLifecyclePhases();
452 testing::runPendingTasks(); 454 testing::runPendingTasks();
453 EXPECT_TRUE(frameView->canThrottleRendering()); 455 EXPECT_TRUE(frameView->canThrottleRendering());
454 456
455 Document* frameDocument = frameView->frame().document(); 457 Document* frameDocument = frameView->frame().document();
456 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state()) ; 458 EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state()) ;
457 459
458 // Mutate the local child frame contents. 460 // Mutate the local child frame contents.
459 auto* divElement = frameDocument->getElementById("div"); 461 auto* divElement = frameDocument->getElementById("div");
460 divElement->setAttribute(styleAttr, "width: 50px"); 462 divElement->setAttribute(styleAttr, "width: 50px");
461 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state()); 463 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
462 464
463 // Update the lifecycle again. The frame's lifecycle should not advance 465 // Update the lifecycle again. The frame's lifecycle should not advance
464 // because of throttling even though it is the local root. 466 // because of throttling even though it is the local root.
465 DocumentLifecycle::AllowThrottlingScope throttlingScope(frameDocument->lifec ycle()); 467 DocumentLifecycle::AllowThrottlingScope throttlingScope(frameDocument->lifec ycle());
466 frameView->updateAllLifecyclePhases(); 468 frameView->updateAllLifecyclePhases();
467 testing::runPendingTasks(); 469 testing::runPendingTasks();
468 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state()); 470 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
471 widget->close();
469 webView->close(); 472 webView->close();
470 } 473 }
471 474
472 TEST_F(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledFrame) 475 TEST_F(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledFrame)
473 { 476 {
474 webView().settings()->setAcceleratedCompositingEnabled(true); 477 webView().settings()->setAcceleratedCompositingEnabled(true);
475 478
476 // Create a hidden frame which is throttled. 479 // Create a hidden frame which is throttled.
477 SimRequest mainResource("https://example.com/", "text/html"); 480 SimRequest mainResource("https://example.com/", "text/html");
478 SimRequest frameResource("https://example.com/iframe.html", "text/html"); 481 SimRequest frameResource("https://example.com/iframe.html", "text/html");
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 localFrame->script().executeScriptInMainWorld( 848 localFrame->script().executeScriptInMainWorld(
846 "window.requestAnimationFrame(function() {\n" 849 "window.requestAnimationFrame(function() {\n"
847 " var throttledFrame = window.parent.frames.first;\n" 850 " var throttledFrame = window.parent.frames.first;\n"
848 " throttledFrame.document.documentElement.style = 'margin: 50px';\n" 851 " throttledFrame.document.documentElement.style = 'margin: 50px';\n"
849 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\ n" 852 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\ n"
850 "});\n"); 853 "});\n");
851 compositeFrame(); 854 compositeFrame();
852 } 855 }
853 856
854 } // namespace blink 857 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698