Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "web/WebLocalFrameImpl.h" | |
| 16 #include "web/WebRemoteFrameImpl.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 Loading... | |
| 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/"); | |
|
esprehn
2015/12/11 10:44:19
We need to get rid of the std::strings in FrameTes
Sami
2016/01/05 14:45:35
Done.
| |
| 276 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("simple_div.html")); | |
|
esprehn
2015/12/11 10:44:20
you don't need the fromUTF8, WebString can auto cr
Sami
2016/01/05 14:45:35
Neat, thanks.
| |
| 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(); | |
| 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 |
| OLD | NEW |