1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
7 <div id="testParent" style="visibility:hidden"></div>
9 description('Various tests for the marquee element.');
12 var testParent = document.getElementById("testParent");
14 debug('"behavior" IDL attribute reflects content attribute:');
15 testParent.innerHTML = '<marquee id="marquee" behavior="slide">test</marquee>';
16 marquee = document.getElementById('marquee');
17 shouldBe('marquee.behavior', '"slide"');
19 debug('"behavior" IDL attribute can be modified:');
20 testParent.innerHTML = '<marquee id="marquee" behavior="slide">test</marquee>';
21 marquee = document.getElementById('marquee');
22 marquee.behavior="alternate";
23 shouldBe('marquee.behavior', '"alternate"');
25 debug('"bgColor" IDL attribute reflects content attribute:');
26 testParent.innerHTML = '<marquee id="marquee" bgcolor="red">test</marquee>';
27 marquee = document.getElementById('marquee');
28 shouldBe('marquee.bgColor', '"red"');
30 debug('"bgColor" IDL attribute can be modified:');
31 testParent.innerHTML = '<marquee id="marquee" bgcolor="red">test</marquee>';
32 marquee = document.getElementById('marquee');
33 marquee.bgColor="blue";
34 shouldBe('marquee.bgColor', '"blue"');
36 debug('"direction" IDL attribute reflects content attribute:');
37 testParent.innerHTML = '<marquee id="marquee" direction="right">test</marquee>';
38 marquee = document.getElementById('marquee');
39 shouldBe('marquee.direction', '"right"');
41 debug('"direction" IDL attribute can be modified:');
42 testParent.innerHTML = '<marquee id="marquee" direction="right">test</marquee>';
43 marquee = document.getElementById('marquee');
44 marquee.direction="left";
45 shouldBe('marquee.direction', '"left"');
47 debug('"height" IDL attribute reflects content attribute:');
48 testParent.innerHTML = '<marquee id="marquee" height="100px">test</marquee>';
49 marquee = document.getElementById('marquee');
50 shouldBe('marquee.height', '"100px"');
52 debug('"height" IDL attribute can be modified:');
53 testParent.innerHTML = '<marquee id="marquee" height="100px">test</marquee>';
54 marquee = document.getElementById('marquee');
55 marquee.height="200px";
56 shouldBe('marquee.height', '"200px"');
58 debug('"hspace" IDL attribute reflects content attribute:');
59 testParent.innerHTML = '<marquee id="marquee" hspace="10">test</marquee>';
60 marquee = document.getElementById('marquee');
61 shouldBe('marquee.hspace', '10');
63 debug('"hspace" IDL attribute can be modified:');
64 testParent.innerHTML = '<marquee id="marquee" hspace="10">test</marquee>';
65 marquee = document.getElementById('marquee');
67 shouldBe('marquee.hspace', '20');
69 debug('"hspace" IDL attribute is 0 when content attribute is negative:');
70 testParent.innerHTML = '<marquee id="marquee" hspace="-1">test</marquee>';
71 marquee = document.getElementById('marquee');
72 shouldBe('marquee.hspace', '0');
74 debug('"hspace" IDL attribute is 0 when content attribute is too large:');
75 testParent.innerHTML = '<marquee id="marquee" hspace="2147483648">test</marquee>';
76 marquee = document.getElementById('marquee');
77 shouldBe('marquee.hspace', '0');
79 debug('"loop" IDL attribute reflects content attribute:');
80 testParent.innerHTML = '<marquee id="marquee" loop="3">test</marquee>';
81 marquee = document.getElementById('marquee');
82 shouldBe('marquee.loop', '3');
84 debug('"loop" IDL attribute can be modified:');
85 testParent.innerHTML = '<marquee id="marquee" loop="3">test</marquee>';
86 marquee = document.getElementById('marquee');
88 shouldBe('marquee.loop', '4');
90 debug('"scrollAmount" IDL attribute reflects content attribute:');
91 testParent.innerHTML = '<marquee id="marquee" scrollamount="5">test</marquee>';
92 marquee = document.getElementById('marquee');
93 shouldBe('marquee.scrollAmount', '5');
95 debug('"scrollAmount" IDL attribute can be modified:');
96 testParent.innerHTML = '<marquee id="marquee" scrollamount="5">test</marquee>';
97 marquee = document.getElementById('marquee');
98 marquee.scrollAmount=6;
99 shouldBe('marquee.scrollAmount', '6');
101 debug('"scrollDelay" IDL attribute reflects content attribute:');
102 testParent.innerHTML = '<marquee id="marquee" scrolldelay="50">test</marquee>';
103 marquee = document.getElementById('marquee');
104 shouldBe('marquee.scrollDelay', '50');
106 debug('"scrollDelay" IDL attribute can be modified:');
107 testParent.innerHTML = '<marquee id="marquee" scrolldelay="50">test</marquee>';
108 marquee = document.getElementById('marquee');
109 marquee.scrollDelay=60;
110 shouldBe('marquee.scrollDelay', '60');
112 debug('"trueSpeed" IDL attribute reflects content attribute:');
113 testParent.innerHTML = '<marquee id="marquee" truespeed="true">test</marquee>';
114 marquee = document.getElementById('marquee');
115 shouldBeTrue('marquee.trueSpeed');
117 debug('"trueSpeed" IDL attribute can be modified:');
118 testParent.innerHTML = '<marquee id="marquee" truespeed="true">test</marquee>';
119 marquee = document.getElementById('marquee');
120 marquee.trueSpeed=false;
121 shouldBe('marquee.trueSpeed', 'false');
123 debug('"vspace" IDL attribute reflects content attribute:');
124 testParent.innerHTML = '<marquee id="marquee" vspace="10">test</marquee>';
125 marquee = document.getElementById('marquee');
126 shouldBe('marquee.vspace', '10');
128 debug('"vspace" IDL attribute can be modified:');
129 testParent.innerHTML = '<marquee id="marquee" vspace="10">test</marquee>';
130 marquee = document.getElementById('marquee');
132 shouldBe('marquee.vspace', '20');
134 debug('"vspace" IDL attribute is 0 when content attribute is negative:');
135 testParent.innerHTML = '<marquee id="marquee" vspace="-1">test</marquee>';
136 marquee = document.getElementById('marquee');
137 shouldBe('marquee.vspace', '0');
139 debug('"vspace" IDL attribute is 0 when content attribute is too large:');
140 testParent.innerHTML = '<marquee id="marquee" vspace="2147483648">test</marquee>';
141 marquee = document.getElementById('marquee');
142 shouldBe('marquee.vspace', '0');
144 debug('Default "scrollAmount" value is 6:');
145 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
146 marquee = document.getElementById('marquee');
147 shouldBe('marquee.scrollAmount', '6');
149 debug('"scrollAmount" uses default value when content attribute is not a number:');
150 testParent.innerHTML = '<marquee id="marquee" scrollamount="a1">test</marquee>';
151 marquee = document.getElementById('marquee');
152 shouldBe('marquee.scrollAmount', '6');
154 debug('"scrollAmount" uses default value when content attribute is too large:');
155 testParent.innerHTML = '<marquee id="marquee" scrollamount="2147483648">test</marquee>';
156 marquee = document.getElementById('marquee');
157 shouldBe('marquee.scrollAmount', '6');
159 debug('"scrollAmount" uses default value when content attribute is negative:');
160 testParent.innerHTML = '<marquee id="marquee" scrollamount="-1">test</marquee>';
161 marquee = document.getElementById('marquee');
162 shouldBe('marquee.scrollAmount', '6');
164 debug('"scrollAmount" can be set to 0:');
165 testParent.innerHTML = '<marquee id="marquee" scrollamount="0">test</marquee>';
166 marquee = document.getElementById('marquee');
167 shouldBe('marquee.scrollAmount', '0');
169 debug('"scrollAmount" can be set to 2^31-1:');
170 testParent.innerHTML = '<marquee id="marquee" scrollamount="2147483647">test</marquee>';
171 marquee = document.getElementById('marquee');
172 shouldBe('marquee.scrollAmount', '2147483647');
174 debug('"scrollAmount" can contain whitespace:');
175 testParent.innerHTML = '<marquee id="marquee" scrollamount=" 5 ">test</marquee>';
176 marquee = document.getElementById('marquee');
177 shouldBe('marquee.scrollAmount', '5');
179 debug('"scrollAmount" can contain trailing non-numeric values:');
180 testParent.innerHTML = '<marquee id="marquee" scrollamount="5a">test</marquee>';
181 marquee = document.getElementById('marquee');
182 shouldBe('marquee.scrollAmount', '5');
184 debug('Setting "scrollAmount" to a negative value raises an exception:');
185 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
186 shouldThrow('document.getElementById("marquee").scrollAmount = -1;');
188 debug('Setting "scrollAmount" to a value that is too large raises an exception:');
189 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
190 shouldThrow('document.getElementById("marquee").scrollAmount = 2147483648;');
192 debug('Default "scrollDelay" value is 85:');
193 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
194 marquee = document.getElementById('marquee');
195 shouldBe('marquee.scrollDelay', '85');
197 debug('"scrollDelay" uses default value when content attribute is not a number:');
198 testParent.innerHTML = '<marquee id="marquee" scrolldelay="a1">test</marquee>';
199 marquee = document.getElementById('marquee');
200 shouldBe('marquee.scrollDelay', '85');
202 debug('"scrollDelay" uses default value when content attribute is too large:');
203 testParent.innerHTML = '<marquee id="marquee" scrolldelay="2147483648">test</marquee>';
204 marquee = document.getElementById('marquee');
205 shouldBe('marquee.scrollDelay', '85');
207 debug('"scrollDelay" uses default value when content attribute is negative:');
208 testParent.innerHTML = '<marquee id="marquee" scrolldelay="-1">test</marquee>';
209 marquee = document.getElementById('marquee');
210 shouldBe('marquee.scrollDelay', '85');
212 debug('"scrollDelay" can be set to 0:');
213 testParent.innerHTML = '<marquee id="marquee" scrolldelay="0">test</marquee>';
214 marquee = document.getElementById('marquee');
215 shouldBe('marquee.scrollDelay', '0');
217 debug('"scrollDelay" can be set to 2^31-1:');
218 testParent.innerHTML = '<marquee id="marquee" scrolldelay="2147483647">test</marquee>';
219 marquee = document.getElementById('marquee');
220 shouldBe('marquee.scrollDelay', '2147483647');
222 debug('"scrollDelay" can contain whitespace:');
223 testParent.innerHTML = '<marquee id="marquee" scrolldelay=" 5 ">test</marquee>';
224 marquee = document.getElementById('marquee');
225 shouldBe('marquee.scrollDelay', '5');
227 debug('"scrollDelay" can contain trailing non-numeric values:');
228 testParent.innerHTML = '<marquee id="marquee" scrolldelay="5a">test</marquee>';
229 marquee = document.getElementById('marquee');
230 shouldBe('marquee.scrollDelay', '5');
232 debug('Setting "scrollDelay" to a negative value raises an exception:');
233 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
234 shouldThrow('document.getElementById("marquee").scrollDelay = -1;');
236 debug('Setting "scrollDelay" to a value that is too large raises an exception:');
237 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
238 shouldThrow('document.getElementById("marquee").scrollDelay = 2147483648;');
240 debug('Default "loop" value is -1:');
241 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
242 marquee = document.getElementById('marquee');
243 shouldBe('marquee.loop', '-1');
245 debug('"loop" uses default value when content attribute is not a number:');
246 testParent.innerHTML = '<marquee id="marquee" loop="a1">test</marquee>';
247 marquee = document.getElementById('marquee');
248 shouldBe('marquee.loop', '-1');
250 debug('"loop" uses default value when content attribute is too large:');
251 testParent.innerHTML = '<marquee id="marquee" loop="2147483648">test</marquee>';
252 marquee = document.getElementById('marquee');
253 shouldBe('marquee.loop', '-1');
255 debug('"loop" uses default value when content attribute is negative:');
256 testParent.innerHTML = '<marquee id="marquee" loop="-5">test</marquee>';
257 marquee = document.getElementById('marquee');
258 shouldBe('marquee.loop', '-1');
260 debug('"loop" uses default value when set to 0:');
261 testParent.innerHTML = '<marquee id="marquee" loop="0">test</marquee>';
262 marquee = document.getElementById('marquee');
263 shouldBe('marquee.loop', '-1');
265 debug('"loop" can be set to 1:');
266 testParent.innerHTML = '<marquee id="marquee" loop="1">test</marquee>';
267 marquee = document.getElementById('marquee');
268 shouldBe('marquee.loop', '1');
270 debug('"loop" can be set to 2^31-1:');
271 testParent.innerHTML = '<marquee id="marquee" loop="2147483647">test</marquee>';
272 marquee = document.getElementById('marquee');
273 shouldBe('marquee.loop', '2147483647');
275 debug('"loop" can contain whitespace:');
276 testParent.innerHTML = '<marquee id="marquee" loop=" 5 ">test</marquee>';
277 marquee = document.getElementById('marquee');
278 shouldBe('marquee.loop', '5');
280 debug('"loop" can contain trailing non-numeric values:');
281 testParent.innerHTML = '<marquee id="marquee" loop="5a">test</marquee>';
282 marquee = document.getElementById('marquee');
283 shouldBe('marquee.loop', '5');
285 debug('Setting "loop" to 0 raises an exception:');
286 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
287 shouldThrow('document.getElementById("marquee").loop = 0;');
289 debug('Setting "loop" to a negative value raises an exception:');
290 testParent.innerHTML = '<marquee id="marquee">test</marquee>';
291 shouldThrow('document.getElementById("marquee").scrollDelay = -5;');
293 debug('"loop" can be set to -1 by script:');
294 testParent.innerHTML = '<marquee id="marquee" loop="5">test</marquee>';
295 marquee = document.getElementById('marquee');
297 shouldBe('marquee.loop', '-1');
299 <script src="../../fast/js/resources/js-test-post.js"></script>