Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / printing / page-format-data.html
blob37e7707475764bd2e1da0bb3b8f5b75f7072b225
1 <!DOCTYPE html>
2 <html>
3 <head id="head_element">
4 <script src="../resources/js-test.js"></script>
5 <style>
6 </style>
7 </head>
8 <body>
9 <p id="description"></p>
10 <div id="console"></div>
11 <script>
12 description("This tests page format data");
14 function appendStyle(styleString)
16 var styleElement = document.createElement("style");
17 styleElement.innerHTML = styleString;
18 document.getElementById("head_element").appendChild(styleElement);
21 function inchSize(width, height)
23 return "(" + Math.floor(width * 96) + ", " + Math.floor(height * 96) + ")";
26 function mmSize(width, height)
28 return "(" + Math.floor(width * 96 / 25.4) + ", " + Math.floor(height * 96 / 25.4) + ")";
31 function pxMargins(top, right, bottom, left)
33 return " " + top + " " + right + " " + bottom + " " + left;
36 if (window.testRunner) {
37 testRunner.dumpAsText();
39 // Page box visibility tests.
41 debug("Test default visibility");
42 shouldBe("internals.isPageBoxVisible(document, 0)", "true");
44 debug("Test display: none. display property doesn't apply to @page");
45 appendStyle("@page {display:none;}");
46 shouldBe("internals.isPageBoxVisible(document, 0)", "true");
48 debug("Test display: inline. display property doesn't apply to @page");
49 appendStyle("@page {display:inline;}");
50 shouldBe("internals.isPageBoxVisible(document, 0)", "true");
52 debug("Test visibility: hidden");
53 appendStyle("@page {visibility:hidden;}");
54 shouldBe("internals.isPageBoxVisible(document, 0)", "false");
56 debug("Test visibility: visible");
57 appendStyle("@page {visibility:visible;}");
58 shouldBe("internals.isPageBoxVisible(document, 0)", "true");
60 debug("");
62 // Page size tests
64 debug("Test default page size");
65 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(100, 200)' + pxMargins(1, 2, 3, 4)");
67 debug("Test auto page size");
68 appendStyle("@page {size:auto;}");
69 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(100, 200)' + pxMargins(1, 2, 3, 4)");
71 debug("Test landscape");
72 appendStyle("@page {size:landscape;}");
73 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(200, 100)' + pxMargins(1, 2, 3, 4)");
74 shouldBe("internals.pageSizeAndMarginsInPixels(0, 200, 100, 1, 2, 3, 4)", "'(200, 100)' + pxMargins(1, 2, 3, 4)");
76 debug("Test portrait");
77 appendStyle("@page {size:portrait;}");
78 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(100, 200)' + pxMargins(1, 2, 3, 4)");
79 shouldBe("internals.pageSizeAndMarginsInPixels(0, 200, 100, 1, 2, 3, 4)", "'(100, 200)' + pxMargins(1, 2, 3, 4)");
81 debug("Test a5");
82 appendStyle("@page {size:a5;}");
83 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(148, 210) + pxMargins(1, 2, 3, 4)");
85 debug("Test a5 landscape");
86 appendStyle("@page {size:a5 landscape;}");
87 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(210, 148) + pxMargins(1, 2, 3, 4)");
89 debug("Test portrait a4");
90 appendStyle("@page {size:portrait a4;}");
91 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(210, 297) + pxMargins(1, 2, 3, 4)");
93 debug("Test a3");
94 appendStyle("@page {size:a3;}");
95 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(297, 420) + pxMargins(1, 2, 3, 4)");
97 debug("Test b5");
98 appendStyle("@page {size:b5;}");
99 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(176, 250) + pxMargins(1, 2, 3, 4)");
101 debug("Test b4");
102 appendStyle("@page {size:b4;}");
103 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(250, 353) + pxMargins(1, 2, 3, 4)");
105 debug("Test letter");
106 appendStyle("@page {size:letter;}");
107 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "inchSize(8.5, 11) + pxMargins(1, 2, 3, 4)");
109 debug("Test legal");
110 appendStyle("@page {size:legal;}");
111 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "inchSize(8.5, 14) + pxMargins(1, 2, 3, 4)");
113 debug("Test ledger");
114 appendStyle("@page {size:ledger;}");
115 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "inchSize(11, 17) + pxMargins(1, 2, 3, 4)");
117 debug("Test 10cm");
118 appendStyle("@page {size:10cm;}");
119 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(100, 100) + pxMargins(1, 2, 3, 4)");
121 debug("Test 20cm x 30cm");
122 appendStyle("@page {size:20cm 30cm;}");
123 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(200, 300) + pxMargins(1, 2, 3, 4)");
125 debug("Test 10000px 20000px");
126 appendStyle("@page {size:10000px 20000px;}");
127 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
129 debug("Test invalid page size: -10cm");
130 appendStyle("@page {size:-10cm;}");
131 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
133 debug("Test invalid page size: a4 a4");
134 appendStyle("@page {size:a4 a4;}");
135 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
137 debug("Test invalid page size: landscape portrait");
138 appendStyle("@page {size:landscape portrait;}");
139 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
141 debug("Test invalid page size: 10cm letter");
142 appendStyle("@page {size:10cm letter;}");
143 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
145 debug("Test invalid page size: 10cm 10cm 10cm");
146 appendStyle("@page {size:10cm 10cm 10cm;}");
147 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
149 debug("Test invalid page size: empty");
150 appendStyle("@page {size:;}");
151 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 2, 3, 4)");
153 debug("");
155 // Margin tests
157 debug("Test 0px margins");
158 appendStyle("@page {margin:0px;}");
159 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(0, 0, 0, 0)");
161 debug("Test non-zero margins");
162 appendStyle("@page {margin:10px 20px 40px 80px;}");
163 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(10, 20, 40, 80)");
165 debug("Test percentage margin");
166 appendStyle("@page {margin: 8% 4% 2% 1%;}");
167 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(800, 400, 200, 100)");
169 debug("Test margin: auto 4% 2% 1%");
170 appendStyle("@page {margin: auto 4% 2% 1%;}");
171 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(1, 400, 200, 100)");
173 debug("Test margin: 8% auto 2% 1%");
174 appendStyle("@page {margin: 8% auto 2% 1%;}");
175 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(800, 2, 200, 100)");
177 debug("Test margin: 8% 4% auto 1%");
178 appendStyle("@page {margin: 8% 4% auto 1%;}");
179 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(800, 400, 3, 100)");
181 debug("Test margin: 8% 4% 2% auto");
182 appendStyle("@page {margin: 8% 4% 2% auto;}");
183 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(800, 400, 200, 4)");
185 debug("Test visibility: hidden");
186 appendStyle("@page {visibility:hidden}");
187 shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "'(10000, 20000)' + pxMargins(800, 400, 200, 4)");
189 debug("");
191 } else {
192 testFailed("This test can be run only with window.testRunner");
194 </script>
195 </body>
196 </html>