2 <script src=
"../../resources/testharness.js"></script>
3 <script src=
"../../resources/testharnessreport.js"></script>
8 transform: matrix(
1,
0,
0,
1,
0,
0);
13 <!-- just plain bad -->
14 <div style=
"width: calc(;">unclosed calc
</div>
15 <div style=
"width: calc( flim;">unclosed calc with garbage
</div>
16 <div style=
"width: calc( flim );">garbage
</div>
17 <div style=
"width: calc( auto );">garbage
</div>
19 <!-- unsupported units -->
20 <div style=
"width: calc(10dpi);">dpi
</div>
21 <div style=
"width: calc(10dpi / 4);">dpi / number
</div>
22 <div style=
"width: calc(5dpi + 5dpi);">dpi + dpi
</div>
23 <div style=
"width: calc(42fr);">fr
</div>
25 <!-- zero division -->
26 <div style=
"width: calc(1ex / 0);">zero division
</div>
28 <!-- mod, +, - require whitespaces around the operator -->
29 <div style=
"width: calc(1 mod10 * 200px);">mod10
</div>
30 <div style=
"width: calc(1mod 10 * 200px);">1mod
</div>
31 <div style=
"width: calc(70px+40px);">70px+
40px no whitespace around +
</div>
32 <div style=
"width: calc(70px +40px);">70px +
40px no whitespace on right of +
</div>
33 <div style=
"width: calc(70px+ 40px);">70px+
40px no whitespace on left of +
</div>
34 <div style=
"width: calc(70px+-40px);">70px+-
40px no whitespace around +
</div>
35 <div style=
"width: calc(70px-40px);">70px-
40px no whitespace around -
</div>
36 <div style=
"width: calc(70px -40px);">70px -
40px no whitespace on right of -
</div>
37 <div style=
"width: calc(70px- 40px);">70px-
40px no whitespace on left of -
</div>
38 <div style=
"width: calc(70px-+40px);">70px-+
40px no whitespace around -
</div>
40 <div style=
"width: calc(70px+/**/40px);">70px+/**/
40px no whitespace around +
</div>
41 <div style=
"width: calc(70px/**/+40px);">70px/**/+
40px no whitespace around +
</div>
42 <div style=
"width: calc(70px/**/+/**/40px);">70px+/**/
40px no whitespace around +
</div>
43 <div style=
"width: calc(70px +/**/40px);">70px +/**/
40px no whitespace on right of +
</div>
44 <div style=
"width: calc(70px/**/+ 40px);">70px/**/+
40px no whitespace on left of +
</div>
45 <div style=
"width: calc(70px/**/+-40px);">70px/**/+-
40px no whitespace around +
</div>
46 <div style=
"width: calc(70px+/**/-40px);">70px+/**/-
40px no whitespace around +
</div>
47 <div style=
"width: calc(70px/**/+/**/-40px);">70px/**/+/**/-
40px no whitespace around +
</div>
49 <div style=
"width: calc(70px-/**/40px);">70px-/**/
40px no whitespace around -
</div>
50 <div style=
"width: calc(70px/**/-40px);">70px/**/-
40px no whitespace around -
</div>
51 <div style=
"width: calc(70px/**/-/**/40px);">70px/**/-/**/
40px no whitespace around -
</div>
52 <div style=
"width: calc(70px -/**/40px);">70px -/**/
40px no whitespace on right of -
</div>
53 <div style=
"width: calc(70px/**/- 40px);">70px/**/-
40px no whitespace on left of -
</div>
54 <div style=
"width: calc(70px/**/-+40px);">70px/**/-+
40px no whitespace around -
</div>
55 <div style=
"width: calc(70px-/**/+40px);">70px-/**/+
40px no whitespace around -
</div>
56 <div style=
"width: calc(70px/**/-/**/+40px);">70px/**/-/**/+
40px no whitespace around -
</div>
58 <!-- too many nests should be rejected to avoid stack overflow -->
59 <div style=
"width: calc(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((200px)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));">too many nests
</div>
61 <!-- invalid formulas -->
62 <div style=
"width: calc(200px*);">end with operator
</div>
63 <div style=
"width: calc(+ +200px);">start with operator
</div>
64 <div style=
"width: calc();">no expressions
</div>
65 <div style=
"width: calc(100px + + +100px);">too many pluses
</div>
66 <div style=
"width: calc(200px 200px);">no binary operator
</div>
67 <div style=
"width: calc(100px * * 2);">two binary operators
</div>
68 <div style=
"width: calc(100px @ 2);">invalid operator '@'
</div>
69 <div style=
"width: calc(1 flim 2);">invalid operator 'flim'
</div>
70 <div style=
"width: calc(100px @ 2);">invalid operator '@'
</div>
71 <div style=
"width: calc(1 flim 2);">invalid operator 'flim'
</div>
72 <div style=
"width: calc(1 flim (2));">invalid operator 'flim' with parens
</div>
74 <!-- Single unitless non length value -->
75 <div style=
"width: 100px; width: calc(200);">non length
</div>
77 <!-- Wrong combinations -->
78 <div style=
"width: calc(10 + 10px);">number + length
</div>
79 <div style=
"width: calc(10px + 10);">length + number
</div>
80 <div style=
"width: calc(10% + 100);">percent + number
</div>
81 <div style=
"width: calc(100 + 10%);">number + percent
</div>
83 <div style=
"transform: rotate(calc(42deg + 10))">angle + number
</div>
84 <div style=
"transform: rotate(calc(10 + 42rad))">number + angle
</div>
85 <div style=
"transform: rotate(calc(42deg + 10px))">angle + length
</div>
86 <div style=
"transform: rotate(calc(10px + 42rad))">length + angle
</div>
87 <div style=
"transform: rotate(calc(42rad + 10%))">angle + percent
</div>
88 <div style=
"transform: rotate(calc(10% + 42rad))">percent + angle
</div>
89 <div style=
"transform: rotate(calc(42grad + 10ms))">angle + time
</div>
90 <div style=
"transform: rotate(calc(10s + 42grad))">time + angle
</div>
91 <div style=
"transform: rotate(calc(42turn + 10Hz))">angle + frequency
</div>
92 <div style=
"transform: rotate(calc(10kHz + 42turn))">frequency + angle
</div>
94 <div style=
"animation-delay: rotate(calc(10ms + 10)">time + number
</div>
95 <div style=
"animation-delay: rotate(calc(10 + 10s))">number + time
</div>
96 <div style=
"animation-delay: rotate(calc(10ms + 10px)">time + length
</div>
97 <div style=
"animation-delay: rotate(calc(10px + 10s))">length + time
</div>
98 <div style=
"animation-delay: rotate(calc(10ms + 10%))">time + percent
</div>
99 <div style=
"animation-delay: rotate(calc(10% + 10s))">percent + time
</div>
100 <div style=
"animation-delay: rotate(calc(10ms + 10rad))">time + angle
</div>
101 <div style=
"animation-delay: rotate(calc(10deg + 10s))">angle + time
</div>
102 <div style=
"animation-delay: rotate(calc(10ms + 10Hz))">time + frequency
</div>
103 <div style=
"animation-delay: rotate(calc(10kHz + 10s))">frequency + time
</div>
106 <div style=
"width: calc(300px - 100);">length - number
</div>
107 <div style=
"width: calc(300 - 100px);">number - length
</div>
108 <div style=
"width: calc(100% - 10);">percent - number
</div>
109 <div style=
"width: calc(100 - 10%);">number - percent
</div>
110 <div style=
"transform: rotate(calc(42deg - 10))">angle - number
</div>
111 <div style=
"transform: rotate(calc(10 - 42rad))">number - angle
</div>
112 <div style=
"transform: rotate(calc(42deg - 10px))">angle - length
</div>
113 <div style=
"transform: rotate(calc(10px - 42rad))">length - angle
</div>
114 <div style=
"transform: rotate(calc(42rad - 10%))">angle - percent
</div>
115 <div style=
"transform: rotate(calc(10% - 42rad))">percent - angle
</div>
116 <div style=
"transform: rotate(calc(42grad - 10ms))">angle - time
</div>
117 <div style=
"transform: rotate(calc(10s - 42grad))">time - angle
</div>
118 <div style=
"transform: rotate(calc(42turn - 10Hz))">angle - frequency
</div>
119 <div style=
"transform: rotate(calc(10kHz - 42turn))">frequency - angle
</div>
121 <div style=
"animation-delay: rotate(calc(10ms - 10)">time - number
</div>
122 <div style=
"animation-delay: rotate(calc(10 - 10s))">number - time
</div>
123 <div style=
"animation-delay: rotate(calc(10ms - 10px))">time - length
</div>
124 <div style=
"animation-delay: rotate(calc(10px - 10s))">length - time
</div>
125 <div style=
"animation-delay: rotate(calc(10ms - 10%))">time - percent
</div>
126 <div style=
"animation-delay: rotate(calc(10% - 10s))">percent - time
</div>
127 <div style=
"animation-delay: rotate(calc(10ms - 10turn))">time - angle
</div>
128 <div style=
"animation-delay: rotate(calc(10rad - 10s))">angle - time
</div>
129 <div style=
"animation-delay: rotate(calc(10ms - 10Hz))">time - frequency
</div>
130 <div style=
"animation-delay: rotate(calc(10kHz - 10s))">frequency - time
</div>
133 <div style=
"width: calc(10px * 100px);">length * length
</div>
134 <div style=
"width: calc(10px * 100%);">length * percent
</div>
135 <div style=
"width: calc(10% * 100px);">percent * length
</div>
136 <div style=
"width: calc(10% * 100%);">percent * percent
</div>
138 <div style=
"transform: rotate(calc(42deg * 10px))">angle * length
</div>
139 <div style=
"transform: rotate(calc(10px * 42rad))">length * angle
</div>
140 <div style=
"transform: rotate(calc(42rad * 10%))">angle * percent
</div>
141 <div style=
"transform: rotate(calc(10% * 42rad))">percent * angle
</div>
142 <div style=
"transform: rotate(calc(42grad * 10ms))">angle * time
</div>
143 <div style=
"transform: rotate(calc(10s * 42grad))">time * angle
</div>
144 <div style=
"transform: rotate(calc(42turn * 10Hz))">angle * frequency
</div>
145 <div style=
"transform: rotate(calc(10kHz * 42turn))">frequency * angle
</div>
147 <div style=
"animation-delay: rotate(calc(10ms * 10px))">time * length
</div>
148 <div style=
"animation-delay: rotate(calc(10px * 10s))">length * time
</div>
149 <div style=
"animation-delay: rotate(calc(10ms * 10%))">time * percent
</div>
150 <div style=
"animation-delay: rotate(calc(10% * 10s))">percent * time
</div>
151 <div style=
"animation-delay: rotate(calc(10ms * 10deg))">time * angle
</div>
152 <div style=
"animation-delay: rotate(calc(10turn * 10s))">angle * time
</div>
153 <div style=
"animation-delay: rotate(calc(10ms * 10Hz))">time * frequency
</div>
154 <div style=
"animation-delay: rotate(calc(10kHz * 10s))">frequency * time
</div>
157 <div style=
"width: calc(100 / 10px);">number / length
</div>
158 <div style=
"width: calc(100 / 10%);">number / percent
</div>
159 <div style=
"width: calc(100px / 10px);">length / length
</div>
160 <div style=
"width: calc(100px / 10%);">length / percent
</div>
161 <div style=
"width: calc(100% / 10px);">percent / length
</div>
162 <div style=
"width: calc(100% / 10%);">percent / percent
</div>
164 <div style=
"transform: rotate(calc(10 / 42rad))">number / angle
</div>
165 <div style=
"transform: rotate(calc(42deg / 10px))">angle / length
</div>
166 <div style=
"transform: rotate(calc(10px / 42rad))">length / angle
</div>
167 <div style=
"transform: rotate(calc(42rad / 10%))">angle / percent
</div>
168 <div style=
"transform: rotate(calc(10% / 42rad))">percent / angle
</div>
169 <div style=
"transform: rotate(calc(42grad / 10ms))">angle / time
</div>
170 <div style=
"transform: rotate(calc(10s / 42grad))">time / angle
</div>
171 <div style=
"transform: rotate(calc(42turn / 10Hz))">angle / frequency
</div>
172 <div style=
"transform: rotate(calc(10kHz / 42turn))">frequency / angle
</div>
174 <div style=
"animation-delay: rotate(calc(10 / 10s))">number / time
</div>
175 <div style=
"animation-delay: rotate(calc(10ms / 10px))">time / length
</div>
176 <div style=
"animation-delay: rotate(calc(10px / 10s))">length / time
</div>
177 <div style=
"animation-delay: rotate(calc(10ms / 10%))">time / percent
</div>
178 <div style=
"animation-delay: rotate(calc(10% / 10s))">percent / time
</div>
179 <div style=
"animation-delay: rotate(calc(10ms / 10grad))">time / angle
</div>
180 <div style=
"animation-delay: rotate(calc(10rad / 10s))">angle / time
</div>
181 <div style=
"animation-delay: rotate(calc(10ms / 10Hz))">time / frequency
</div>
182 <div style=
"animation-delay: rotate(calc(10kHz / 10s))">frequency / time
</div>
187 var divs
= document
.getElementsByTagName("div");
188 for (var i
= 0, element
= divs
[i
]; i
< divs
.length
; ++i
) {
189 assert_equals(getComputedStyle(element
).getPropertyValue("width"), "100px");
190 assert_equals(getComputedStyle(element
).getPropertyValue("transform"), "matrix(1, 0, 0, 1, 0, 0)");
191 assert_equals(getComputedStyle(element
).getPropertyValue("animation-delay"), "100s");
193 }, "Tests invalid calc() expression handling.");