Synchronous media query evaluation could destroy current Frame/FrameView.
[WebKit-https.git] / LayoutTests / printing / break-inside-avoid.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../resources/js-test-pre.js"></script>
5 <script src="resources/paged-media-test-utils.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10 <div id="sandbox"></div>
11 <script>
12 description("Test for page-break-inside:avoid");
13
14 function test()
15 {
16     createBlockWithRatioToPageHeight("page1-1", 0.5).style.breakBefore = "page";
17     // block 'page1-2' should be splitted.
18     createBlockWithNumberOfLines("page1-2", 20);
19     createBlockWithRatioToPageHeight("page2", 0.1);
20
21     createBlockWithRatioToPageHeight("page3", 0.5).style.breakBefore = "page";
22     // We should place block 'page4' in the next page because of 'page-break-inside: avoid'.
23     createBlockWithNumberOfLines("page4", 20).style.breakInside = "avoid";
24
25     createBlockWithRatioToPageHeight("page5", 0.8).style.breakBefore = "page";
26     // block 'page5-2' is a very large block, occupying more than 2 pages.
27     // We don't define from where this large block starts. Maybe from the next page.
28     createBlockWithNumberOfLines("page5or6", 20 * 2 + 10).style.breakInside = "avoid";
29     createBlockWithRatioToPageHeight("page8", 0.1);
30
31     createBlockWithRatioToPageHeight("page9-1", 0.1).style.breakBefore = "page";
32     createBlockWithRatioToPageHeight("page9-2", 0.1).style.breakAfter = "page";
33     // Make sure page-break only happens once, not twice.
34     createBlockWithNumberOfLines("page10", 20).style.breakInside = "avoid";
35
36     pageNumberForElementShouldBe('page1-1', 1);
37     pageNumberForElementShouldBe('page1-2', 1);
38     pageNumberForElementShouldBe('page2', 2);
39
40     pageNumberForElementShouldBe('page3', 3);
41     pageNumberForElementShouldBe('page4', 4);
42
43     pageNumberForElementShouldBe('page5', 5);
44     pageNumberForElementShouldBe('page8', 8);
45
46     pageNumberForElementShouldBe('page9-1', 9);
47     pageNumberForElementShouldBe('page9-2', 9);
48     pageNumberForElementShouldBe('page10', 10);
49
50     document.body.removeChild(document.getElementById("sandbox"));
51 }
52
53 var successfullyParsed = true;
54 </script>
55 <script>runPrintingTest(test);</script>
56 <script src="../resources/js-test-post.js"></script>
57 </body>
58 </html>