4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
6 <script src=
"../resources/picker-common.js"></script>
11 <option selected
>bar
</option>
15 var menuElement
= document
.getElementById('menu');
17 var clickEventCounter
= 0;
18 menuElement
.addEventListener('click', function() { clickEventCounter
++; }, false);
19 var mouseupEventCounter
= 0;
20 menuElement
.addEventListener('mouseup', function() { mouseupEventCounter
++; }, false);
22 function openPickerErrorCallback() {
23 testFailed('picker didn\'t open')
26 openPicker(menu
, test1
, openPickerErrorCallback
);
28 picker
= window
.internals
.pagePopupWindow
.global
.picker
;
29 shouldBeEqualToString('picker._selectElement.value', '1');
30 shouldBeEqualToString('menuElement.value', 'bar');
32 hoverOverElement(picker
._selectElement
.children
[0]);
33 shouldBeEqualToString('picker._selectElement.value', '0');
34 shouldBeEqualToString('menuElement.value', 'bar');
36 hoverOverElement(picker
._selectElement
.children
[1]);
37 shouldBeEqualToString('picker._selectElement.value', '1');
38 shouldBeEqualToString('menuElement.value', 'bar');
40 hoverOverElement(menuElement
);
41 shouldBeEqualToString('picker._selectElement.value', '1');
42 shouldBeEqualToString('menuElement.value', 'bar');
44 // Start drag selecting but release outside the popup.
45 hoverOverElement(picker
._selectElement
.children
[2]);
46 eventSender
.mouseDown();
47 hoverOverElement(picker
._selectElement
.children
[0]);
48 hoverOverElement(menuElement
);
49 eventSender
.mouseUp();
50 shouldNotBe('window.internals.pagePopupWindow', 'null');
51 shouldBeEqualToString('picker._selectElement.value', '0');
52 shouldBeEqualToString('menuElement.value', 'bar');
54 shouldBe('clickEventCounter', '0');
55 shouldBe('mouseupEventCounter', '0');
57 clickElement(picker
._selectElement
.children
[2]);
58 shouldBeNull('window.internals.pagePopupWindow');
59 shouldBeEqualToString('menuElement.value', 'baz');
61 shouldBe('clickEventCounter', '1');
62 shouldBe('mouseupEventCounter', '1');
64 waitUntilClosing(function() {
65 openPicker(menu
, test2
, openPickerErrorCallback
);
70 picker
= window
.internals
.pagePopupWindow
.global
.picker
;
71 shouldBeEqualToString('picker._selectElement.value', '2');
72 shouldBeEqualToString('internals.selectMenuListText(menu)', 'baz');
74 eventSender
.keyDown('upArrow');
75 shouldBeEqualToString('picker._selectElement.value', '1');
76 shouldBeEqualToString('menu.value', 'baz');
77 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar');
79 // click outside to close popup
80 eventSender
.mouseMoveTo(300, 1);
81 eventSender
.mouseDown();
82 eventSender
.mouseUp();
83 shouldBeNull('window.internals.pagePopupWindow');
84 shouldBeEqualToString('menu.value', 'bar');
85 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar');