2 <script src=
"../../../resources/js-test.js"></script>
5 <select name=
"set_sel">
6 <option id=
"opt">========
9 <select name=
"get_sel">
10 <option id=
"one">option
1
11 <option id=
"two">option
2
16 description('Tests the indexed setter and getter for HTMLOptionsCollection.');
19 var get_options
= document
.my_form
.get_sel
.options
;
20 debug((++i
) + ') getting options by index or by getElementById');
21 shouldBe('get_options[0]', 'document.getElementById("one")');
22 shouldBe('get_options[1]', 'document.getElementById("two")');
24 var set_options
= document
.my_form
.set_sel
.options
;
25 debug((++i
) + ') setting a few elements to Option values');
26 set_options
[1] = new Option('A');
27 set_options
[2] = new Option('B');
28 shouldBe('set_options.length', '3');
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');
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');
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');