| 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 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; | |
| 20 | |
| 21 function openPickerErrorCallback() { | |
| 22 testFailed('picker didn\'t open') | |
| 23 finishJSTest(); | |
| 24 } | |
| 25 openPicker(menu, test1, openPickerErrorCallback); | |
| 26 | |
| 27 function test1() { | |
| 28 picker = window.internals.pagePopupWindow.global.picker; | |
| 29 | |
| 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 }); | |
| 37 } | |
| 38 picker.on("didUpdate", onUpdate); | |
| 39 menuElement.style.color = 'rgb(123, 0, 0)'; | |
| 40 } | |
| 41 | |
| 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'); | |
| 47 | |
| 48 picker.on("didUpdate", onUpdate); | |
| 49 menuElement.innerHTML = '<option>FOO</option><option>BAR</option><optgroup l
abel="BAZ"></optgroup>'; | |
| 50 | |
| 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', 'FO
O'); | |
| 56 shouldBeEqualToString('picker._selectElement.children[1].label', 'BA
R'); | |
| 57 shouldBeEqualToString('picker._selectElement.children[2].tagName', '
OPTGROUP'); | |
| 58 shouldBeEqualToString('picker._selectElement.children[2].label', 'BA
Z'); | |
| 59 picker.removeListener("didUpdate", onUpdate); | |
| 60 test3(); | |
| 61 }, 0); | |
| 62 }; | |
| 63 } | |
| 64 | |
| 65 function test3() { | |
| 66 hoverOverElement(picker._selectElement.children[2]); | |
| 67 shouldBeEqualToString('picker._selectElement.value', '1'); | |
| 68 | |
| 69 menuElement.innerHTML = '<option>FOO</option><option>BAR</option><option sel
ected>QUX</option>'; | |
| 70 | |
| 71 picker.on("didUpdate", function () { | |
| 72 setTimeout(function () { | |
| 73 shouldBeEqualToString('picker._selectElement.value', '2'); | |
| 74 finishJSTest(); | |
| 75 }, 0); | |
| 76 }); | |
| 77 } | |
| 78 </script> | |
| 79 </body> | |
| 80 </html> | |
| OLD | NEW |