Revision control

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-before:avoid");
13
14
function test()
15
{
16
createBlockWithRatioToPageHeight("page1", 0.5).style.pageBreakBefore = "always";
17
// A block 'page2-1' must move to the next page because the following block 'page2-2'
18
// has 'page-break-before:avoid' and both blocks cannot be placed in the current page
19
// at the same time.
20
createBlockWithRatioToPageHeight("page2-1", 0.3);
21
createBlockWithRatioToPageHeight("page2-2", 0.3).style.pageBreakBefore = "avoid";
22
23
createBlockWithRatioToPageHeight("page3-1", 0.5).style.pageBreakBefore = "always";
24
// A page break can occur inside of 'page3-3' block because it has child elements.
25
createBlockWithRatioToPageHeight("page3-2", 0.3);
26
createBlockWithNumberOfLines("page3-3", 10).style.pageBreakBefore = "avoid";
27
28
createBlockWithRatioToPageHeight("page5", 0.5).style.pageBreakBefore = "always";
29
// It seems unrealistic, but block 'page6-1' must move to the next page.
30
createBlockWithRatioToPageHeight("page6-1", 0.1);
31
createBlockWithRatioToPageHeight("page6-2", 0.1).style.pageBreakBefore = "avoid";
32
createBlockWithRatioToPageHeight("page6-3", 0.1).style.pageBreakBefore = "avoid";
33
createBlockWithRatioToPageHeight("page6-4", 0.1).style.pageBreakBefore = "avoid";
34
createBlockWithRatioToPageHeight("page6-5", 0.1).style.pageBreakBefore = "avoid";
35
createBlockWithRatioToPageHeight("page6-6", 0.1).style.pageBreakBefore = "avoid";
36
createBlockWithRatioToPageHeight("page6-7", 0.1).style.pageBreakBefore = "avoid";
37
38
// We don't define where block 'page7or8-1' is placed.
39
createBlockWithRatioToPageHeight("page7", 0.5).style.pageBreakBefore = "always";
40
createBlockWithRatioToPageHeight("page7or8-1", 0.1);
41
createBlockWithRatioToPageHeight("page7or8-2", 3).style.pageBreakBefore = "avoid";
42
createBlockWithRatioToPageHeight("page10", 0.1);
43
44
pageNumberForElementShouldBe("page1", 1);
45
pageNumberForElementShouldBe("page2-1", 2);
46
pageNumberForElementShouldBe("page2-2", 2);
47
48
pageNumberForElementShouldBe("page3-1", 3);
49
pageNumberForElementShouldBe("page3-2", 3);
50
pageNumberForElementShouldBe("page3-3", 3);
51
52
pageNumberForElementShouldBe("page5", 5);
53
pageNumberForElementShouldBe("page6-1", 6);
54
// Omit tests for intermediate blocks.
55
pageNumberForElementShouldBe("page6-7", 6);
56
57
pageNumberForElementShouldBe("page7", 7);
58
pageNumberForElementShouldBe("page10", 10);
59
60
document.body.removeChild(document.getElementById("sandbox"));
61
}
62
63
var successfullyParsed = true;
64
</script>
65
<script>runPrintingTest(test);</script>
66
<script src="../resources/js-test-post.js"></script>
67
</body>
68
</html>