Index: third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-select-element/selected-index.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-select-element/selected-index.html b/third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-select-element/selected-index.html |
index 1be5378cdf4fae7ad5d717c67b5fff97636a33e3..6c30698a8ae1f79e5db21e8912d19b55d803910f 100644 |
--- a/third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-select-element/selected-index.html |
+++ b/third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-select-element/selected-index.html |
@@ -28,46 +28,76 @@ |
</form> |
<script> |
+function assertSelectedIndex(select, value) { |
+ assert_equals(select.selectedIndex, value); |
+ assert_equals(select.options.selectedIndex, value); |
+} |
+ |
test(function () { |
var select = document.getElementById('empty'); |
- assert_equals(select.selectedIndex, -1); |
+ assertSelectedIndex(select, -1); |
}, "get empty"); |
test(function () { |
var select = document.getElementById('default'); |
- assert_equals(select.selectedIndex, 0); |
+ assertSelectedIndex(select, 0); |
}, "get default"); |
test(function () { |
var select = document.getElementById('disabled'); |
- assert_equals(select.selectedIndex, 1); |
+ assertSelectedIndex(select, 1); |
}, "get disabled"); |
test(function () { |
var select = document.getElementById('selected'); |
- assert_equals(select.selectedIndex, 1); |
+ assertSelectedIndex(select, 1); |
}, "get unselected"); |
test(function () { |
var select = document.getElementById('empty'); |
select.selectedIndex = 1; |
- assert_equals(select.selectedIndex, -1); |
-}, "set empty"); |
+ assertSelectedIndex(select, -1); |
+}, "set empty (HTMLSelectElement)"); |
+ |
+test(function () { |
+ var select = document.getElementById('empty'); |
+ select.options.selectedIndex = 1; |
+ assertSelectedIndex(select, -1); |
+}, "set empty (HTMLOptionsCollection)"); |
test(function () { |
var select = document.getElementById('default'); |
- assert_equals(select.selectedIndex, 0); |
+ assertSelectedIndex(select, 0); |
select.selectedIndex = 2; |
- assert_equals(select.selectedIndex, 2); |
-}, "set"); |
+ assertSelectedIndex(select, 2); |
+ this.add_cleanup(() => select.selectedIndex = 0); |
+}, "set (HTMLSelectElement)"); |
+ |
+test(function () { |
+ var select = document.getElementById('default'); |
+ assertSelectedIndex(select, 0); |
+ select.options.selectedIndex = 2; |
+ assertSelectedIndex(select, 2); |
+ this.add_cleanup(() => select.selectedIndex = 0); |
+}, "set (HTMLOptionsCollection)"); |
test(function () { |
var select = document.getElementById('selected'); |
var form = document.getElementById('form'); |
- assert_equals(select.selectedIndex, 1); |
+ assertSelectedIndex(select, 1); |
select.selectedIndex = 0; |
- assert_equals(select.selectedIndex, 0); |
+ assertSelectedIndex(select, 0); |
+ form.reset(); |
+ assertSelectedIndex(select, 1); |
+}, "set and reset (HTMLSelectElement)"); |
+ |
+test(function () { |
+ var select = document.getElementById('selected'); |
+ var form = document.getElementById('form'); |
+ assertSelectedIndex(select, 1); |
+ select.options.selectedIndex = 0; |
+ assertSelectedIndex(select, 0); |
form.reset(); |
- assert_equals(select.selectedIndex, 1); |
-}, "set and reset"); |
+ assertSelectedIndex(select, 1); |
+}, "set and reset (HTMLOptionsCollection)"); |
</script> |