|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=346485 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 346485</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=346485">Mozilla Bug 346485</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"> |
|
15 <input id='a'> |
|
16 <input id='b'> |
|
17 <output id='o' for='a b'></output> |
|
18 </div> |
|
19 <pre id="test"> |
|
20 <script type="application/javascript"> |
|
21 |
|
22 /** Test for Bug 346485 **/ |
|
23 |
|
24 /** |
|
25 * This test is testing DOMSettableTokenList used by the output element. |
|
26 */ |
|
27 |
|
28 var o = document.getElementById('o'); |
|
29 |
|
30 is(o.htmlFor, 'a b', |
|
31 "htmlFor IDL attribute should reflect for content attribute"); |
|
32 |
|
33 is(o.htmlFor.value, 'a b', |
|
34 "value should return the underlying string"); |
|
35 |
|
36 is(o.htmlFor.length, 2, "Size should be '2'"); |
|
37 |
|
38 ok(o.htmlFor.contains('a'), "It should contain 'a' token'"); |
|
39 ok(!o.htmlFor.contains('c'), "It should not contain 'c' token"); |
|
40 |
|
41 is(o.htmlFor.item(0), 'a', "First item is 'a' token'"); |
|
42 is(o.htmlFor.item(42), null, "Out-of-range should return null"); |
|
43 |
|
44 o.htmlFor.add('c'); |
|
45 is(o.htmlFor, 'a b c', "'c' token should have been added"); |
|
46 is(o.htmlFor.length, 3, "Size should be '3'"); |
|
47 |
|
48 o.htmlFor.add('a'); |
|
49 is(o.htmlFor, 'a b c', "Nothing should have changed"); |
|
50 is(o.htmlFor.length, 3, "Size should be '3'"); |
|
51 |
|
52 o.htmlFor.remove('a'); |
|
53 is(o.htmlFor, 'b c', "'a' token should have been removed"); |
|
54 is(o.htmlFor.length, 2, "Size should be '2'"); |
|
55 |
|
56 o.htmlFor.remove('d'); |
|
57 is(o.htmlFor, 'b c', "Nothing should have been removed"); |
|
58 is(o.htmlFor.length, 2, "Size should be '2'"); |
|
59 |
|
60 o.htmlFor.toggle('a'); |
|
61 is(o.htmlFor, 'b c a', "'a' token should have been added"); |
|
62 is(o.htmlFor.length, 3, "Size should be '3'"); |
|
63 |
|
64 o.htmlFor.toggle('b'); |
|
65 is(o.htmlFor, 'c a', "Nothing should have changed"); |
|
66 is(o.htmlFor.length, 2, "Size should be '2'"); |
|
67 |
|
68 o.htmlFor.value = "foo bar"; |
|
69 is(o.htmlFor, 'foo bar', "The underlying string should have changed"); |
|
70 is(o.htmlFor.length, 2, "Size should be '2'"); |
|
71 ok(o.htmlFor.contains('foo'), "It should contain 'foo'"); |
|
72 |
|
73 </script> |
|
74 </pre> |
|
75 </body> |
|
76 </html> |