1 description("Test for page-break-after:avoid");
5 createBlockWithRatioToPageHeight("page1", 0.5).style.pageBreakBefore = "always";
6 // A block 'page2-1' must move to the next page because it has 'page-break-after:avoid'
7 // and both 'page2-1' and 'page2-2' cannot be placed in the current page at the same time.
8 createBlockWithRatioToPageHeight("page2-1", 0.3).style.pageBreakAfter = "avoid";
9 createBlockWithRatioToPageHeight("page2-2", 0.3);
11 createBlockWithRatioToPageHeight("page3-1", 0.5).style.pageBreakBefore = "always";
12 // A page break can occur inside of 'page3-3' block because it has child elements.
13 createBlockWithRatioToPageHeight("page3-2", 0.3).style.pageBreakAfter = "avoid";
14 createBlockWithNumberOfLines("page3-3", 10);
16 createBlockWithRatioToPageHeight("page5", 0.5).style.pageBreakBefore = "always";
17 // It seems unrealistic, but block 'page6-1' must move to the next page.
18 createBlockWithRatioToPageHeight("page6-1", 0.1).style.pageBreakAfter = "avoid";
19 createBlockWithRatioToPageHeight("page6-2", 0.1).style.pageBreakAfter = "avoid";
20 createBlockWithRatioToPageHeight("page6-3", 0.1).style.pageBreakAfter = "avoid";
21 createBlockWithRatioToPageHeight("page6-4", 0.1).style.pageBreakAfter = "avoid";
22 createBlockWithRatioToPageHeight("page6-5", 0.1).style.pageBreakAfter = "avoid";
23 createBlockWithRatioToPageHeight("page6-6", 0.1).style.pageBreakAfter = "avoid";
24 createBlockWithRatioToPageHeight("page6-7", 0.1);
27 pageNumberForElementShouldBe("page1", 1);
28 pageNumberForElementShouldBe("page2-1", 2);
29 pageNumberForElementShouldBe("page2-2", 2);
31 pageNumberForElementShouldBe("page3-1", 3);
32 pageNumberForElementShouldBe("page3-2", 3);
33 pageNumberForElementShouldBe("page3-3", 3);
35 pageNumberForElementShouldBe("page5", 5);
36 pageNumberForElementShouldBe("page6-1", 6);
37 // Omit tests for intermediate blocks.
38 pageNumberForElementShouldBe("page6-7", 6);
40 document.body.removeChild(document.getElementById("sandbox"));
43 var successfullyParsed = true;