summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/bugs/test_bug1160342_marquee.html
blob: 8da13478e11a55246e793dc785061074e006a766 (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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
-->
<head>
  <title>Test for Bug 411103</title>
  <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=1160342">Mozilla Bug 1160342</a>
<p id="display"></p>
<div id="content">
<marquee id="a" style="border: 1px solid black;">marquee</marquee>
</div>

<pre id="test">
<script class="testbody" type="text/javascript">
/* The todos are cases where IE/Edge is throwing errors, but
   for Mozilla it was decided to not do that for now */
  var x=document.getElementById('a');

  SimpleTest.waitForExplicitFinish();

  setTimeout(function() {
    is(x.behavior, "scroll", "Wrong behavior value");
    x.setAttribute('behavior', 'alternate');
    is(x.behavior, "alternate", "Wrong behavior value");
    x.setAttribute('behavior', 'invalid');
    is(x.behavior, "scroll", "Wrong behavior value");;
    x.setAttribute('behavior', 'Scroll');
    is(x.behavior, "scroll", "Wrong behavior value");
    x.setAttribute('behavior', 'Slide');
    is(x.behavior, "slide", "Wrong behavior value");
    x.setAttribute('behavior', '');
    is(x.behavior, "scroll", "Wrong behavior value");
    x.setAttribute('behavior', 'slide');
    x.removeAttribute('behavior');
    is(x.behavior, "scroll", "Wrong behavior value");
    is(x.getAttribute('behavior'), null, "Wrong behavior attribute");

    x.behavior = 'alternate';
    is(x.behavior, "alternate", "Wrong behavior value");
    try {
      x.behavior = 'invalid';
      todo_is(false, true, "marquee.behavior = 'invalid' should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.behavior, "alternate", "Wrong behavior value");
    is(x.getAttribute('behavior'), "alternate", "Wrong behavior attribute");
    x.behavior = 'Slide';
    is(x.behavior, "slide", "Wrong behavior value");
    is(x.getAttribute('behavior'), "slide", "Wrong behavior attribute");
    try {
      x.behavior = 'invalid';
      todo_is(false, true, "marquee.behavior = 'invalid' should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    try {
      x.behavior = null;
      x.behavior = undefined;
      todo_is(false, true, "marquee.behavior = 'invalid' should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.behavior, "slide", "Wrong behavior value");
    is(x.getAttribute('behavior'), "slide", "Wrong behavior attribute");
    // This doesn't work in Mozilla due to chrome XBL security issues
    x.behavior = { toString: function _toString() { return "scroll"} }
    is(x.behavior, x.getAttribute('behavior'), "Wrong behavior value");
    x.behavior = 'scroll';
    is(x.behavior, "scroll", "Wrong behavior value");

    is(x.loop, -1, "Wrong loop value");
    x.setAttribute('loop', '1');
    is(x.loop, 1, "Wrong loop value");
    x.setAttribute('loop', 'invalid');
    is(x.loop, -1, "Wrong loop value");
    x.setAttribute('loop', '');
    is(x.loop, -1, "Wrong loop value");
    x.setAttribute('loop', '0');
    is(x.loop, -1, "Wrong loop value");
    x.setAttribute('loop', '1000');
    is(x.loop, 1000, "Wrong loop value");
    x.setAttribute('loop', '-0.123');
    is(x.loop, 1000, "Wrong loop value");
    x.setAttribute('loop', '-1.123');
    is(x.loop, -1, "Wrong loop value");
    x.setAttribute('loop', '-1');
    is(x.loop, -1, "Wrong loop value");
    x.setAttribute('loop', '1000');
    is(x.loop, 1000, "Wrong loop value");
    x.removeAttribute('loop');
    is(x.loop, -1, "Wrong loop value");
    is(x.getAttribute('loop'), null, "Wrong loop attribute");

    x.loop = 1;
    is(x.loop, 1, "Wrong loop value");
    is(x.getAttribute('loop'), "1", "Wrong loop attribute");
    try {
      x.loop = -2;
      todo_is(false, true, "marquee.loop = -2 should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.loop, 1, "Wrong loop value");
    is(x.getAttribute('loop'), "1", "Wrong loop attribute");
    try {
      x.loop = 'invalid';
      todo_is(false, true, ".loop = 'invalid' should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.loop, 1, "Wrong loop value");
    is(x.getAttribute('loop'), "1", "Wrong loop attribute");
    try {
      x.loop = null;
      todo_is(false, true, "marquee.loop = null should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.loop, 1, "Wrong loop value");
    is(x.getAttribute('loop'), "1", "Wrong loop attribute");
    x.loop = -1;
    is(x.loop, -1, "Wrong loop value");
    is(x.getAttribute('loop'), "-1", "Wrong loop attribute");
    x.loop = '100';
    is(x.loop, 100, "Wrong loop value");
    is(x.getAttribute('loop'), "100", "Wrong loop attribute");
    try {
      x.loop = -0.123;
      todo_is(false, true, "marquee.loop = null should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.loop, 100, "Wrong loop value");
    is(x.getAttribute('loop'), "100", "Wrong loop attribute");
    try {
      x.loop = 0;
      todo_is(false, true, "marquee.loop = null should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.loop, 100, "Wrong loop value");
    is(x.getAttribute('loop'), "100", "Wrong loop attribute");
    x.loop = -1.123;
    is(x.loop, -1, "Wrong loop value");
    is(x.getAttribute('loop'), "-1", "Wrong loop attribute");


    is(x.scrollAmount, 6, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', '1');
    is(x.scrollAmount, 1, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', 'invalid');
    is(x.scrollAmount, 6, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', '1000');
    is(x.scrollAmount, 1000, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', '-1');
    is(x.scrollAmount, 1000, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', '999');
    is(x.scrollAmount, 999, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', '');
    is(x.scrollAmount, 6, "Wrong scrollAmount value");
    x.setAttribute('scrollAmount', '999');
    x.removeAttribute('scrollAmount');
    is(x.scrollAmount, 6, "Wrong scrollAmount value");
    is(x.getAttribute('scrollamount'), null, "Wrong scrollamount attribute");

    x.scrollAmount = 1;
    is(x.scrollAmount, 1, "Wrong scrollAmount value");
    is(x.getAttribute('scrollamount'), "1", "Wrong scrolldelay attribute");
    try {
      x.scrollAmount = -2;
      todo_is(false, true, "marquee.scrollAmount = -2 should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.scrollAmount, 1, "Wrong scrollAmount value");
    is(x.getAttribute('scrollamount'), "1", "Wrong scrolldelay attribute");
    x.scrollAmount = 'invalid';
    is(x.scrollAmount, 0, "Wrong scrollAmount value");
    is(x.getAttribute('scrollamount'), "0", "Wrong scrolldelay attribute");
    x.scrollAmount = 1;
    x.scrollAmount = null;
    is(x.scrollAmount, 0, "Wrong scrollAmount value");
    is(x.getAttribute('scrollamount'), "0", "Wrong scrolldelay attribute");
    x.scrollAmount = '2';
    is(x.scrollAmount, 2, "Wrong scrollAmount value");
    is(x.getAttribute('scrollamount'), "2", "Wrong scrolldelay attribute");


    is(x.scrollDelay, 85, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '1');
    is(x.scrollDelay, 1, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', 'invalid');
    is(x.scrollDelay, 85, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '70');
    is(x.scrollDelay, 70, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '59');
    is(x.scrollDelay, 59, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '1000');
    is(x.scrollDelay, 1000, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '-1');
    is(x.scrollDelay, 1000, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '');
    is(x.scrollDelay, 85, "Wrong scrollDelay value");
    x.setAttribute('scrollDelay', '1000');
    x.removeAttribute('scrollDelay');
    is(x.scrollDelay, 85, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), null, "Wrong scrolldelay attribute");

    x.scrollDelay = 100;
    is(x.scrollDelay, 100, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
    try {
      x.scrollDelay = -2;
      todo_is(false, true, "marquee.scrollDelay = -2 should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.scrollDelay, 100, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
    try {
      x.scrollDelay = 'invalid';
      todo_is(false, true, "marquee.scrollDelay = 'invalid' should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.scrollDelay, 100, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
    try {
      x.scrollDelay = null;
      todo_is(false, true, "marquee.scrollDelay = null should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.scrollDelay, 100, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
    try {
      x.scrollDelay = -1;
      todo_is(false, true, "marquee.scrollDelay = -1 should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.scrollDelay, 100, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
    x.scrollDelay = '50';
    is(x.scrollDelay, 50, "Wrong scrollDelay value");
    is(x.getAttribute('scrolldelay'), "50", "Wrong scrolldelay attribute");


    is(x.trueSpeed, false, "Wrong trueSpeed value");
    x.setAttribute('trueSpeed', '1');
    is(x.trueSpeed, true, "Wrong trueSpeed value");
    x.setAttribute('trueSpeed', 'false');
    is(x.trueSpeed, true, "Wrong trueSpeed value");
    x.setAttribute('trueSpeed', '');
    is(x.trueSpeed, true, "Wrong trueSpeed value");
    x.removeAttribute('trueSpeed');
    is(x.trueSpeed, false, "Wrong trueSpeed value");
    is(x.getAttribute('truespeed'), null, "Wrong truespeed attribute");

    x.trueSpeed = 1;
    is(x.trueSpeed, true, "Wrong trueSpeed value");
    is(x.getAttribute('truespeed'), "", "Wrong truespeed attribute");
    x.trueSpeed = -2;
    is(x.trueSpeed, true, "Wrong trueSpeed value");
    is(x.getAttribute('truespeed'), "", "Wrong truespeed attribute");
    x.trueSpeed = null;
    is(x.trueSpeed, false, "Wrong trueSpeed value");
    is(x.getAttribute('truespeed'), null, "Wrong truespeed attribute");
    x.trueSpeed = '100';
    is(x.trueSpeed, true, "Wrong trueSpeed value");
    is(x.getAttribute('truespeed'), "", "Wrong truespeed attribute");


    is(x.direction, "left", "Wrong direction value");
    x.setAttribute('direction', 'right');
    is(x.direction, "right", "Wrong direction value");
    x.setAttribute('direction', 'invalid');
    is(x.direction, "left", "Wrong direction value");
    x.setAttribute('direction', 'RIGHT');
    is(x.direction, "right", "Wrong direction value");
    x.setAttribute('direction', '');
    is(x.direction, "left", "Wrong direction value");
    x.setAttribute('direction', 'right');
    x.removeAttribute('direction');
    is(x.direction, "left", "Wrong direction value");
    is(x.getAttribute('direction'), null, "Wrong direction attribute");
    x.setAttribute('direction', 'up');
    is(x.direction, "up", "Wrong direction value");
    x.setAttribute('direction', 'down');
    is(x.direction, "down", "Wrong direction value");
    x.removeAttribute('direction');
    is(x.direction, "left", "Wrong direction value");
    is(x.getAttribute('direction'), null, "Wrong direction attribute");

    x.direction = 'right';
    is(x.direction, "right", "Wrong direction value");
    is(x.getAttribute('direction'), "right", "Wrong direction attribute");
    x.direction = 'up';
    is(x.direction, "up", "Wrong direction value");
    is(x.getAttribute('direction'), "up", "Wrong direction attribute");
    x.direction = 'down';
    is(x.direction, "down", "Wrong direction value");
    is(x.getAttribute('direction'), "down", "Wrong direction attribute");
    try {
      x.direction = 1;
      todo_is(false, true, "marquee.direction = 1 should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.direction, "down", "Wrong direction value");
    is(x.getAttribute('direction'), "down", "Wrong direction attribute");
    try {
      x.direction = null;
      todo_is(false, true, "marquee.direction = null should throw");
    } catch(e) {
      ok(true, "Exception was raised");
    }
    is(x.direction, "down", "Wrong direction value");
    is(x.getAttribute('direction'), "down", "Wrong direction attribute");
    // This doesn't work in Mozilla due to chrome XBL security issues
    x.direction = { toString: function _toString() { return "right"} }
    is(x.direction, x.getAttribute('direction'), "Wrong direction value");
    x.direction = 'left';
    is(x.direction, "left", "Wrong direction value");
    SimpleTest.finish();
  }, 0);

</script>
</pre>
</body>
</html>