4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
8 <p>Test if selected options are correctly restored even if their positions were changed.
</p>
9 <div id=
"console"></div>
11 <input id=
"emptyOnFirstVisit">
13 <form action=
"data:text/html,<script>history.back()</script>" id=form1
>
14 <select id=
"select1" multiple
>
15 <option id=
"opt-ca-1" value=
"CA">California
1</option>
16 <option id=
"opt-ca-2" value=
"CA" selected
>California
2</option>
17 <option id=
"opt-la">LA
</option>
19 <option id=
"opt-tk" selected
>Tokyo
</option>
20 <option id=
"opt-os">Osaka
</option>
22 <option id=
"opt-ak" value=
"AK">Alaska
</option>
23 <option id=
"opt-wy" selected
>WY
</option>
34 var state
= document
.getElementById('emptyOnFirstVisit');
37 setTimeout(function() {
38 state
.value
= 'visited';
39 $('opt-tk').selected
= false;
40 $('opt-os').selected
= true;
41 $('select1').insertBefore($('opt-ak'), $('opt-ca-1'));
42 $('select1').removeChild($('opt-wy'));
43 var newOption
= document
.createElement('option');
44 newOption
.textContent
= 'NY';
45 $('select1').appendChild(newOption
);
46 newOption
.selected
= true;
50 // Went back to this page again, and form state should be restored.
51 shouldBeFalse('$("opt-la").selected');
52 shouldBeFalse('$("opt-tk").selected');
53 shouldBeTrue('$("opt-os").selected');
54 shouldBeFalse('$("opt-ak").selected');
55 shouldBeFalse('$("opt-wy").selected');
56 debug('We don\'t care which one is selected because their values are identical:');
57 shouldBeTrue('!!($("opt-ca-1").selected ^ $("opt-ca-2").selected)');
59 $('parent').innerHTML
= '';
60 setTimeout(function() {
66 window
.onload
= runTest
;