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

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

Issue 2333263002: Document::haveImportsLoaded() should return true when ignoring pending sheets (Closed)
Patch Set: Tests really added... Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/html/HTMLIFrameElement.h" 6 #include "core/html/HTMLIFrameElement.h"
7 #include "core/layout/api/LayoutViewItem.h" 7 #include "core/layout/api/LayoutViewItem.h"
8 #include "core/paint/PaintLayer.h" 8 #include "core/paint/PaintLayer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "web/tests/sim/SimCompositor.h" 10 #include "web/tests/sim/SimCompositor.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 // Finish loading the CSS resource (no change to painting). 335 // Finish loading the CSS resource (no change to painting).
336 cssBodyResource.complete("a { color: red; }"); 336 cssBodyResource.complete("a { color: red; }");
337 EXPECT_TRUE(document().isRenderingReady()); 337 EXPECT_TRUE(document().isRenderingReady());
338 338
339 // Finish the load, painting should stay enabled. 339 // Finish the load, painting should stay enabled.
340 mainResource.finish(); 340 mainResource.finish();
341 EXPECT_TRUE(document().isRenderingReady()); 341 EXPECT_TRUE(document().isRenderingReady());
342 } 342 }
343 343
344 // Regression test for crbug.com/646323
345 TEST_F(DocumentLoadingRenderingTest, ShouldNotPerformRepeatedLayoutWithPendingIm port)
346 {
347 SimRequest mainResource("https://example.com/test.html", "text/html");
348 SimRequest cssResource("https://example.com/test.css", "text/css");
349
350 loadURL("https://example.com/test.html");
351
352 mainResource.start();
353 mainResource.write("<!DOCTYPE html><div>foo bar.</div>");
354 compositor().beginFrame();
355
356 // Insert a pending sheet with @import.
357 mainResource.write("<style>@import url('test.css')</style>");
358
359 // Do a layout with pending sheet.
360 document().updateStyleAndLayoutIgnorePendingStylesheets();
361
362 // HTML import is required.
363 mainResource.write("<link rel=import>");
364
365 // updateStyleAndLayoutIgnorePendingStylesheets should not have nodes left
366 // with placeholder style, even there are pending imports.
367 document().updateStyleAndLayoutIgnorePendingStylesheets();
368 EXPECT_FALSE(document().hasNodesWithPlaceholderStyle());
369
370 {
371 DocumentLifecycle::DisallowTransitionScope disallowTransition(document() .lifecycle());
372
373 // The test crashes if updateStyleAndLayoutIgnorePendingStylesheets
374 // performs an extra layout, which happens if the last call left some
375 // nodes with placeholder style.
rune 2016/09/15 10:48:26 Not sure if I understood completely, but you mean
Xiaocheng 2016/09/15 11:28:30 Sorry for the confusion. I just want to check if t
rune 2016/09/15 12:37:54 Compare StyleEngine::styleForElementCount() before
376 document().updateStyleAndLayoutIgnorePendingStylesheets();
377 }
378
379 // The content of the pending sheet doesn't matter.
380 cssResource.complete("");
381 mainResource.finish();
382 }
383
384 // Regression test for a wrong fix to crbug.com/646323, which simply stops
385 // updateStyleAndLayoutIgnorePendingStylesheets from forcing layout when there
386 // are nodes with placeholder style.
387 TEST_F(DocumentLoadingRenderingTest, ShouldClearPlaceholderStyleWhenIgnoringPend ingStylesheet)
388 {
389 SimRequest mainResource("https://example.com/test.html", "text/html");
390 SimRequest cssResource("https://example.com/test.css", "text/css");
391
392 loadURL("https://example.com/test.html");
393
394 mainResource.start();
395 mainResource.write("<!DOCTYPE html>");
396
397 // Insert a render blocking pending stylesheet. Do not let it finish.
398 mainResource.write("<link rel=stylesheet href=test.css>");
399
400 // Insert a non-empty body.
401 mainResource.write("foo");
402
403 // Do a layout with the pending sheet ignored, so that <body> does not get a
404 // placeholder style.
405 document().updateStyleAndLayoutIgnorePendingStylesheets();
406 EXPECT_FALSE(document().hasNodesWithPlaceholderStyle());
407
408 // Insert a <div>, which should get a placeholder style later.
409 mainResource.write("<div>bar</div>");
410 EXPECT_TRUE(document().needsLayoutTreeUpdate());
411
412 // <div> gets a placeholder style if the pending sheet is not ignored.
413 document().updateStyleAndLayout();
414 EXPECT_TRUE(document().hasNodesWithPlaceholderStyle());
415 EXPECT_FALSE(document().needsLayoutTreeUpdate());
416
417 // updateStyleAndLayoutIgnorePendingStylesheets should clear the placeholder
418 // style and redo layout, even if we have just finished one.
419 document().updateStyleAndLayoutIgnorePendingStylesheets();
420 EXPECT_FALSE(document().hasNodesWithPlaceholderStyle());
421
422 // The content of the pending sheet doesn't matter.
423 cssResource.complete("");
424 mainResource.finish();
425 }
344 426
345 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698