OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 |
| 7 #include "core/dom/Document.h" |
| 8 #include "web/WebLocalFrameImpl.h" |
| 9 #include "web/tests/FrameTestHelpers.h" |
| 10 #include "web/tests/sim/SimLayerTreeView.h" |
| 11 #include "web/tests/sim/SimNetwork.h" |
| 12 #include "web/tests/sim/SimRequest.h" |
| 13 #include "web/tests/sim/SimWebViewClient.h" |
| 14 #include <gtest/gtest.h> |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 class DocumentLoadingRenderingTest : public ::testing::Test { |
| 19 void SetUp() override |
| 20 { |
| 21 Document::setThreadedParsingEnabledForUnitTestsOnly(false); |
| 22 } |
| 23 |
| 24 void TearDown() override |
| 25 { |
| 26 Document::setThreadedParsingEnabledForUnitTestsOnly(true); |
| 27 } |
| 28 }; |
| 29 |
| 30 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterBodyParsedWithoutSh
eets) |
| 31 { |
| 32 SimLayerTreeView layerTreeView; |
| 33 SimWebViewClient webViewClient(layerTreeView); |
| 34 FrameTestHelpers::WebViewHelper webViewHelper; |
| 35 webViewHelper.initialize(true, nullptr, &webViewClient); |
| 36 |
| 37 SimNetwork network; |
| 38 SimRequest mainResource("https://example.com/test.html", "text/html"); |
| 39 |
| 40 WebURLRequest request; |
| 41 request.initialize(); |
| 42 request.setURL(KURL(ParsedURLString, "https://example.com/test.html")); |
| 43 |
| 44 webViewHelper.webViewImpl()->mainFrameImpl()->loadRequest(request); |
| 45 |
| 46 mainResource.start(); |
| 47 |
| 48 // Still in the head, should not resume commits. |
| 49 mainResource.write("<!DOCTYPE html>"); |
| 50 EXPECT_TRUE(layerTreeView.deferCommits()); |
| 51 mainResource.write("<title>Test</title><style>div { color red; }</style>"); |
| 52 EXPECT_TRUE(layerTreeView.deferCommits()); |
| 53 |
| 54 // Implicitly inserts the body. Since there's no loading stylesheets we |
| 55 // should resume commits. |
| 56 mainResource.write("<p>Hello World</p>"); |
| 57 EXPECT_FALSE(layerTreeView.deferCommits()); |
| 58 |
| 59 // Finish the load, should stay resumed. |
| 60 mainResource.finish(); |
| 61 EXPECT_FALSE(layerTreeView.deferCommits()); |
| 62 } |
| 63 |
| 64 } // namespace blink |
OLD | NEW |