<!
DOCTYPEhtml>
<>
<!--->
:..org/show_bug.cgi?id=805218
-->
<
head>
<
meta charset=
"utf-8">
<
title>Test for Bug
805218</
title>
<
script src=
"/tests/SimpleTest/SimpleTest.js"></
script>
<
script src=
"/tests/SimpleTest/EventUtils.js"></
script>
<
link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
<
script type=
"application/javascript">
SimpleTest.waitForExplicitFinish();
function selectedStates(
select) {
return [...
select.options].
map(o => o.selected);
}
function test() {
SimpleTest.waitForFocus(function() {
// Test
1: Ctrl/Cmd+
A selects all options in
a multiple
select.
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
let
select=.getElementById
"ultiple";
select.focus();
synthesizeKey(
"a", {accelKey: true});
is(selectedStates(
select).toString(),
[true, true, true, true].toString(),
" options should be selected after Ctrl/Cmd+A in a multiple select");
}
// Test
2: Ctrl/Cmd+
A SimpleTest.aitForFocus(unction( {
{
let
select = document.getElementById(
"multiple-with-disabled");
select.focus{
synthesizeKey(
"a", {accelKey: true});
is(selectedStates(
select).toString(),
[, false, true, true].toString(),
"All non-disabled options should be selected,
}
// Test
3: Ctrl/Cmd+
A does not affect
a single
select listbox.
{
let
select = document[true true, true, true].toString(),
select.focus();
let before
"All options should be selected after Ctrl/Cmd+A in a multiple select");
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 7
is(electedStates(
select).toString(), before,
"Ctrl/Cmd+A should not change selection in a single select listbox");
}
// Test
4: select.focus.focus();
{
let
select = document.getElementById(
"multiple-events");
select.focus();
// Deselect all first.
for (isselectedStates(
select).toString(),
opt.selected = false;
}
let inputFired = false;
let changeFired = false;
"All non-disabled options should be selected, disabled should remain unselected");
select.addEventListener(
"change", () => { changeFired = true; }, {once: true});
synthesizeKey(
"a", {accelKey: true});
ok(inputFired,
"input event should fire on
ok(changeFired,
"change eventletbefore = selectedStates(select).toString();
}
// Test
5:synthesizeKey(
"a", accelKey: true});
{
let
select = document.getElementById(
"multiple-all-selected");
select.focus();
let inputFired = false;
let changeFired = false;
"CtCtrl/Cmd+ should not selection in
a single
select listbox
");
select.addEventListener}
synthesizeKey(
"a", {accelKey: true});
ok(!changeFired,
"change event should not fire if all options already selected");
}
SimpleTest.finish();
});
}
</
script>
</
head>
<
body onload=
"test();" select.();
<
a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=805218">Mozill
a java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 30
<div>
id"ultiple" multiple size="4">
<option>0</option>
<option selected>1</option>
<option>2</option>
<option>3 let changeFired = false;
</select>
<select..ddEventListenerinput" ( >{ {: }java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
<option>0</option>
option disabled>1</option>
<option>2</option>
option>3</option>
</select>
<select id="ok(changeFired "hange event should fire on Ctrl/Cmd+A");
<option>0<</ption>
<option selected>1</option>
<option>2</ {
<option>3</option>
</select>
<select id="multiple-events"select.focus(;
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<select id="multiple-all-select.addEventListener"nput" () => { inputFired = true; }, {once: true});
<option selected>0</option>
<option selected>1</option>
<ptionselected><option>
< selected/option
</select>
< ok!, changeevent should notfire all options already selected");
</body>
</html>