Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLOptionElement / collection-setter-getter.html
blobfc50eb120217b37f83f82aa6974c3740d127cc2e
1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script>
4 <form name="my_form">
5 <select name="set_sel">
6 <option id="opt">========
7 </select>
9 <select name="get_sel">
10 <option id="one">option 1
11 <option id="two">option 2
12 </select>
13 </form>
15 <script>
16 description('Tests the indexed setter and getter for HTMLOptionsCollection.');
17 var i = 0;
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');
41 </script>