OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | |
3 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
4 </head> | |
5 <body> | |
6 | 3 |
7 <form name="my_form"> | 4 <form name="my_form"> |
8 <select name="set_sel"> | 5 <select name="set_sel"> |
9 <option id='opt'>========</option> | 6 <option id="opt">======== |
10 </select> | 7 </select> |
11 | 8 |
12 <select name="get_sel"> | 9 <select name="get_sel"> |
13 <option id="one">option 1</option> | 10 <option id="one">option 1 |
14 <option id="two">option 2</option> | 11 <option id="two">option 2 |
15 </select> | 12 </select> |
16 </form> | 13 </form> |
17 | 14 |
18 <script> | 15 <script> |
19 description('Tests the indexed setter and getter for HTMLOptionsCollection.'); | 16 description('Tests the indexed setter and getter for HTMLOptionsCollection.'); |
| 17 var i = 0; |
20 | 18 |
21 document.my_form.set_sel.options[1] = new Option("A"); | 19 var get_options = document.my_form.get_sel.options; |
22 document.my_form.set_sel.options[2] = new Option("B"); | 20 debug((++i) + ') getting options by index or by getElementById'); |
23 shouldBe("my_form.set_sel.options.length", "3"); | 21 shouldBe('get_options[0]', 'document.getElementById("one")'); |
| 22 shouldBe('get_options[1]', 'document.getElementById("two")'); |
24 | 23 |
25 var options = document.my_form.get_sel.options; | 24 var set_options = document.my_form.set_sel.options; |
26 shouldBe("options[0]", "document.getElementById('one')"); | 25 debug((++i) + ') setting a few elements to Option values'); |
27 shouldBe("options[1]", "document.getElementById('two')"); | 26 set_options[1] = new Option('A'); |
| 27 set_options[2] = new Option('B'); |
| 28 shouldBe('set_options.length', '3'); |
| 29 |
| 30 debug((++i) + ') trying to set an element to a non-Option value: undefined'); |
| 31 set_options[10] = undefined; |
| 32 shouldBe('set_options.length', '3'); |
| 33 |
| 34 debug((++i) + ') trying to set an element to a non-Option value: null'); |
| 35 set_options[10] = null; |
| 36 shouldBe('set_options.length', '3'); |
| 37 |
| 38 debug((++i) + ') trying to set an element to a non-Option value: form (object of
incorrect type)'); |
| 39 shouldThrow('set_options[10] = my_form'); |
| 40 shouldBe('set_options.length', '3'); |
28 </script> | 41 </script> |
29 </body> | |
30 </html> | |
OLD | NEW |