summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-page/parsing/size-001.html
blob: 885a7b85306f3f5d0737e62e400225d9f35a2bb6 (plain)
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
<!DOCTYPE html>
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-page-3/#page-size-prop">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@page{
	size: 640px 480px;
}
@page{
	size: 8.5in 11in;
}
@page{
	size: A4;
}
@page{
	size: 3in 10in;
}
@page{
	size: jis-B5;
}
@page{
	size: auto;
}
@page{
	size: landscape;
}
@page{
    size: letter portrait;
}
@page{
    size: legal landscape;
}
</style>

<script>
'use strict';

const expectedSizes = [
    "640px 480px",
    "8.5in 11in",
    "a4",
    "3in 10in",
    "jis-b5",
    "auto",
    "landscape",
    "letter",
    "legal landscape"
];
const sizePrefix = "size: ";

test(t => {
  assert_equals(document.styleSheets.length, 1);
  let styleSheet = document.styleSheets[0];
  assert_equals(styleSheet.rules.length, expectedSizes.length);
  for(let i = 0; i < expectedSizes.length; i++){
    let cssText = styleSheet.cssRules[i].style.cssText;
    assert_true(cssText.startsWith(sizePrefix));
    cssText = cssText.slice(sizePrefix.length);
    assert_equals(cssText, expectedSizes[i] + ";", "for rule " + i);
  }
}, "size-001");
</script>