Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / printing / script-tests / page-break-before-avoid.js
blob7d335f7cdab9f84b6100b8818f608ac42bb58d05
1 description("Test for page-break-before:avoid");
3 function test()
5     createBlockWithRatioToPageHeight("page1", 0.5).style.pageBreakBefore = "always";
6     // A block 'page2-1' must move to the next page because the following block 'page2-2'
7     // has 'page-break-before:avoid' and both blocks cannot be placed in the current page
8     // at the same time.
9     createBlockWithRatioToPageHeight("page2-1", 0.3);
10     createBlockWithRatioToPageHeight("page2-2", 0.3).style.pageBreakBefore = "avoid";
12     createBlockWithRatioToPageHeight("page3-1", 0.5).style.pageBreakBefore = "always";
13     // A page break can occur inside of 'page3-3' block because it has child elements.
14     createBlockWithRatioToPageHeight("page3-2", 0.3);
15     createBlockWithNumberOfLines("page3-3", 10).style.pageBreakBefore = "avoid";
17     createBlockWithRatioToPageHeight("page5", 0.5).style.pageBreakBefore = "always";
18     // It seems unrealistic, but block 'page6-1' must move to the next page.
19     createBlockWithRatioToPageHeight("page6-1", 0.1);
20     createBlockWithRatioToPageHeight("page6-2", 0.1).style.pageBreakBefore = "avoid";
21     createBlockWithRatioToPageHeight("page6-3", 0.1).style.pageBreakBefore = "avoid";
22     createBlockWithRatioToPageHeight("page6-4", 0.1).style.pageBreakBefore = "avoid";
23     createBlockWithRatioToPageHeight("page6-5", 0.1).style.pageBreakBefore = "avoid";
24     createBlockWithRatioToPageHeight("page6-6", 0.1).style.pageBreakBefore = "avoid";
25     createBlockWithRatioToPageHeight("page6-7", 0.1).style.pageBreakBefore = "avoid";
27     // We don't define where block 'page7or8-1' is placed.
28     createBlockWithRatioToPageHeight("page7", 0.5).style.pageBreakBefore = "always";
29     createBlockWithRatioToPageHeight("page7or8-1", 0.1);
30     createBlockWithRatioToPageHeight("page7or8-2", 3).style.pageBreakBefore = "avoid";
31     createBlockWithRatioToPageHeight("page10", 0.1);
33     pageNumberForElementShouldBe("page1", 1);
34     pageNumberForElementShouldBe("page2-1", 2);
35     pageNumberForElementShouldBe("page2-2", 2);
37     pageNumberForElementShouldBe("page3-1", 3);
38     pageNumberForElementShouldBe("page3-2", 3);
39     pageNumberForElementShouldBe("page3-3", 3);
41     pageNumberForElementShouldBe("page5", 5);
42     pageNumberForElementShouldBe("page6-1", 6);
43     // Omit tests for intermediate blocks.
44     pageNumberForElementShouldBe("page6-7", 6);
46     pageNumberForElementShouldBe("page7", 7);
47     pageNumberForElementShouldBe("page10", 10);
49     document.body.removeChild(document.getElementById("sandbox"));
52 var successfullyParsed = true;