Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / listbox-selection.html
blob9942584b30d927327cd74f666f68464be8e4c029
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('&lt;select&gt; selection test for mouse events and keyevents.');
12 function mouseDownOnSelect(selId, index, modifier) {
13 var sl = document.getElementById(selId);
14 var itemHeight = Math.floor(sl.offsetHeight / sl.size);
15 var border = 1;
16 var y = border + index * itemHeight;
18 sl.focus();
19 if (window.eventSender) {
20 eventSender.mouseMoveTo(sl.offsetLeft + border, sl.offsetTop + y - window.pageYOffset);
21 eventSender.mouseDown(0, [modifier]);
22 eventSender.mouseUp(0, [modifier]);
26 function keyDownOnSelect(selId, identifier, modifier) {
27 document.getElementById(selId).focus();
28 if (window.eventSender)
29 eventSender.keyDown(identifier, [modifier]);
32 function createSelect(idName, sz, mlt, selIndex) {
33 var sl = document.createElement("select");
34 var i = 0;
35 sl.size = sz;
36 while (i < sz) {
37 var opt = document.createElement("option");
38 if (i == selIndex)
39 opt.selected = true;
40 opt.textContent = "item " + i;
41 sl.appendChild(opt);
42 i++;
44 sl.multiple = mlt;
45 sl.id = idName;
46 var parent = document.getElementById("parent");
47 parent.appendChild(sl);
50 function selectionPattern(selId) {
51 var sl = document.getElementById(selId);
52 var result = '';
53 for (var i = 0; i < sl.options.length; i++)
54 result += sl.options[i].selected ? '1' : '0';
55 return result;
58 var parent = document.createElement('div');
59 parent.id = "parent";
60 document.body.appendChild(parent);
62 createSelect("sl1", 5, false, -1);
63 createSelect("sl2", 5, false, 1);
64 createSelect("sl3", 5, false, -1);
65 createSelect("sl4", 5, false, 1);
66 createSelect("sl5", 5, false, 2);
67 createSelect("sl6", 5, false, 3);
68 createSelect("sl7", 5, false, 1);
70 createSelect("sl8", 5, true, -1);
71 createSelect("sl9", 5, true, 1);
72 createSelect("sl10", 5, true, -1);
73 createSelect("sl11", 5, true, 1);
74 createSelect("sl12", 5, true, 2);
75 createSelect("sl13", 5, true, 0);
76 createSelect("sl14", 5, true, 1);
78 debug("1) Select one item with mouse (no previous selection)");
79 mouseDownOnSelect("sl1", 0);
80 shouldBe('selectionPattern("sl1")', '"10000"');
82 debug("2) Select one item with mouse (with previous selection)");
83 mouseDownOnSelect("sl2", 0);
84 shouldBe('selectionPattern("sl2")', '"10000"');
86 debug("3) Select one item with the keyboard (no previous selection)");
87 keyDownOnSelect("sl3", "upArrow");
88 shouldBe('selectionPattern("sl3")', '"00001"');
90 debug("4) Select one item with the keyboard (with previous selection)");
91 keyDownOnSelect("sl4", "downArrow");
92 shouldBe('selectionPattern("sl4")', '"00100"');
94 debug("5) Attempt to select an item cmd-clicking");
95 mouseDownOnSelect("sl5", 1, "addSelectionKey");
96 shouldBe('selectionPattern("sl5")', '"01000"');
98 debug("6) Attempt to select a range shift-clicking");
99 mouseDownOnSelect("sl6", 1, "rangeSelectionKey");
100 shouldBe('selectionPattern("sl6")', '"01000"');
102 debug("7) Attempt to select a range with the keyboard");
103 keyDownOnSelect("sl7", "downArrow", "rangeSelectionKey");
104 shouldBe('selectionPattern("sl7")', '"00100"');
106 // Multiple selection tests
108 debug("8) Select one item with mouse (no previous selection)");
109 mouseDownOnSelect("sl8", 0);
110 shouldBe('selectionPattern("sl8")', '"10000"');
112 debug("9) Select one item with mouse (with previous selection)");
113 mouseDownOnSelect("sl9", 0);
114 shouldBe('selectionPattern("sl9")', '"10000"');
116 debug("10) Select one item with the keyboard (no previous selection)");
117 keyDownOnSelect("sl10", "upArrow");
118 shouldBe('selectionPattern("sl10")', '"00001"');
120 debug("11) Select one item with the keyboard (with previous selection)");
121 keyDownOnSelect("sl11", "downArrow");
122 shouldBe('selectionPattern("sl11")', '"00100"');
124 debug("12) Select an item cmd-clicking");
125 mouseDownOnSelect("sl12", 1, "addSelectionKey");
126 shouldBe('selectionPattern("sl12")', '"01100"');
128 debug("13) Select a range shift-clicking");
129 mouseDownOnSelect("sl13", 3, "rangeSelectionKey");
130 shouldBe('selectionPattern("sl13")', '"11110"');
132 debug("14) Select a range with the keyboard");
133 keyDownOnSelect("sl14", "downArrow", "rangeSelectionKey");
134 shouldBe('selectionPattern("sl14")', '"01100"');
135 </script>
136 </body>
137 </html>