mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Add DateTime string attribute to Time
Also handle datetime content attribute when attribute is absent. Rephrase terms used in the test: dateTime IDL property, datetime attribute and datetime content attribute. Remove failure expectations for time element.
This commit is contained in:
parent
99c4821485
commit
25f0317a82
6 changed files with 33 additions and 247 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#htmltimeelement
|
||||
interface HTMLTimeElement : HTMLElement {
|
||||
// attribute DOMString dateTime;
|
||||
attribute DOMString dateTime;
|
||||
};
|
||||
|
|
|
@ -1533,12 +1533,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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue