Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=571352 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 571352</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=571352">Mozilla Bug 571352</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | |
michael@0 | 17 | </div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script type="application/javascript"> |
michael@0 | 20 | |
michael@0 | 21 | /** Test for Bug 571352 **/ |
michael@0 | 22 | |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | SimpleTest.waitForFocus(function test() { |
michael@0 | 25 | function createList() { |
michael@0 | 26 | $('display').innerHTML = '<select multiple><option>0<option>1<option>2<option>3<option>4<option>5</select>'; |
michael@0 | 27 | $('display').firstChild.focus(); |
michael@0 | 28 | } |
michael@0 | 29 | function option(index) { |
michael@0 | 30 | return $('display').firstChild.childNodes[index]; |
michael@0 | 31 | } |
michael@0 | 32 | function remove(index) { |
michael@0 | 33 | var sel = $('display').firstChild; |
michael@0 | 34 | sel.removeChild(sel.childNodes[index]); |
michael@0 | 35 | } |
michael@0 | 36 | function up() { synthesizeKey("VK_UP", {}); } |
michael@0 | 37 | function shiftUp() { synthesizeKey("VK_UP", {shiftKey:true}); } |
michael@0 | 38 | function down() { synthesizeKey("VK_DOWN", {}); } |
michael@0 | 39 | function shiftDown() { synthesizeKey("VK_DOWN", {shiftKey:true}); } |
michael@0 | 40 | function mouseEvent(index,event) { |
michael@0 | 41 | synthesizeMouse(option(index), 5, 5, event); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | const click = {}; |
michael@0 | 45 | const shiftClick = {shiftKey:true}; |
michael@0 | 46 | const CtrlClick = {CtrlKey:true}; |
michael@0 | 47 | createList(); |
michael@0 | 48 | mouseEvent(0,click) |
michael@0 | 49 | is(document.activeElement,$('display').firstChild,"<select> is focused"); |
michael@0 | 50 | mouseEvent(2,shiftClick) |
michael@0 | 51 | remove(0); |
michael@0 | 52 | ok(option(0).selected && option(1).selected,"first two options are selected"); |
michael@0 | 53 | mouseEvent(2,shiftClick) |
michael@0 | 54 | ok(option(0).selected && option(1).selected && option(2).selected,"first three options are selected"); |
michael@0 | 55 | shiftUp(); |
michael@0 | 56 | ok(option(0).selected && option(1).selected,"first two options are selected"); |
michael@0 | 57 | remove(1); |
michael@0 | 58 | ok(option(0).selected,"first option is selected"); |
michael@0 | 59 | shiftDown(); |
michael@0 | 60 | ok(option(0).selected && option(1).selected,"first two options are selected"); |
michael@0 | 61 | down(); |
michael@0 | 62 | ok(option(2).selected,"third option is selected"); |
michael@0 | 63 | shiftDown(); |
michael@0 | 64 | ok(option(2).selected && option(3).selected,"third & fourth option are selected"); |
michael@0 | 65 | remove(2); |
michael@0 | 66 | shiftUp(); |
michael@0 | 67 | ok(option(1).selected && option(2).selected,"2nd & third option are selected"); |
michael@0 | 68 | remove(0); |
michael@0 | 69 | mouseEvent(0,shiftClick) |
michael@0 | 70 | ok(option(0).selected && option(1).selected,"all remaining 2 options are selected"); |
michael@0 | 71 | shiftDown(); |
michael@0 | 72 | remove(1); |
michael@0 | 73 | ok(!option(0).selected,"first option is unselected"); |
michael@0 | 74 | remove(0); // select is now empty |
michael@0 | 75 | ok($('display').firstChild.firstChild==null,"all options were removed"); |
michael@0 | 76 | |
michael@0 | 77 | SimpleTest.finish(); |
michael@0 | 78 | }); |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | |
michael@0 | 82 | |
michael@0 | 83 | </script> |
michael@0 | 84 | </pre> |
michael@0 | 85 | </body> |
michael@0 | 86 | </html> |