diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs
index 2e4ce0f9a37..4fea7a69ff6 100644
--- a/components/script/dom/htmloptionscollection.rs
+++ b/components/script/dom/htmloptionscollection.rs
@@ -6,6 +6,7 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
use dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding;
use dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsCollectionMethods;
+use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
use dom::bindings::codegen::UnionTypes::{HTMLOptionElementOrHTMLOptGroupElement, HTMLElementOrLong};
use dom::bindings::error::{Error, ErrorResult};
@@ -16,6 +17,7 @@ use dom::bindings::str::DOMString;
use dom::element::Element;
use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmloptionelement::HTMLOptionElement;
+use dom::htmlselectelement::HTMLSelectElement;
use dom::node::{document_from_node, Node};
use dom::window::Window;
@@ -182,4 +184,22 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
element.Remove();
}
}
+
+ // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-selectedindex
+ fn SelectedIndex(&self) -> i32 {
+ self.upcast()
+ .root_node()
+ .downcast::()
+ .expect("HTMLOptionsCollection not rooted on a HTMLSelectElement")
+ .SelectedIndex()
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-selectedindex
+ fn SetSelectedIndex(&self, index: i32) {
+ self.upcast()
+ .root_node()
+ .downcast::()
+ .expect("HTMLOptionsCollection not rooted on a HTMLSelectElement")
+ .SetSelectedIndex(index)
+ }
}
diff --git a/components/script/dom/webidls/HTMLOptionsCollection.webidl b/components/script/dom/webidls/HTMLOptionsCollection.webidl
index bb6fce7dc20..73b11779159 100644
--- a/components/script/dom/webidls/HTMLOptionsCollection.webidl
+++ b/components/script/dom/webidls/HTMLOptionsCollection.webidl
@@ -14,5 +14,5 @@ interface HTMLOptionsCollection : HTMLCollection {
void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
//[CEReactions]
void remove(long index);
- //attribute long selectedIndex;
+ attribute long selectedIndex;
};
diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index 22bf80f6bd8..8d94376b643 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -175595,7 +175595,7 @@
"testharness"
],
"html/semantics/forms/the-select-element/selected-index.html": [
- "3ab30abb683f3fb42b6fdc84555126379d472a3d",
+ "0753a7487a10bde3b879d4c2ed10ba3d0260a48a",
"testharness"
],
"html/semantics/forms/the-textarea-element/.gitkeep": [
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index e7f2a58aca8..0ad2a61033a 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -720,18 +720,12 @@
[HTMLCollection interface: calling namedItem(DOMString) on document.all with too few arguments must throw TypeError]
expected: FAIL
- [HTMLOptionsCollection interface: attribute selectedIndex]
- expected: FAIL
-
[HTMLOptionsCollection interface: document.createElement("select").options must inherit property "add" with the proper type (3)]
expected: FAIL
[HTMLOptionsCollection interface: document.createElement("select").options must inherit property "remove" with the proper type (4)]
expected: FAIL
- [HTMLOptionsCollection interface: document.createElement("select").options must inherit property "selectedIndex" with the proper type (5)]
- expected: FAIL
-
[HTMLPropertiesCollection interface: existence and properties of interface object]
expected: FAIL
@@ -9723,9 +9717,6 @@
[Navigator interface: window.navigator must inherit property "hardwareConcurrency" with the proper type (22)]
expected: FAIL
- [HTMLOptionsCollection interface: document.createElement("select").options must inherit property "selectedIndex" with the proper type (4)]
- expected: FAIL
-
[HTMLEmbedElement interface: document.createElement("embed") must inherit property "align" with the proper type (5)]
expected: FAIL
diff --git a/tests/wpt/web-platform-tests/html/semantics/forms/the-select-element/selected-index.html b/tests/wpt/web-platform-tests/html/semantics/forms/the-select-element/selected-index.html
index 1be5378cdf4..6c30698a8ae 100644
--- a/tests/wpt/web-platform-tests/html/semantics/forms/the-select-element/selected-index.html
+++ b/tests/wpt/web-platform-tests/html/semantics/forms/the-select-element/selected-index.html
@@ -28,46 +28,76 @@