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 "core/dom/Document.h" | 5 #include "core/dom/Document.h" |
6 #include "core/dom/FrameRequestCallback.h" | 6 #include "core/dom/FrameRequestCallback.h" |
7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
8 #include "core/layout/api/LayoutViewItem.h" | 8 #include "core/layout/api/LayoutViewItem.h" |
9 #include "core/paint/PaintLayer.h" | 9 #include "core/paint/PaintLayer.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "web/tests/sim/SimCompositor.h" | 12 #include "web/tests/sim/SimCompositor.h" |
12 #include "web/tests/sim/SimDisplayItemList.h" | 13 #include "web/tests/sim/SimDisplayItemList.h" |
13 #include "web/tests/sim/SimRequest.h" | 14 #include "web/tests/sim/SimRequest.h" |
14 #include "web/tests/sim/SimTest.h" | 15 #include "web/tests/sim/SimTest.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 using namespace HTMLNames; | 19 using namespace HTMLNames; |
19 | 20 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 374 |
374 // Finish loading the CSS resource (no change to painting). | 375 // Finish loading the CSS resource (no change to painting). |
375 cssBodyResource.complete("a { color: red; }"); | 376 cssBodyResource.complete("a { color: red; }"); |
376 EXPECT_TRUE(document().isRenderingReady()); | 377 EXPECT_TRUE(document().isRenderingReady()); |
377 | 378 |
378 // Finish the load, painting should stay enabled. | 379 // Finish the load, painting should stay enabled. |
379 mainResource.finish(); | 380 mainResource.finish(); |
380 EXPECT_TRUE(document().isRenderingReady()); | 381 EXPECT_TRUE(document().isRenderingReady()); |
381 } | 382 } |
382 | 383 |
| 384 TEST_F(DocumentLoadingRenderingTest, |
| 385 ShouldPauseParsingForExternalStylesheetsInBody) { |
| 386 SimRequest mainResource("https://example.com/test.html", "text/html"); |
| 387 SimRequest cssHeadResource("https://example.com/testHead.css", "text/css"); |
| 388 SimRequest cssBodyResource("https://example.com/testBody.css", "text/css"); |
| 389 |
| 390 loadURL("https://example.com/test.html"); |
| 391 |
| 392 mainResource.complete( |
| 393 "<!DOCTYPE html>" |
| 394 "<html><head>" |
| 395 "<link rel=stylesheet href=testHead.css>" |
| 396 "</head><body>" |
| 397 "<div id=\"before\"></div>" |
| 398 "<link rel=stylesheet href=testBody.css>" |
| 399 "<div id=\"after\"></div>" |
| 400 "</body></html>"); |
| 401 |
| 402 // Head and body css are pending. The "before" div should exist on the DOM but |
| 403 // "after" should not get created until the body css loads. That way with |
| 404 // rendering unblocked for body css the content that may depend on the |
| 405 // css will not flash with an incorrect style before the css loads. |
| 406 EXPECT_TRUE(document().getElementById("before")); |
| 407 EXPECT_FALSE(document().getElementById("after")); |
| 408 |
| 409 // Completing the head css shouldn't change anything |
| 410 cssHeadResource.complete(""); |
| 411 EXPECT_TRUE(document().getElementById("before")); |
| 412 EXPECT_FALSE(document().getElementById("after")); |
| 413 |
| 414 // Completing the body resource and pumping the tasks should continue creating |
| 415 // the dom and create the "after" div. |
| 416 cssBodyResource.complete(""); |
| 417 testing::runPendingTasks(); |
| 418 EXPECT_TRUE(document().getElementById("before")); |
| 419 EXPECT_TRUE(document().getElementById("after")); |
| 420 } |
| 421 |
383 } // namespace blink | 422 } // namespace blink |
OLD | NEW |