3 <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=115199 -->
6 <title>Test of @page parser
</title>
7 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css">
13 href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=115199"
15 <pre id=
"display"></pre>
16 <style type=
"text/css" id=
"testbox"></style>
17 <script class=
"testbody" type=
"text/javascript">
18 function _(b) { return
"@page { " + b +
" }"; };
21 // CSS
2.1 only allows margin properties in the page rule.
23 // Check a bad property.
24 { rule: _(
"position: absolute;") },
26 // Check good properties with invalid units.
27 { rule: _(
"margin: 2in; margin: 2vw;"), expected: {
29 "margin-right":
"2in",
30 "margin-bottom":
"2in",
33 { rule: _(
"margin-top: 2in; margin-top: 2vw;"), expected: {
"margin-top":
"2in"}},
34 { rule: _(
"margin-top: 2in; margin-top: 2vh;"), expected: {
"margin-top":
"2in"}},
35 { rule: _(
"margin-top: 2in; margin-top: 2vmax;"), expected: {
"margin-top":
"2in"}},
36 { rule: _(
"margin-top: 2in; margin-top: 2vmin;"), expected: {
"margin-top":
"2in"}},
38 // Check good properties.
39 { rule: _(
"margin: 2in;"), expected: {
41 "margin-right":
"2in",
42 "margin-bottom":
"2in",
45 { rule: _(
"margin-top: 2in;"), expected: {
"margin-top":
"2in"}},
46 { rule: _(
"margin-left: 2in;"), expected: {
"margin-left":
"2in"}},
47 { rule: _(
"margin-bottom: 2in;"), expected: {
"margin-bottom":
"2in"}},
48 { rule: _(
"margin-right: 2in;"), expected: {
"margin-right":
"2in"}}
51 var display = document.getElementById(
"display");
52 var sheet = document.styleSheets[
1];
54 for (var curTest =
0; curTest < testset.length; curTest++) {
55 while(sheet.cssRules.length
> 0) {
58 sheet.insertRule(testset[curTest].rule,
0);
61 is(sheet.cssRules.length,
1,
62 testset[curTest].rule +
" rule count");
63 is(sheet.cssRules[
0].type, CSSRule.PAGE_RULE,
64 testset[curTest].rule +
" rule type");
66 if (testset[curTest].expected) {
67 var expected = testset[curTest].expected;
68 var s = sheet.cssRules[
0].style;
71 // everything is set that should be
72 for (var name in expected) {
73 is(s.getPropertyValue(name), expected[name],
74 testset[curTest].rule +
" (prop " + name +
")");
77 // nothing else is set
78 is(s.length, n, testset[curTest].rule +
" prop count");
79 for (var i =
0; i < s.length; i++) {
80 ok(s[i] in expected, testset[curTest].rule +
81 " - Unexpected item #" + i +
": " + s[i]);
84 is(Object.keys(sheet.cssRules[
0].style).length,
0,
85 testset[curTest].rule +
" rule has no properties");
88 ok(false, testset[curTest].rule +
" - During test: " + e);