OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../../resources/js-test.js"></script> | |
5 <script src="../resources/common.js"></script> | |
6 <script src="../resources/picker-common.js"></script> | |
7 </head> | |
8 <body> | |
9 <select id="menu"> | |
10 <option>foo</option> | |
11 <option selected>bar</option> | |
12 <option>baz</option> | |
13 </select> | |
14 <select id="menu2" style="font-size:13px; font-family:Arial"> | |
15 <option>option1</option> | |
16 <option>option2</option> | |
17 <option>option3</option> | |
18 <option>option4</option> | |
19 <option>option5</option> | |
20 <option>option6</option> | |
21 <option>option7</option> | |
22 <option>option8</option> | |
23 <option>option9</option> | |
24 <option>option10</option> | |
25 <option>option11</option> | |
26 <option>option12</option> | |
27 <option>option13</option> | |
28 <option>option14</option> | |
29 <option>option15</option> | |
30 <option>option16</option> | |
31 <option>option17</option> | |
32 <option>option18</option> | |
33 <option>option19</option> | |
34 <option>option20</option> | |
35 <option>option21</option> | |
36 </select> | |
37 <script> | |
38 var menuElement = document.getElementById('menu'); | |
39 var menuElement2 = document.getElementById('menu2'); | |
40 var picker = null; | |
41 var clickEventCounter = 0; | |
42 menuElement.addEventListener('click', function() { clickEventCounter++; }, false
); | |
43 var mouseupEventCounter = 0; | |
44 menuElement.addEventListener('mouseup', function() { mouseupEventCounter++; }, f
alse); | |
45 | |
46 function openPickerErrorCallback() { | |
47 testFailed('picker didn\'t open') | |
48 finishJSTest(); | |
49 } | |
50 openPicker(menu, test1, openPickerErrorCallback); | |
51 function test1() { | |
52 picker = window.internals.pagePopupWindow.global.picker; | |
53 shouldBeEqualToString('picker._selectElement.value', '1'); | |
54 shouldBeEqualToString('menuElement.value', 'bar'); | |
55 | |
56 hoverOverElement(picker._selectElement.children[0]); | |
57 shouldBeEqualToString('picker._selectElement.value', '0'); | |
58 shouldBeEqualToString('menuElement.value', 'bar'); | |
59 | |
60 hoverOverElement(picker._selectElement.children[1]); | |
61 shouldBeEqualToString('picker._selectElement.value', '1'); | |
62 shouldBeEqualToString('menuElement.value', 'bar'); | |
63 | |
64 hoverOverElement(menuElement); | |
65 shouldBeEqualToString('picker._selectElement.value', '1'); | |
66 shouldBeEqualToString('menuElement.value', 'bar'); | |
67 | |
68 // Start drag selecting but release outside the popup. | |
69 hoverOverElement(picker._selectElement.children[2]); | |
70 eventSender.mouseDown(); | |
71 hoverOverElement(picker._selectElement.children[0]); | |
72 hoverOverElement(menuElement); | |
73 eventSender.mouseUp(); | |
74 shouldNotBe('window.internals.pagePopupWindow', 'null'); | |
75 shouldBeEqualToString('picker._selectElement.value', '0'); | |
76 shouldBeEqualToString('menuElement.value', 'bar'); | |
77 | |
78 shouldBe('clickEventCounter', '0'); | |
79 shouldBe('mouseupEventCounter', '0'); | |
80 | |
81 clickElement(picker._selectElement.children[2]); | |
82 shouldBeNull('window.internals.pagePopupWindow'); | |
83 shouldBeEqualToString('menuElement.value', 'baz'); | |
84 | |
85 shouldBe('clickEventCounter', '1'); | |
86 shouldBe('mouseupEventCounter', '1'); | |
87 | |
88 waitUntilClosing(function() { | |
89 openPicker(menu, test2, openPickerErrorCallback); | |
90 }); | |
91 } | |
92 | |
93 function test2() { | |
94 picker = window.internals.pagePopupWindow.global.picker; | |
95 shouldBeEqualToString('picker._selectElement.value', '2'); | |
96 shouldBeEqualToString('internals.selectMenuListText(menu)', 'baz'); | |
97 | |
98 eventSender.keyDown('upArrow'); | |
99 shouldBeEqualToString('picker._selectElement.value', '1'); | |
100 shouldBeEqualToString('menu.value', 'baz'); | |
101 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
102 | |
103 // click outside to close popup | |
104 eventSender.mouseMoveTo(300, 1); | |
105 eventSender.mouseDown(); | |
106 eventSender.mouseUp(); | |
107 shouldBeNull('window.internals.pagePopupWindow'); | |
108 shouldBeEqualToString('menu.value', 'bar'); | |
109 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
110 | |
111 waitUntilClosing(function() { | |
112 openPicker(menu2, test3, openPickerErrorCallback); | |
113 }); | |
114 } | |
115 | |
116 function test3() { | |
117 picker = window.internals.pagePopupWindow.global.picker; | |
118 // We had a bug that almost-invisible OPTION was selected and the popup was | |
119 // scrolled. crbug.com/558287. | |
120 eventSender.mouseMoveTo(10, picker._selectElement.offsetHeight - 2); | |
121 shouldBeEqualToString('picker._selectElement.selectedOptions[0].label', 'opt
ion20'); | |
122 | |
123 finishJSTest(); | |
124 } | |
125 | |
126 | |
127 </script> | |
128 </body> | |
129 </html> | |
OLD | NEW |