2 <html id="html_element">
3 <head id="head_element">
4 <script src="../fast/js/resources/js-test-pre.js"></script>
7 <p id="description"></p>
8 <div id="console"></div>
10 description("This tests page style selection.");
12 function appendStyle(styleString)
14 var styleElement = document.createElement("style");
15 styleElement.innerHTML = styleString;
16 document.getElementById("head_element").appendChild(styleElement);
19 if (window.testRunner) {
20 testRunner.dumpAsText();
22 debug("Default margin is auto.");
23 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "auto");
24 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "auto");
25 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "auto");
26 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "auto");
27 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "auto");
29 debug("Set margin to 200px via user style sheet.");
30 testRunner.addUserStyleSheet("@page { margin:200px; }", true);
31 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "200");
32 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "200");
33 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "200");
34 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "200");
35 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "200");
37 debug("Set margin to 100px.");
38 appendStyle("@page { margin:100px; }");
39 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "100");
40 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "100");
41 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "100");
42 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "100");
43 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "100");
45 debug("Set margin for right pages to 50px. The first page is a right page.");
46 appendStyle("@page :right { margin:50px; }");
47 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "50");
48 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "100");
49 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "50");
50 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "100");
51 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "50");
53 debug("Set margin for left pages to 75px.");
54 appendStyle("@page :left { margin:75px; }");
55 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "50");
56 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "75");
57 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "50");
58 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "75");
59 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "50");
61 debug("Set margin for the first page to 125px.");
62 appendStyle("@page :first { margin:125px; }");
63 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "125");
64 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "75");
65 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "50");
66 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "75");
67 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "50");
69 debug("Change the document direction to RTL. This makes the first page a left page.");
70 document.getElementById("html_element").setAttribute("dir", "rtl");
71 shouldBeEqualToString("testRunner.pageProperty('margin-left', 0)", "125");
72 shouldBeEqualToString("testRunner.pageProperty('margin-left', 1)", "50");
73 shouldBeEqualToString("testRunner.pageProperty('margin-left', 2)", "75");
74 shouldBeEqualToString("testRunner.pageProperty('margin-left', 3)", "50");
75 shouldBeEqualToString("testRunner.pageProperty('margin-left', 4)", "75");
77 debug("Check font update and line height override.");
78 appendStyle("@page { line-height:1em; }");
79 appendStyle("@page { font-family:Futura; }");
80 appendStyle("@page { font:15px/6em Arial; }");
81 appendStyle("@page { zoom:200%; }");
82 shouldBeEqualToString("testRunner.pageProperty('line-height', 0)", "180");
83 shouldBeEqualToString("testRunner.pageProperty('font-family', 0)", "Arial");
84 shouldBeEqualToString("testRunner.pageProperty('font-size', 0)", "30");
85 appendStyle("@page { zoom:100%; }");
87 debug("Check @media rules.");
88 appendStyle("@page { size:100px 200px; }");
89 shouldBeEqualToString("testRunner.pageProperty('size', 0)", "100 200");
90 appendStyle("@media print { @page { size:150px 250px; } }");
91 shouldBeEqualToString("testRunner.pageProperty('size', 0)", "150 250");
92 appendStyle("@media screen { @page { size:300px 500px; } }");
93 shouldBeEqualToString("testRunner.pageProperty('size', 0)", "150 250");
96 testFailed("This test can be run only with window.testRunner");
99 <script src="../fast/js/resources/js-test-post.js"></script>