| 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/html/HTMLIFrameElement.h" | 6 #include "core/html/HTMLIFrameElement.h" |
| 7 #include "platform/testing/UnitTestHelpers.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "web/tests/sim/SimCompositor.h" | 9 #include "web/tests/sim/SimCompositor.h" |
| 9 #include "web/tests/sim/SimDisplayItemList.h" | 10 #include "web/tests/sim/SimDisplayItemList.h" |
| 10 #include "web/tests/sim/SimRequest.h" | 11 #include "web/tests/sim/SimRequest.h" |
| 11 #include "web/tests/sim/SimTest.h" | 12 #include "web/tests/sim/SimTest.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 using namespace HTMLNames; | 16 using namespace HTMLNames; |
| 16 | 17 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 cssResource.start(); | 90 cssResource.start(); |
| 90 cssResource.write("a { color: red; }"); | 91 cssResource.write("a { color: red; }"); |
| 91 EXPECT_TRUE(compositor().deferCommits()); | 92 EXPECT_TRUE(compositor().deferCommits()); |
| 92 | 93 |
| 93 // Body inserted, but sheet is still loading so don't resume. | 94 // Body inserted, but sheet is still loading so don't resume. |
| 94 mainResource.write("<body>"); | 95 mainResource.write("<body>"); |
| 95 EXPECT_TRUE(compositor().deferCommits()); | 96 EXPECT_TRUE(compositor().deferCommits()); |
| 96 | 97 |
| 97 // Sheet finished and there's a body so resume. | 98 // Sheet finished and there's a body so resume. |
| 98 cssResource.finish(); | 99 cssResource.finish(); |
| 100 testing::runPendingTasks(); |
| 99 EXPECT_FALSE(compositor().deferCommits()); | 101 EXPECT_FALSE(compositor().deferCommits()); |
| 100 | 102 |
| 101 // Finish the load, should stay resumed. | 103 // Finish the load, should stay resumed. |
| 102 mainResource.finish(); | 104 mainResource.finish(); |
| 103 EXPECT_FALSE(compositor().deferCommits()); | 105 EXPECT_FALSE(compositor().deferCommits()); |
| 104 } | 106 } |
| 105 | 107 |
| 106 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterDocumentElementWith
NoSheets) | 108 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterDocumentElementWith
NoSheets) |
| 107 { | 109 { |
| 108 SimRequest mainResource("https://example.com/test.svg", "image/svg+xml"); | 110 SimRequest mainResource("https://example.com/test.svg", "image/svg+xml"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Root inserted, but sheet is still loading so don't resume. | 152 // Root inserted, but sheet is still loading so don't resume. |
| 151 mainResource.write("<svg xmlns='http://www.w3.org/2000/svg'></svg>"); | 153 mainResource.write("<svg xmlns='http://www.w3.org/2000/svg'></svg>"); |
| 152 EXPECT_TRUE(compositor().deferCommits()); | 154 EXPECT_TRUE(compositor().deferCommits()); |
| 153 | 155 |
| 154 // Finish the load, but sheets still loading so don't resume. | 156 // Finish the load, but sheets still loading so don't resume. |
| 155 mainResource.finish(); | 157 mainResource.finish(); |
| 156 EXPECT_TRUE(compositor().deferCommits()); | 158 EXPECT_TRUE(compositor().deferCommits()); |
| 157 | 159 |
| 158 // Sheet finished, so resume commits. | 160 // Sheet finished, so resume commits. |
| 159 cssResource.finish(); | 161 cssResource.finish(); |
| 162 testing::runPendingTasks(); |
| 160 EXPECT_FALSE(compositor().deferCommits()); | 163 EXPECT_FALSE(compositor().deferCommits()); |
| 161 } | 164 } |
| 162 | 165 |
| 163 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterFinishParsingXml) | 166 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterFinishParsingXml) |
| 164 { | 167 { |
| 165 SimRequest mainResource("https://example.com/test.svg", "image/svg+xml"); | 168 SimRequest mainResource("https://example.com/test.svg", "image/svg+xml"); |
| 166 | 169 |
| 167 loadURL("https://example.com/test.svg"); | 170 loadURL("https://example.com/test.svg"); |
| 168 | 171 |
| 169 mainResource.start(); | 172 mainResource.start(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 mainResource.start(); | 205 mainResource.start(); |
| 203 | 206 |
| 204 // Load a stylesheet. | 207 // Load a stylesheet. |
| 205 mainResource.write("<!DOCTYPE html><link id=link rel=stylesheet href=first.c
ss>"); | 208 mainResource.write("<!DOCTYPE html><link id=link rel=stylesheet href=first.c
ss>"); |
| 206 EXPECT_TRUE(compositor().deferCommits()); | 209 EXPECT_TRUE(compositor().deferCommits()); |
| 207 | 210 |
| 208 firstCssResource.start(); | 211 firstCssResource.start(); |
| 209 firstCssResource.write("body { color: red; }"); | 212 firstCssResource.write("body { color: red; }"); |
| 210 mainResource.write("<body>"); | 213 mainResource.write("<body>"); |
| 211 firstCssResource.finish(); | 214 firstCssResource.finish(); |
| 215 testing::runPendingTasks(); |
| 212 | 216 |
| 213 // Sheet finished and there's a body so resume. | 217 // Sheet finished and there's a body so resume. |
| 214 EXPECT_FALSE(compositor().deferCommits()); | 218 EXPECT_FALSE(compositor().deferCommits()); |
| 215 | 219 |
| 216 mainResource.finish(); | 220 mainResource.finish(); |
| 217 compositor().beginFrame(); | 221 compositor().beginFrame(); |
| 218 | 222 |
| 219 // Replace the stylesheet by changing href. | 223 // Replace the stylesheet by changing href. |
| 220 auto* element = document().getElementById("link"); | 224 auto* element = document().getElementById("link"); |
| 221 EXPECT_NE(nullptr, element); | 225 EXPECT_NE(nullptr, element); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 childFrame->contentDocument()->updateLayoutIgnorePendingStylesheets(); | 269 childFrame->contentDocument()->updateLayoutIgnorePendingStylesheets(); |
| 266 | 270 |
| 267 auto frame2 = compositor().beginFrame(); | 271 auto frame2 = compositor().beginFrame(); |
| 268 | 272 |
| 269 // The child frame still has pending sheets, and the parent frame has no | 273 // The child frame still has pending sheets, and the parent frame has no |
| 270 // invalid paint so we shouldn't draw any text. | 274 // invalid paint so we shouldn't draw any text. |
| 271 EXPECT_FALSE(frame2.containsText()); | 275 EXPECT_FALSE(frame2.containsText()); |
| 272 | 276 |
| 273 // 1 for the main frame background (white), | 277 // 1 for the main frame background (white), |
| 274 // 1 for the iframe background (pink) | 278 // 1 for the iframe background (pink) |
| 275 // 1 for the composited transform layer in the iframe (green). | |
| 276 // TODO(esprehn): Why FOUC the background (borders, etc.) of iframes and | 279 // TODO(esprehn): Why FOUC the background (borders, etc.) of iframes and |
| 277 // composited layers? Seems like a bug. | 280 // composited layers? Seems like a bug. |
| 278 EXPECT_EQ(3, frame2.drawCount()); | 281 EXPECT_EQ(2, frame2.drawCount()); |
| 279 EXPECT_TRUE(frame2.contains(SimCanvas::Rect, "white")); | 282 EXPECT_TRUE(frame2.contains(SimCanvas::Rect, "white")); |
| 280 EXPECT_TRUE(frame2.contains(SimCanvas::Rect, "pink")); | 283 EXPECT_TRUE(frame2.contains(SimCanvas::Rect, "pink")); |
| 281 EXPECT_TRUE(frame2.contains(SimCanvas::Rect, "green")); | 284 EXPECT_FALSE(frame2.contains(SimCanvas::Rect, "green")); |
| 282 | 285 |
| 283 // Finish loading the sheets in the child frame. After it should issue a | |
| 284 // paint invalidation for every layer since frame2 painted them but skipped | |
| 285 // painting the real content to avoid FOUC. | |
| 286 cssResource.complete(); | 286 cssResource.complete(); |
| 287 | 287 testing::runPendingTasks(); |
| 288 // First frame where all frames are loaded, should paint the text in the | |
| 289 // child frame. | |
| 290 auto frame3 = compositor().beginFrame(); | |
| 291 EXPECT_TRUE(frame3.containsText()); | |
| 292 } | 288 } |
| 293 | 289 |
| 294 } // namespace blink | 290 } // namespace blink |
| OLD | NEW |