Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
selectedIndex
property on <select>
.
- Loading branch information
Showing
5 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tests/wpt/web-platform-tests/html/semantics/forms/the-select-element/selected-index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>HTMLSelectElement selectedIndex</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id=log></div> | ||
|
||
<form id=form> | ||
<select id=empty></select> | ||
|
||
<select id=default> | ||
<option></option> | ||
<option></option> | ||
<option></option> | ||
<option></option> | ||
<option></option> | ||
</select> | ||
|
||
<select id=disabled> | ||
<option disabled></option> | ||
<option></option> | ||
</select> | ||
|
||
<select id=selected> | ||
<option></option> | ||
<option selected></option> | ||
</select> | ||
</form> | ||
|
||
<script> | ||
test(function () { | ||
var select = document.getElementById('empty'); | ||
assert_equals(select.selectedIndex, -1); | ||
}, "get empty"); | ||
|
||
test(function () { | ||
var select = document.getElementById('default'); | ||
assert_equals(select.selectedIndex, 0); | ||
}, "get default"); | ||
|
||
test(function () { | ||
var select = document.getElementById('disabled'); | ||
assert_equals(select.selectedIndex, 1); | ||
}, "get disabled"); | ||
|
||
test(function () { | ||
var select = document.getElementById('selected'); | ||
assert_equals(select.selectedIndex, 1); | ||
}, "get unselected"); | ||
|
||
test(function () { | ||
var select = document.getElementById('empty'); | ||
select.selectedIndex = 1; | ||
assert_equals(select.selectedIndex, -1); | ||
}, "set empty"); | ||
|
||
test(function () { | ||
var select = document.getElementById('default'); | ||
assert_equals(select.selectedIndex, 0); | ||
select.selectedIndex = 2; | ||
assert_equals(select.selectedIndex, 2); | ||
}, "set"); | ||
|
||
test(function () { | ||
var select = document.getElementById('selected'); | ||
var form = document.getElementById('form'); | ||
assert_equals(select.selectedIndex, 1); | ||
select.selectedIndex = 0; | ||
assert_equals(select.selectedIndex, 0); | ||
form.reset(); | ||
assert_equals(select.selectedIndex, 1); | ||
}, "set and reset"); | ||
</script> |