Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select / optgroup-clicking.html
blob543b235f82a6a34d8f568bf284c4a3733bd5486f
1 <!DOCTYPE html>
2 <html>
3 <body onload="test()">
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../resources/common.js"></script>
7 <form id="form">
8 <select size="10" id="listbox">
9 <optgroup label="Enabled" id="listbox_optgroup_enabled">
10 <option value="listbox_e1" id="listbox_option_enabled">One</option>
11 <option value="listbox_e2">Two</option>
12 <option value="listbox_e3">Three</option>
13 <option value="listbox_e4">Four</option>
14 </optgroup>
15 <optgroup label="Disabled" disabled id="listbox_optgroup_disabled">
16 <option value="listbox_d1" id="listbox_option_disabled">One</option>
17 <option value="listbox_d2">Two</option>
18 <option value="listbox_d3">Three</option>
19 <option value="listbox_d4">Four</option>
20 </optgroup>
21 </select>
22 <br />
23 <select size="1" id="menulist">
24 <optgroup label="Enabled" id="menulist_optgroup_enabled">
25 <option value="listbox_e1" id="menulist_option_enabled">One</option>
26 <option value="listbox_e2">Two</option>
27 <option value="listbox_e3">Three</option>
28 <option value="listbox_e4">Four</option>
29 </optgroup>
30 <optgroup label="Disabled" disabled id="menulist_optgroup_disabled">
31 <option value="menulist_d1" id="menulist_option_disabled">One</option>
32 <option value="menulist_d2">Two</option>
33 <option value="menulist_d3">Three</option>
34 <option value="menulist_d4">Four</option>
35 </optgroup>
36 <optgroup label="Enabled2">
37 <option value="listbox_e21">One</option>
38 <option value="listbox_e22">Two</option>
39 <option value="listbox_e23">Three</option>
40 <option value="listbox_e24">Four</option>
41 </optgroup>
42 </select>
43 </form>
44 <script>
45 description('Test clicking with optgroup element');
47 window.jsTestIsAsync = true;
49 function test()
51 if (!window.testRunner) {
52 debug("This test needs testRunner.");
53 return;
56 testRunner.dumpAsText();
58 debug("\nClick enabled option");
59 $("listbox").selectedIndex = 2;
60 mouseMoveToIndexInListbox(1 + 1, 'listbox'); // +1 for optgroup
61 eventSender.mouseDown();
62 eventSender.mouseUp();
63 shouldBe('$("listbox").selectedIndex', '1');
65 debug("\nClick on optgroup, should not deselect selectedIndex");
66 mouseMoveToIndexInListbox(0, 'listbox'); // Select on optgroup
67 eventSender.mouseDown();
68 eventSender.mouseUp();
69 shouldBe('$("listbox").selectedIndex', '1');
71 debug("\nClick disabled option - doesn't change selectedIndex");
72 mouseMoveToIndexInListbox(5 + 2, 'listbox'); // +2 for optgroup's
73 eventSender.mouseDown();
74 eventSender.mouseUp();
75 shouldBe('$("listbox").selectedIndex', '1');
77 debug("\nMenu list with arrow key");
78 $("menulist").selectedIndex = 3;
79 $("menulist").focus();
80 eventSender.keyDown("downArrow");
81 eventSender.keyDown("\n");
82 shouldBe('$("menulist").selectedIndex', '8');
84 finishJSTest();
86 </script>
87 </body>
88 </html>