2010-06-16 03:23:12 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html id="html_element">
|
|
|
|
<head id="head_element">
|
2013-09-08 04:22:45 +00:00
|
|
|
<script src="../resources/js-test-pre.js"></script>
|
2010-06-16 03:23:12 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p id="description"></p>
|
|
|
|
<div id="console"></div>
|
|
|
|
<script>
|
|
|
|
description("This tests page style selection.");
|
|
|
|
|
|
|
|
function appendStyle(styleString)
|
|
|
|
{
|
|
|
|
var styleElement = document.createElement("style");
|
|
|
|
styleElement.innerHTML = styleString;
|
|
|
|
document.getElementById("head_element").appendChild(styleElement);
|
|
|
|
}
|
|
|
|
|
2012-06-15 07:38:37 +00:00
|
|
|
if (window.testRunner) {
|
|
|
|
testRunner.dumpAsText();
|
2010-06-16 03:23:12 +00:00
|
|
|
|
2010-06-28 01:59:51 +00:00
|
|
|
debug("Default margin is auto.");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "auto");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "auto");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "auto");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "auto");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "auto");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Set margin to 200px via user style sheet.");
|
2012-06-15 07:38:37 +00:00
|
|
|
testRunner.addUserStyleSheet("@page { margin:200px; }", true);
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "200");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "200");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "200");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "200");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "200");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Set margin to 100px.");
|
|
|
|
appendStyle("@page { margin:100px; }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "100");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "100");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "100");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "100");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "100");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Set margin for right pages to 50px. The first page is a right page.");
|
|
|
|
appendStyle("@page :right { margin:50px; }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "100");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "100");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "50");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Set margin for left pages to 75px.");
|
|
|
|
appendStyle("@page :left { margin:75px; }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "75");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "75");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "50");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Set margin for the first page to 125px.");
|
|
|
|
appendStyle("@page :first { margin:125px; }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "125");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "75");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "75");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "50");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Change the document direction to RTL. This makes the first page a left page.");
|
|
|
|
document.getElementById("html_element").setAttribute("dir", "rtl");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 0)", "125");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 1)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 2)", "75");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 3)", "50");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('margin-left', 4)", "75");
|
2010-06-16 03:23:12 +00:00
|
|
|
|
|
|
|
debug("Check font update and line height override.");
|
|
|
|
appendStyle("@page { line-height:1em; }");
|
|
|
|
appendStyle("@page { font-family:Futura; }");
|
|
|
|
appendStyle("@page { font:15px/6em Arial; }");
|
|
|
|
appendStyle("@page { zoom:200%; }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('line-height', 0)", "180");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('font-family', 0)", "Arial");
|
|
|
|
shouldBeEqualToString("internals.pageProperty('font-size', 0)", "30");
|
2010-06-16 03:23:12 +00:00
|
|
|
appendStyle("@page { zoom:100%; }");
|
2010-07-28 03:48:36 +00:00
|
|
|
|
|
|
|
debug("Check @media rules.");
|
|
|
|
appendStyle("@page { size:100px 200px; }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('size', 0)", "100 200");
|
2010-07-28 03:48:36 +00:00
|
|
|
appendStyle("@media print { @page { size:150px 250px; } }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('size', 0)", "150 250");
|
2010-07-28 03:48:36 +00:00
|
|
|
appendStyle("@media screen { @page { size:300px 500px; } }");
|
2012-09-05 11:36:03 +00:00
|
|
|
shouldBeEqualToString("internals.pageProperty('size', 0)", "150 250");
|
2010-07-28 03:48:36 +00:00
|
|
|
|
2010-06-16 03:23:12 +00:00
|
|
|
} else {
|
2012-06-15 07:38:37 +00:00
|
|
|
testFailed("This test can be run only with window.testRunner");
|
2010-06-16 03:23:12 +00:00
|
|
|
}
|
|
|
|
</script>
|
2013-09-08 04:22:45 +00:00
|
|
|
<script src="../resources/js-test-post.js"></script>
|
2010-06-16 03:23:12 +00:00
|
|
|
</body>
|
|
|
|
</html>
|