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

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

Issue 1890913005: Update widget geometries when transforming a layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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/paint/PaintLayer.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 "core/page/FocusController.h"
10 #include "core/page/Page.h"
9 #include "platform/testing/URLTestHelpers.h" 11 #include "platform/testing/URLTestHelpers.h"
10 #include "platform/testing/UnitTestHelpers.h" 12 #include "platform/testing/UnitTestHelpers.h"
11 #include "public/web/WebHitTestResult.h" 13 #include "public/web/WebHitTestResult.h"
14 #include "public/web/WebSettings.h"
12 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
13 #include "web/WebLocalFrameImpl.h" 16 #include "web/WebLocalFrameImpl.h"
14 #include "web/WebRemoteFrameImpl.h" 17 #include "web/WebRemoteFrameImpl.h"
15 #include "web/tests/sim/SimCompositor.h" 18 #include "web/tests/sim/SimCompositor.h"
16 #include "web/tests/sim/SimDisplayItemList.h" 19 #include "web/tests/sim/SimDisplayItemList.h"
17 #include "web/tests/sim/SimRequest.h" 20 #include "web/tests/sim/SimRequest.h"
18 #include "web/tests/sim/SimTest.h" 21 #include "web/tests/sim/SimTest.h"
19 22
20 namespace blink { 23 namespace blink {
21 24
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll); 345 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll);
343 auto displayItems = compositeFrame(); 346 auto displayItems = compositeFrame();
344 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "red")); 347 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "red"));
345 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "green")); 348 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "green"));
346 349
347 // Make sure the new style shows up instead of the old one. 350 // Make sure the new style shows up instead of the old one.
348 auto displayItems2 = compositeFrame(); 351 auto displayItems2 = compositeFrame();
349 EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green")); 352 EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green"));
350 } 353 }
351 354
355 TEST_F(FrameThrottlingTest, ThrottledFrameWithFocus)
356 {
357 webView().settings()->setJavaScriptEnabled(true);
358 webView().settings()->setAcceleratedCompositingEnabled(true);
359 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true);
360
361 // Create a hidden frame which is throttled and has a text selection.
362 SimRequest mainResource("https://example.com/", "text/html");
363 SimRequest frameResource("https://example.com/iframe.html", "text/html");
364
365 loadURL("https://example.com/");
366 mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.htm l></iframe>");
367 frameResource.complete(
368 "some text to select\n"
369 "<script>\n"
370 "var range = document.createRange();\n"
371 "range.selectNode(document.body);\n"
372 "window.getSelection().addRange(range);\n"
373 "</script>\n");
374
375 // Move the frame offscreen to throttle it.
376 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")) ;
377 frameElement->setAttribute(styleAttr, "transform: translateY(480px)");
378 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering() );
379 compositeFrame();
380 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()) ;
381
382 // Give the frame focus and do another composite. The selection in the
383 // compositor should be cleared because the frame is throttled.
384 EXPECT_FALSE(compositor().hasSelection());
385 document().page()->focusController().setFocusedFrame(frameElement->contentDo cument()->frame());
386 document().body()->setAttribute(styleAttr, "background: green");
387 compositeFrame();
388 EXPECT_FALSE(compositor().hasSelection());
389 }
390
352 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot) 391 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
353 { 392 {
354 FrameTestHelpers::TestWebViewClient viewClient; 393 FrameTestHelpers::TestWebViewClient viewClient;
355 WebViewImpl* webView = WebViewImpl::create(&viewClient); 394 WebViewImpl* webView = WebViewImpl::create(&viewClient);
356 webView->resize(WebSize(640, 480)); 395 webView->resize(WebSize(640, 480));
357 396
358 // Create a remote root frame with a local child frame. 397 // Create a remote root frame with a local child frame.
359 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 398 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
360 webView->setMainFrame(remoteClient.frame()); 399 webView->setMainFrame(remoteClient.frame());
361 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ; 400 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ;
(...skipping 27 matching lines...) Expand all
389 // Update the lifecycle again. The frame's lifecycle should not advance 428 // Update the lifecycle again. The frame's lifecycle should not advance
390 // because of throttling even though it is the local root. 429 // because of throttling even though it is the local root.
391 DocumentLifecycle::AllowThrottlingScope throttlingScope(frameDocument->lifec ycle()); 430 DocumentLifecycle::AllowThrottlingScope throttlingScope(frameDocument->lifec ycle());
392 frameView->updateAllLifecyclePhases(); 431 frameView->updateAllLifecyclePhases();
393 testing::runPendingTasks(); 432 testing::runPendingTasks();
394 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state()); 433 EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle() .state());
395 webView->close(); 434 webView->close();
396 } 435 }
397 436
398 } // namespace blink 437 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698