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

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

Issue 1891453002: Don't try to render composited selection in throttled frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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"
12 #include "public/web/WebSettings.h" 14 #include "public/web/WebSettings.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include "web/WebLocalFrameImpl.h" 16 #include "web/WebLocalFrameImpl.h"
15 #include "web/WebRemoteFrameImpl.h" 17 #include "web/WebRemoteFrameImpl.h"
16 #include "web/tests/sim/SimCompositor.h" 18 #include "web/tests/sim/SimCompositor.h"
17 #include "web/tests/sim/SimDisplayItemList.h" 19 #include "web/tests/sim/SimDisplayItemList.h"
18 #include "web/tests/sim/SimRequest.h" 20 #include "web/tests/sim/SimRequest.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll); 345 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll);
344 auto displayItems = compositeFrame(); 346 auto displayItems = compositeFrame();
345 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "red")); 347 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "red"));
346 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "green")); 348 EXPECT_FALSE(displayItems.contains(SimCanvas::Rect, "green"));
347 349
348 // 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.
349 auto displayItems2 = compositeFrame(); 351 auto displayItems2 = compositeFrame();
350 EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green")); 352 EXPECT_TRUE(displayItems2.contains(SimCanvas::Rect, "green"));
351 } 353 }
352 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
353 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot) 391 TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
354 { 392 {
355 FrameTestHelpers::TestWebViewClient viewClient; 393 FrameTestHelpers::TestWebViewClient viewClient;
356 WebViewImpl* webView = WebViewImpl::create(&viewClient); 394 WebViewImpl* webView = WebViewImpl::create(&viewClient);
357 webView->resize(WebSize(640, 480)); 395 webView->resize(WebSize(640, 480));
358 396
359 // Create a remote root frame with a local child frame. 397 // Create a remote root frame with a local child frame.
360 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 398 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
361 webView->setMainFrame(remoteClient.frame()); 399 webView->setMainFrame(remoteClient.frame());
362 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ; 400 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique()) ;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 471
434 // Scroll down to unthrottle the frame. 472 // Scroll down to unthrottle the frame.
435 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll); 473 webView().mainFrameImpl()->frameView()->setScrollPosition(DoublePoint(0, 480 ), ProgrammaticScroll);
436 document().view()->updateAllLifecyclePhases(); 474 document().view()->updateAllLifecyclePhases();
437 testing::runPendingTasks(); 475 testing::runPendingTasks();
438 // The fixed background in the throttled sub frame should be considered. 476 // The fixed background in the throttled sub frame should be considered.
439 EXPECT_TRUE(document().view()->shouldScrollOnMainThread()); 477 EXPECT_TRUE(document().view()->shouldScrollOnMainThread());
440 } 478 }
441 479
442 } // namespace blink 480 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | third_party/WebKit/Source/web/tests/sim/SimCompositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698