зеркало из https://github.com/mozilla/gecko-dev.git
Bug 672810 - ctrl+shift+arrow should extend selection in multiselectable listbox (HTML select). r=bzbarsky
This commit is contained in:
Родитель
4fdc3501bb
Коммит
87afedd042
|
@ -2649,9 +2649,10 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
// Actually process the new index and let the selection code
|
||||
// do the scrolling for us
|
||||
if (newIndex != kNothingSelected) {
|
||||
// If you hold control, no key will actually do anything except space.
|
||||
// If you hold control, but not shift, no key will actually do anything
|
||||
// except space.
|
||||
PRBool wasChanged = PR_FALSE;
|
||||
if (isControl && charcode != ' ') {
|
||||
if (isControl && !isShift && charcode != ' ') {
|
||||
mStartSelectionIndex = newIndex;
|
||||
mEndSelectionIndex = newIndex;
|
||||
InvalidateFocus();
|
||||
|
|
|
@ -77,6 +77,7 @@ _TEST_FILES = test_bug231389.html \
|
|||
test_bug620936.html \
|
||||
test_bug595310.html \
|
||||
test_bug644542.html \
|
||||
test_bug672810.html \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=672810
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 672810</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=672810">Mozilla Bug 672810</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 672810 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
var sel = document.getElementsByTagName('select');
|
||||
|
||||
sel[0].addEventListener('focus', function() {
|
||||
s = sel[0];
|
||||
s.removeEventListener('focus', arguments.callee, false);
|
||||
synthesizeKey('VK_DOWN', {});
|
||||
is(s.selectedIndex,0, s.id + ": initial DOWN selects first option");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true});
|
||||
is(s.selectedIndex,0, s.id + ": first option is still selected");
|
||||
ok(!s[1].selected,s.id + ": CTRL+DOWN did not select 2nd option");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true});
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,0, s.id + ": first option is still selected");
|
||||
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
|
||||
ok(s[2].selected,s.id + ": 3rd option is selected");
|
||||
ok(s[3].selected,s.id + ": 4th option is selected");
|
||||
ok(!s[4].selected,s.id + ": 5th option is unselected");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,0, s.id + ": first option is still selected");
|
||||
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
|
||||
ok(s[2].selected,s.id + ": 3rd option is still selected");
|
||||
ok(s[3].selected,s.id + ": 4th option is still selected");
|
||||
ok(s[4].selected,s.id + ": 5th option is selected");
|
||||
ok(!s[5].selected,s.id + ": 6th option is unselected");
|
||||
synthesizeKey('VK_UP', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,0, s.id + ": first option is still selected");
|
||||
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
|
||||
ok(s[2].selected,s.id + ": 3rd option is still selected");
|
||||
ok(s[3].selected,s.id + ": 4th option is still selected");
|
||||
ok(s[4].selected,s.id + ": 5th option is still selected");
|
||||
ok(!s[5].selected,s.id + ": 6th option is still unselected");
|
||||
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,0, s.id + ": first option is still selected");
|
||||
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
|
||||
ok(s[2].selected,s.id + ": 3rd option is still selected");
|
||||
ok(!s[3].selected,s.id + ": 4th option is unselected");
|
||||
ok(s[4].selected,s.id + ": 5th option is still selected");
|
||||
ok(!s[5].selected,s.id + ": 6th option is still unselected");
|
||||
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,0, s.id + ": first option is still selected");
|
||||
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
|
||||
ok(s[2].selected,s.id + ": 3rd option is still selected");
|
||||
ok(s[3].selected,s.id + ": 4th option is selected");
|
||||
ok(s[4].selected,s.id + ": 5th option is still selected");
|
||||
ok(!s[5].selected,s.id + ": 6th option is still unselected");
|
||||
setTimeout(function(){sel[1].focus()},0);
|
||||
}, false);
|
||||
sel[1].addEventListener('focus', function() {
|
||||
s = sel[1];
|
||||
s.removeEventListener('focus', arguments.callee, false);
|
||||
synthesizeKey('VK_DOWN', {});
|
||||
is(s.selectedIndex,0, s.id + ": initial DOWN selects first option");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true});
|
||||
is(s.selectedIndex,1, s.id + ": 2nd option is selected");
|
||||
ok(!s[0].selected,s.id + ": CTRL+DOWN deselected first option");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true});
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,3, s.id + ": 4th option is selected");
|
||||
ok(!s[1].selected,s.id + ": CTRL+SHIFT+DOWN deselected 2nd option");
|
||||
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
|
||||
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
|
||||
setTimeout(function(){sel[2].focus()},0);
|
||||
}, false);
|
||||
sel[2].addEventListener('focus', function() {
|
||||
s = sel[2];
|
||||
s.removeEventListener('focus', arguments.callee, false);
|
||||
synthesizeKey('VK_DOWN', {});
|
||||
is(s.selectedIndex,1, s.id + ": initial DOWN selects 2nd option");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true});
|
||||
is(s.selectedIndex,2, s.id + ": 3rd option is selected");
|
||||
ok(!s[1].selected,s.id + ": CTRL+DOWN deselected 2nd option");
|
||||
synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,3, s.id + ": 4th option is selected");
|
||||
ok(!s[2].selected,s.id + ": CTRL+SHIFT+DOWN deselected 3rd option");
|
||||
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
|
||||
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
|
||||
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
|
||||
setTimeout(function(){SimpleTest.finish()},0);
|
||||
}, false);
|
||||
sel[0].focus();
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче