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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=657143
-->
<head>
<title>Test for Bug 657143</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657143">Mozilla Bug 657143</a>
<p id="display"></p>
<style>
/* Ensure that there is at least one custom property on the root element's
computed style */
:root { --test: some value; }
</style>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 657143 **/
// Check ordering of CSS properties in nsComputedDOMStylePropertyList.h
// by splitting the getComputedStyle() into five sublists
// then cloning and sort()ing the lists and comparing with originals.
function isMozPrefixed(aProp) {
return aProp.startsWith("-moz");
}
function isNotMozPrefixed(aProp) {
return !isMozPrefixed(aProp);
}
function isWebkitPrefixed(aProp) {
return aProp.startsWith("-webkit");
}
function isNotWebkitPrefixed(aProp) {
return !isWebkitPrefixed(aProp);
}
function isCustom(aProp) {
return aProp.startsWith("--");
}
function isNotCustom(aProp) {
return !isCustom(aProp);
}
var styleList = window.getComputedStyle(document.documentElement);
cssA = [], mozA = [], webkitA = [], svgA = [], customA = [];
// Partition the list of property names into four lists:
//
// cssA: regular, non-SVG properties
// mozA: '-moz-' prefixed properties
// svgA: SVG properties
// customA: '--' prefixed custom properties
var list = cssA;
for (var i = 0, j = styleList.length; i < j; i++) {
var prop = styleList.item(i);
switch (list) {
case cssA:
if (isMozPrefixed(prop)) {
list = mozA;
}
// fall through
case mozA:
if (isWebkitPrefixed(prop)) {
list = webkitA;
}
// fall through
case webkitA:
// Assume that the first SVG property is 'clip-path'.
if (prop == "clip-path") {
list = svgA;
}
// fall through
case svgA:
if (isCustom(prop)) {
list = customA;
}
// fall through
}
list.push(prop);
}
var cssB = cssA.slice(0).sort(),
mozB = mozA.slice(0).sort(),
webkitB = webkitA.slice(0).sort(),
svgB = svgA.slice(0).sort();
is(cssA.toString(), cssB.toString(), 'CSS property list should be alphabetical');
is(mozA.toString(), mozB.toString(), 'Experimental -moz- CSS property list should be alphabetical');
is(webkitA.toString(), webkitB.toString(), 'Compatible -webkit- CSS property list should be alphabetical');
is(svgA.toString(), svgB.toString(), 'SVG property list should be alphabetical');
// We don't test that the custom property list is sorted, as the CSSOM
// specification does not yet require it, and we don't return them
// in sorted order.
ok(!cssA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the mature CSS property list');
ok(!cssA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the mature CSS property list');
ok(!cssA.find(isCustom), 'Custom CSS properties should not be in the mature CSS property list');
ok(!mozA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the experimental -moz- CSS '
+ 'property list');
ok(!mozA.find(isNotMozPrefixed), 'Experimental -moz- CSS property list should not contain non -moz- prefixed '
+ 'CSS properties');
ok(!mozA.find(isCustom), 'Custom CSS properties should not be in the experimental -moz- CSS property list');
ok(!webkitA.find(isNotWebkitPrefixed), 'Compatible -webkit- CSS properties should not contain non -webkit- prefixed '
+ 'CSS properties');
ok(!webkitA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the compatible -webkit- CSS '
+ 'property list');
ok(!webkitA.find(isCustom), 'Custom CSS properties should not be in the compatible -webkit- CSS property list');
ok(!svgA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the SVG property list');
ok(!svgA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the SVG property list');
ok(!svgA.find(isCustom), 'Custom CSS properties should not be in the SVG property list');
ok(!customA.find(isNotCustom), 'Non-custom CSS properties should not be in the custom property list');
</script>
</pre>
</body>
</html>
|