Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select / popup-menu-update-from-element.html
blob13d1a8c3fc76f28738dda20c1d5f4fe53027c548
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 selected>foo</option>
11 <option>bar</option>
12 <option hidden>baz</option>
13 <optgroup label="qux">
14 <option>garply</option>
15 </optgroup>
16 </select>
17 <script>
18 var menuElement = document.getElementById('menu');
19 var picker;
21 function openPickerErrorCallback() {
22 testFailed('picker didn\'t open')
23 finishJSTest();
25 openPicker(menu, test1, openPickerErrorCallback);
27 function test1() {
28 picker = window.internals.pagePopupWindow.global.picker;
30 function onUpdate() {
31 setTimeout(function() {
32 shouldBeEqualToString('picker._selectElement.style.color', 'rgb(123, 0, 0)');
33 shouldBeEqualToString('picker._selectElement.options[0].style.color', '');
34 picker.removeListener("didUpdate", onUpdate);
35 test2();
36 });
38 picker.on("didUpdate", onUpdate);
39 menuElement.style.color = 'rgb(123, 0, 0)';
42 function test2() {
43 hoverOverElement(picker._selectElement.children[0]);
44 shouldBeEqualToString('picker._selectElement.value', '0');
45 eventSender.keyDown('downArrow');
46 shouldBeEqualToString('picker._selectElement.value', '1');
48 picker.on("didUpdate", onUpdate);
49 menuElement.innerHTML = '<option>FOO</option><option>BAR</option><optgroup label="BAZ"></optgroup>';
51 function onUpdate() {
52 setTimeout(function() {
53 shouldBeEqualToString('picker._selectElement.value', '1');
54 shouldBe('picker._selectElement.options.length', '2');
55 shouldBeEqualToString('picker._selectElement.children[0].label', 'FOO');
56 shouldBeEqualToString('picker._selectElement.children[1].label', 'BAR');
57 shouldBeEqualToString('picker._selectElement.children[2].tagName', 'OPTGROUP');
58 shouldBeEqualToString('picker._selectElement.children[2].label', 'BAZ');
59 picker.removeListener("didUpdate", onUpdate);
60 test3();
61 }, 0);
65 function test3() {
66 hoverOverElement(picker._selectElement.children[2]);
67 shouldBeEqualToString('picker._selectElement.value', '1');
69 menuElement.innerHTML = '<option>FOO</option><option>BAR</option><option selected>QUX</option>';
71 picker.on("didUpdate", function () {
72 setTimeout(function () {
73 shouldBeEqualToString('picker._selectElement.value', '2');
74 finishJSTest();
75 }, 0);
76 });
78 </script>
79 </body>
80 </html>