test_bug672810.html (5873B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=672810 5 --> 6 <head> 7 <title>Test for Bug 672810</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=672810">Mozilla Bug 672810</a> 14 <p id="display"></p> 15 <div id="content"> 16 <select id="s1" multiple size="10"><option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x</select> 17 <select id="s2" size="10"><option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x</select> 18 <select id="s3" size="1"><option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x</select> 19 </div> 20 <pre id="test"> 21 <script type="application/javascript"> 22 23 /** Test for Bug 672810 */ 24 25 SimpleTest.waitForExplicitFinish(); 26 27 SimpleTest.waitForFocus(function() { 28 var sel = document.getElementsByTagName('select'); 29 30 sel[0].addEventListener('focus', function() { 31 s = sel[0]; 32 s.removeEventListener('focus', arguments.callee); 33 synthesizeKey('KEY_ArrowDown'); 34 is(s.selectedIndex,0, s.id + ": initial DOWN selects first option"); 35 synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); 36 is(s.selectedIndex,0, s.id + ": first option is still selected"); 37 ok(!s[1].selected,s.id + ": CTRL+DOWN did not select 2nd option"); 38 synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); 39 synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); 40 is(s.selectedIndex,0, s.id + ": first option is still selected"); 41 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); 42 ok(s[2].selected,s.id + ": 3rd option is selected"); 43 ok(s[3].selected,s.id + ": 4th option is selected"); 44 ok(!s[4].selected,s.id + ": 5th option is unselected"); 45 synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); 46 is(s.selectedIndex,0, s.id + ": first option is still selected"); 47 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); 48 ok(s[2].selected,s.id + ": 3rd option is still selected"); 49 ok(s[3].selected,s.id + ": 4th option is still selected"); 50 ok(s[4].selected,s.id + ": 5th option is selected"); 51 ok(!s[5].selected,s.id + ": 6th option is unselected"); 52 synthesizeKey('KEY_ArrowUp', {ctrlKey: true, shiftKey: true}); 53 is(s.selectedIndex,0, s.id + ": first option is still selected"); 54 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); 55 ok(s[2].selected,s.id + ": 3rd option is still selected"); 56 ok(s[3].selected,s.id + ": 4th option is still selected"); 57 ok(s[4].selected,s.id + ": 5th option is still selected"); 58 ok(!s[5].selected,s.id + ": 6th option is still unselected"); 59 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); 60 is(s.selectedIndex,0, s.id + ": first option is still selected"); 61 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); 62 ok(s[2].selected,s.id + ": 3rd option is still selected"); 63 ok(!s[3].selected,s.id + ": 4th option is unselected"); 64 ok(s[4].selected,s.id + ": 5th option is still selected"); 65 ok(!s[5].selected,s.id + ": 6th option is still unselected"); 66 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); 67 is(s.selectedIndex,0, s.id + ": first option is still selected"); 68 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); 69 ok(s[2].selected,s.id + ": 3rd option is still selected"); 70 ok(s[3].selected,s.id + ": 4th option is selected"); 71 ok(s[4].selected,s.id + ": 5th option is still selected"); 72 ok(!s[5].selected,s.id + ": 6th option is still unselected"); 73 setTimeout(function(){sel[1].focus()},0); 74 }); 75 sel[1].addEventListener('focus', function() { 76 s = sel[1]; 77 s.removeEventListener('focus', arguments.callee); 78 synthesizeKey('KEY_ArrowDown'); 79 is(s.selectedIndex,0, s.id + ": initial DOWN selects first option"); 80 synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); 81 is(s.selectedIndex,1, s.id + ": 2nd option is selected"); 82 ok(!s[0].selected,s.id + ": CTRL+DOWN deselected first option"); 83 synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); 84 synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); 85 is(s.selectedIndex,3, s.id + ": 4th option is selected"); 86 ok(!s[1].selected,s.id + ": CTRL+SHIFT+DOWN deselected 2nd option"); 87 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); 88 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); 89 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); 90 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); 91 setTimeout(function(){sel[2].focus()},0); 92 }); 93 sel[2].addEventListener('focus', function() { 94 if (!navigator.platform.includes("Mac")) { 95 s = sel[2]; 96 s.removeEventListener('focus', arguments.callee); 97 synthesizeKey('KEY_ArrowDown'); 98 is(s.selectedIndex,1, s.id + ": initial DOWN selects 2nd option"); 99 synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); 100 is(s.selectedIndex,2, s.id + ": 3rd option is selected"); 101 ok(!s[1].selected,s.id + ": CTRL+DOWN deselected 2nd option"); 102 synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); 103 is(s.selectedIndex,3, s.id + ": 4th option is selected"); 104 ok(!s[2].selected,s.id + ": CTRL+SHIFT+DOWN deselected 3rd option"); 105 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); 106 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); 107 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); 108 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); 109 } else { 110 todo(false, "Make this test work on OSX"); 111 } 112 setTimeout(function(){SimpleTest.finish()},0); 113 }); 114 sel[0].focus(); 115 }); 116 117 </script> 118 </pre> 119 </body> 120 </html>