aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/htmltimeelement.rs27
-rw-r--r--components/script/dom/webidls/HTMLTimeElement.webidl2
-rw-r--r--tests/wpt/metadata/html/dom/interfaces.html.ini6
-rw-r--r--tests/wpt/metadata/html/dom/reflection-text.html.ini219
-rw-r--r--tests/wpt/metadata/html/semantics/text-level-semantics/the-time-element/001.html.ini14
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/text-level-semantics/the-time-element/001.html12
6 files changed, 33 insertions, 247 deletions
diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs
index e7d9e049baa..84794443e02 100644
--- a/components/script/dom/htmltimeelement.rs
+++ b/components/script/dom/htmltimeelement.rs
@@ -2,23 +2,27 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::HTMLTimeElementBinding;
+use dom::bindings::codegen::Bindings::HTMLTimeElementBinding::HTMLTimeElementMethods;
+use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::document::Document;
+use dom::element::Element;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTimeElement {
- htmlelement: HTMLElement
+ htmlelement: HTMLElement,
}
impl HTMLTimeElement {
fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTimeElement {
HTMLTimeElement {
- htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
+ htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
@@ -31,3 +35,22 @@ impl HTMLTimeElement {
HTMLTimeElementBinding::Wrap)
}
}
+
+impl HTMLTimeElementMethods for HTMLTimeElement {
+ // https://html.spec.whatwg.org/multipage/#dom-time-datetime
+ //make_getter!(DateTime, "datetime");
+ fn DateTime(&self) -> DOMString {
+ let element = self.upcast::<Element>();
+ if element.has_attribute(&local_name!("datetime")) {
+ return element.get_string_attribute(&local_name!("datetime"))
+ } else {
+ match element.GetInnerHTML() {
+ Ok(x) => x,
+ _ => DOMString::new(),
+ }
+ }
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-time-datetime
+ make_setter!(SetDateTime, "datetime");
+}
diff --git a/components/script/dom/webidls/HTMLTimeElement.webidl b/components/script/dom/webidls/HTMLTimeElement.webidl
index 21f9dcf090e..5f2ac73d4cb 100644
--- a/components/script/dom/webidls/HTMLTimeElement.webidl
+++ b/components/script/dom/webidls/HTMLTimeElement.webidl
@@ -4,5 +4,5 @@
// https://html.spec.whatwg.org/multipage/#htmltimeelement
interface HTMLTimeElement : HTMLElement {
- // attribute DOMString dateTime;
+ attribute DOMString dateTime;
};
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index e7aa48a31cd..b602f533384 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -1227,12 +1227,6 @@
[HTMLAnchorElement interface: document.createElement("a") must inherit property "charset" with the proper type (9)]
expected: FAIL
- [HTMLTimeElement interface: attribute dateTime]
- expected: FAIL
-
- [HTMLTimeElement interface: document.createElement("time") must inherit property "dateTime" with the proper type (0)]
- expected: FAIL
-
[HTMLBRElement interface: attribute clear]
expected: FAIL
diff --git a/tests/wpt/metadata/html/dom/reflection-text.html.ini b/tests/wpt/metadata/html/dom/reflection-text.html.ini
index df94215cfa9..2ba5073e928 100644
--- a/tests/wpt/metadata/html/dom/reflection-text.html.ini
+++ b/tests/wpt/metadata/html/dom/reflection-text.html.ini
@@ -8550,135 +8550,6 @@
[time.tabIndex: IDL set to -2147483648 followed by getAttribute()]
expected: FAIL
- [time.dateTime: typeof IDL attribute]
- expected: FAIL
-
- [time.dateTime: IDL get with DOM attribute unset]
- expected: FAIL
-
- [time.dateTime: setAttribute() to "" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() 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 IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to undefined followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to 7 followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to 1.5 followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to true followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to false followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to object "[object Object\]" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to NaN followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to Infinity followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to -Infinity followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to "\\0" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to null followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to object "test-toString" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: setAttribute() to object "test-valueOf" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to "" followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: 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
-
- [time.dateTime: IDL set to undefined followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to undefined followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to 7 followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to 7 followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to 1.5 followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to 1.5 followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to true followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to true followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to false followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to false followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to object "[object Object\]" followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to object "[object Object\]" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to NaN followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to NaN followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to Infinity followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to Infinity followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to -Infinity followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to -Infinity followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to "\\0" followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to null followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to null followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to object "test-toString" followed by getAttribute()]
- expected: FAIL
-
- [time.dateTime: IDL set to object "test-toString" followed by IDL get]
- expected: FAIL
-
- [time.dateTime: IDL set to object "test-valueOf" followed by IDL get]
- expected: FAIL
-
[time.itemScope: typeof IDL attribute]
expected: FAIL
@@ -28788,96 +28659,6 @@
[time.tabIndex: IDL set to -2147483648]
expected: FAIL
- [time.dateTime: setAttribute() to ""]
- expected: FAIL
-
- [time.dateTime: setAttribute() 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 "]
- expected: FAIL
-
- [time.dateTime: setAttribute() to undefined]
- expected: FAIL
-
- [time.dateTime: setAttribute() to 7]
- expected: FAIL
-
- [time.dateTime: setAttribute() to 1.5]
- expected: FAIL
-
- [time.dateTime: setAttribute() to true]
- expected: FAIL
-
- [time.dateTime: setAttribute() to false]
- expected: FAIL
-
- [time.dateTime: setAttribute() to object "[object Object\]"]
- expected: FAIL
-
- [time.dateTime: setAttribute() to NaN]
- expected: FAIL
-
- [time.dateTime: setAttribute() to Infinity]
- expected: FAIL
-
- [time.dateTime: setAttribute() to -Infinity]
- expected: FAIL
-
- [time.dateTime: setAttribute() to "\\0"]
- expected: FAIL
-
- [time.dateTime: setAttribute() to null]
- expected: FAIL
-
- [time.dateTime: setAttribute() to object "test-toString"]
- expected: FAIL
-
- [time.dateTime: setAttribute() to object "test-valueOf"]
- expected: FAIL
-
- [time.dateTime: IDL set to ""]
- expected: FAIL
-
- [time.dateTime: 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 "]
- expected: FAIL
-
- [time.dateTime: IDL set to undefined]
- expected: FAIL
-
- [time.dateTime: IDL set to 7]
- expected: FAIL
-
- [time.dateTime: IDL set to 1.5]
- expected: FAIL
-
- [time.dateTime: IDL set to true]
- expected: FAIL
-
- [time.dateTime: IDL set to false]
- expected: FAIL
-
- [time.dateTime: IDL set to object "[object Object\]"]
- expected: FAIL
-
- [time.dateTime: IDL set to NaN]
- expected: FAIL
-
- [time.dateTime: IDL set to Infinity]
- expected: FAIL
-
- [time.dateTime: IDL set to -Infinity]
- expected: FAIL
-
- [time.dateTime: IDL set to "\\0"]
- expected: FAIL
-
- [time.dateTime: IDL set to null]
- expected: FAIL
-
- [time.dateTime: IDL set to object "test-toString"]
- expected: FAIL
-
- [time.dateTime: IDL set to object "test-valueOf"]
- expected: FAIL
-
[code.dir: setAttribute() to ""]
expected: FAIL
diff --git a/tests/wpt/metadata/html/semantics/text-level-semantics/the-time-element/001.html.ini b/tests/wpt/metadata/html/semantics/text-level-semantics/the-time-element/001.html.ini
deleted file mode 100644
index e686eda0589..00000000000
--- a/tests/wpt/metadata/html/semantics/text-level-semantics/the-time-element/001.html.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[001.html]
- type: testharness
- [the datetime attribute should be reflected by the .dateTime property]
- expected: FAIL
-
- [the dateTime IDL property should default to an empty string]
- expected: FAIL
-
- [the datetime attribute should be reflected by the .dateTime property even if it is invalid]
- expected: FAIL
-
- [the datetime attribute should not reflect the textContent]
- expected: FAIL
-
diff --git a/tests/wpt/web-platform-tests/html/semantics/text-level-semantics/the-time-element/001.html b/tests/wpt/web-platform-tests/html/semantics/text-level-semantics/the-time-element/001.html
index e1cd0480ac4..e732e84e41f 100644
--- a/tests/wpt/web-platform-tests/html/semantics/text-level-semantics/the-time-element/001.html
+++ b/tests/wpt/web-platform-tests/html/semantics/text-level-semantics/the-time-element/001.html
@@ -47,21 +47,23 @@ test(function () {
//dateTime
test(function () {
assert_equals( makeTime('2000-02-01T03:04:05Z','2001-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' );
-}, 'the datetime attribute should be reflected by the .dateTime property');
+}, 'the datetime attribute should be reflected by the dateTime IDL property');
test(function () {
assert_equals( typeof makeTime().dateTime, 'string', 'typeof test' );
assert_equals( makeTime().dateTime, '', 'value test' );
}, 'the dateTime IDL property should default to an empty string');
test(function () {
assert_equals( makeTime(false,false,'2000-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' );
-}, 'the dateTime property should be read/write');
+}, 'the dateTime IDL property should be read/write');
test(function () {
assert_equals( makeTime('go fish').dateTime, 'go fish' );
}, 'the datetime attribute should be reflected by the .dateTime property even if it is invalid');
test(function () {
- assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '' );
-}, 'the datetime attribute should not reflect the textContent');
-
+ assert_equals( makeTime(false,'2000-02-01T03:04:05Z', '2000-02-01').dateTime, '2000-02-01' );
+}, 'the datetime content attribute should not reflect the textContent when datetime attribute is present.');
+test(function () {
+ assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' );
+}, 'the datetime content attribute should reflect the textContent when datetime attribute is absent.');
</script>
</body>