diff options
7 files changed, 33 insertions, 268 deletions
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index b9df3cc83d0..eabda88f4f8 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -91,6 +91,35 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> { let node: JSRef<Node> = NodeCast::from_ref(self); node.SetTextContent(Some(value)) } + + // https://html.spec.whatwg.org/multipage/forms.html#attr-option-value + fn Value(self) -> DOMString { + let element: JSRef<Element> = ElementCast::from_ref(self); + let attr = &atom!("value"); + if element.has_attribute(attr) { + element.get_string_attribute(attr) + } else { + self.Text() + } + } + + // https://html.spec.whatwg.org/multipage/forms.html#attr-option-value + make_setter!(SetValue, "value") + + // https://html.spec.whatwg.org/multipage/forms.html#attr-option-label + fn Label(self) -> DOMString { + let element: JSRef<Element> = ElementCast::from_ref(self); + let attr = &atom!("label"); + if element.has_attribute(attr) { + element.get_string_attribute(attr) + } else { + self.Text() + } + } + + // https://html.spec.whatwg.org/multipage/forms.html#attr-option-label + make_setter!(SetLabel, "label") + } impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> { @@ -110,7 +139,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> { let node: JSRef<Node> = NodeCast::from_ref(*self); node.set_disabled_state(true); node.set_enabled_state(false); - }, + } _ => () } } diff --git a/components/script/dom/webidls/HTMLOptionElement.webidl b/components/script/dom/webidls/HTMLOptionElement.webidl index 5c3f4b37f6a..9126e24d790 100644 --- a/components/script/dom/webidls/HTMLOptionElement.webidl +++ b/components/script/dom/webidls/HTMLOptionElement.webidl @@ -6,12 +6,12 @@ // http://www.whatwg.org/html/#htmloptionelement //[NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)] interface HTMLOptionElement : HTMLElement { - attribute boolean disabled; + attribute boolean disabled; //readonly attribute HTMLFormElement? form; - // attribute DOMString label; + attribute DOMString label; // attribute boolean defaultSelected; // attribute boolean selected; - // attribute DOMString value; + attribute DOMString value; attribute DOMString text; //readonly attribute long index; diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index ab044ab945f..1b10c3fd820 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -6135,36 +6135,24 @@ [HTMLOptionElement interface: attribute form] expected: FAIL - [HTMLOptionElement interface: attribute label] - expected: FAIL - [HTMLOptionElement interface: attribute defaultSelected] expected: FAIL [HTMLOptionElement interface: attribute selected] expected: FAIL - [HTMLOptionElement interface: attribute value] - expected: FAIL - [HTMLOptionElement interface: attribute index] expected: FAIL [HTMLOptionElement interface: document.createElement("option") must inherit property "form" with the proper type (1)] expected: FAIL - [HTMLOptionElement interface: document.createElement("option") must inherit property "label" with the proper type (2)] - expected: FAIL - [HTMLOptionElement interface: document.createElement("option") must inherit property "defaultSelected" with the proper type (3)] expected: FAIL [HTMLOptionElement interface: document.createElement("option") must inherit property "selected" with the proper type (4)] expected: FAIL - [HTMLOptionElement interface: document.createElement("option") must inherit property "value" with the proper type (5)] - expected: FAIL - [HTMLOptionElement interface: document.createElement("option") must inherit property "index" with the proper type (7)] expected: FAIL diff --git a/tests/wpt/metadata/html/dom/reflection-forms.html.ini b/tests/wpt/metadata/html/dom/reflection-forms.html.ini index 49ed4d13f2c..0eca5cd8754 100644 --- a/tests/wpt/metadata/html/dom/reflection-forms.html.ini +++ b/tests/wpt/metadata/html/dom/reflection-forms.html.ini @@ -13527,93 +13527,6 @@ [option.tabIndex: IDL set to -2147483648 followed by getAttribute()] expected: FAIL - [option.label: typeof IDL attribute] - expected: FAIL - - [option.label: IDL get with DOM attribute unset] - expected: FAIL - - [option.label: IDL set to "" followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to undefined followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to undefined followed by IDL get] - expected: FAIL - - [option.label: IDL set to 7 followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to 7 followed by IDL get] - expected: FAIL - - [option.label: IDL set to 1.5 followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to 1.5 followed by IDL get] - expected: FAIL - - [option.label: IDL set to true followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to true followed by IDL get] - expected: FAIL - - [option.label: IDL set to false followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to false followed by IDL get] - expected: FAIL - - [option.label: IDL set to object "[object Object\]" followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to object "[object Object\]" followed by IDL get] - expected: FAIL - - [option.label: IDL set to NaN followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to NaN followed by IDL get] - expected: FAIL - - [option.label: IDL set to Infinity followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to Infinity followed by IDL get] - expected: FAIL - - [option.label: IDL set to -Infinity followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to -Infinity followed by IDL get] - expected: FAIL - - [option.label: IDL set to "\\0" followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to null followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to null followed by IDL get] - expected: FAIL - - [option.label: IDL set to object "test-toString" followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to object "test-toString" followed by IDL get] - expected: FAIL - - [option.label: IDL set to object "test-valueOf" followed by getAttribute()] - expected: FAIL - - [option.label: IDL set to object "test-valueOf" followed by IDL get] - expected: FAIL - [option.defaultSelected (<option selected>): typeof IDL attribute] expected: FAIL @@ -13722,93 +13635,6 @@ [option.defaultSelected (<option selected>): IDL set to object "test-valueOf" followed by IDL get] expected: FAIL - [option.value: typeof IDL attribute] - expected: FAIL - - [option.value: IDL get with DOM attribute unset] - expected: FAIL - - [option.value: IDL set to "" followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to undefined followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to undefined followed by IDL get] - expected: FAIL - - [option.value: IDL set to 7 followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to 7 followed by IDL get] - expected: FAIL - - [option.value: IDL set to 1.5 followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to 1.5 followed by IDL get] - expected: FAIL - - [option.value: IDL set to true followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to true followed by IDL get] - expected: FAIL - - [option.value: IDL set to false followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to false followed by IDL get] - expected: FAIL - - [option.value: IDL set to object "[object Object\]" followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to object "[object Object\]" followed by IDL get] - expected: FAIL - - [option.value: IDL set to NaN followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to NaN followed by IDL get] - expected: FAIL - - [option.value: IDL set to Infinity followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to Infinity followed by IDL get] - expected: FAIL - - [option.value: IDL set to -Infinity followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to -Infinity followed by IDL get] - expected: FAIL - - [option.value: IDL set to "\\0" followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to null followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to null followed by IDL get] - expected: FAIL - - [option.value: IDL set to object "test-toString" followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to object "test-toString" followed by IDL get] - expected: FAIL - - [option.value: IDL set to object "test-valueOf" followed by getAttribute()] - expected: FAIL - - [option.value: IDL set to object "test-valueOf" followed by IDL get] - expected: FAIL - [option.itemScope: typeof IDL attribute] expected: FAIL diff --git a/tests/wpt/metadata/html/semantics/forms/the-datalist-element/datalistoptions.html.ini b/tests/wpt/metadata/html/semantics/forms/the-datalist-element/datalistoptions.html.ini index b85d32fea50..47ebd87c928 100644 --- a/tests/wpt/metadata/html/semantics/forms/the-datalist-element/datalistoptions.html.ini +++ b/tests/wpt/metadata/html/semantics/forms/the-datalist-element/datalistoptions.html.ini @@ -1,7 +1,5 @@ [datalistoptions.html] type: testharness - [options label/value] - expected: FAIL [If an element has a datalist element ancestor, it is barred from constraint validation] expected: FAIL diff --git a/tests/wpt/metadata/html/semantics/forms/the-option-element/option-label.html.ini b/tests/wpt/metadata/html/semantics/forms/the-option-element/option-label.html.ini deleted file mode 100644 index 157f536349f..00000000000 --- a/tests/wpt/metadata/html/semantics/forms/the-option-element/option-label.html.ini +++ /dev/null @@ -1,38 +0,0 @@ -[option-label.html] - type: testharness - [No children, no label] - expected: FAIL - - [No children, empty label] - expected: FAIL - - [No children, label] - expected: FAIL - - [No children, namespaced label] - expected: FAIL - - [Single child, no label] - expected: FAIL - - [Single child, empty label] - expected: FAIL - - [Single child, label] - expected: FAIL - - [Single child, namespaced label] - expected: FAIL - - [Two children, no label] - expected: FAIL - - [Two children, empty label] - expected: FAIL - - [Two children, label] - expected: FAIL - - [Two children, namespaced label] - expected: FAIL - diff --git a/tests/wpt/metadata/html/semantics/forms/the-option-element/option-value.html.ini b/tests/wpt/metadata/html/semantics/forms/the-option-element/option-value.html.ini deleted file mode 100644 index 8c5af79b0a3..00000000000 --- a/tests/wpt/metadata/html/semantics/forms/the-option-element/option-value.html.ini +++ /dev/null @@ -1,38 +0,0 @@ -[option-value.html] - type: testharness - [No children, no value] - expected: FAIL - - [No children, empty value] - expected: FAIL - - [No children, value] - expected: FAIL - - [No children, namespaced value] - expected: FAIL - - [Single child, no value] - expected: FAIL - - [Single child, empty value] - expected: FAIL - - [Single child, value] - expected: FAIL - - [Single child, namespaced value] - expected: FAIL - - [Two children, no value] - expected: FAIL - - [Two children, empty value] - expected: FAIL - - [Two children, value] - expected: FAIL - - [Two children, namespaced value] - expected: FAIL - |