Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select / popup-menu-mouse-operations.html
blob4e5112027275670fd6f4abf14c335e6e9af148e6
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 <script>
15 var menuElement = document.getElementById('menu');
16 var picker = null;
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')
24 finishJSTest();
26 openPicker(menu, test1, openPickerErrorCallback);
27 function test1() {
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);
66 });
69 function test2() {
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');
87 finishJSTest();
91 </script>
92 </body>
93 </html>