1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
<!doctype html>
<meta charset="utf-8">
<title>CSS Paged Media: parsing @page declarations</title>
<link rel="author" title="Felipe Erias Morandeira" href="mailto:felipeerias@gmail.com"/>
<link rel="help" href="https://drafts.csswg.org/css-page/#at-page-rule"/>
<meta name="assert" content="Test that @page declarations are parsed correctly.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style type="text/css">
@page :visited { /* :visited is invalid for @page */
color: red;
}
@page a_page_name:visited { /* :visited is invalid for @page */
background-color: red;
}
@page {
margin-top:5cm;
margin-bottom:10cm;
}
@page :left {
margin-right:3cm;
}
@page :right {
margin-left:3cm;
}
@page :first {
border-width:1px;
}
@page hello {
color:green;
}
@page world:right {
background-color:green;
}
@page auto_page {
size: auto;
}
@page square_page {
size: 4in;
}
@page letter_page {
size: letter;
}
@page page_width_height {
size: 10cm 15cm;
}
@page page_size_orientation {
size: ledger landscape;
}
@page page_orientation_size {
size: portrait a4;
}
@page page_jis_size_orientation {
size: jis-b5 portrait;
}
@page page_orientation_jis_size {
size: landscape jis-b4;
}
@page err_empty_size {
size:;
}
@page err_unknow_page_size {
size: yotsugiri;
}
@page err_length_and_page_size {
size: 10cm letter;
}
@page err_length_and_orientation {
size: 10cm landscape;
}
@page err_orientations {
size: portrait landscape;
}
@page err_too_many_params {
size: a5 landscape auto;
}
</style>
<script type="text/javascript">
let expectedForSelector = {
"" : "margin-top: 5cm; margin-bottom: 10cm;",
":left" : "margin-right: 3cm;",
":right" : "margin-left: 3cm;",
":first" : "border-width: 1px;",
"hello" : "color: green;",
"world:right" : "background-color: green;",
"auto_page" : "size: auto;",
"square_page" : "size: 4in;",
"letter_page" : "size: letter;",
"page_width_height" : "size: 10cm 15cm;",
"page_size_orientation" : "size: ledger landscape;",
"page_orientation_size" : "size: a4 portrait;",
"page_jis_size_orientation" : "size: jis-b5 portrait;",
"page_orientation_jis_size" : "size: jis-b4 landscape;",
"err_empty_size" : "",
"err_unknow_page_size" : "",
"err_length_and_page_size" : "",
"err_length_and_orientation" : "",
"err_orientations" : "",
"err_too_many_params" : ""
};
let styleSheets = document.styleSheets;
for (let i = 0; i < styleSheets.length; i++) {
let rules = styleSheets[i].cssRules;
for (let rule of rules) {
if (rule.type == CSSRule.PAGE_RULE) {
let expected = expectedForSelector[rule.selectorText];
test(function(){
assert_equals(rule.style.cssText, expected, "unexpected @page contents");
}, "unexpected contents for selector ['" + rule.selectorText + "']");
delete expectedForSelector[rule.selectorText];
}
}
}
test(function() {
assert_equals(Object.keys(expectedForSelector).length, 0, "missing @page selectors");
});
</script>
|