Bug 1269712 - <track kind=invalid> should behave like metadata, not subtitles; r=bz
This follows a spec change <https://github.com/whatwg/html/issues/293>, which AFAIK no other browser has implemented, so it has some regression potential. The web-platform tests changed are out-of-date and match the old spec, so I'm changing them here to match the new spec.
This commit is contained in:
@@ -69,8 +69,9 @@ static MOZ_CONSTEXPR nsAttrValue::EnumTable kKindTable[] = {
|
|||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// The default value for kKindTable is "subtitles"
|
// Invalid values are treated as "metadata" in ParseAttribute, but if no value
|
||||||
static MOZ_CONSTEXPR const char* kKindTableDefaultString = kKindTable[0].tag;
|
// at all is specified, it's treated as "subtitles" in GetKind
|
||||||
|
static MOZ_CONSTEXPR const nsAttrValue::EnumTable* kKindTableInvalidValueDefault = &kKindTable[4];
|
||||||
|
|
||||||
/** HTMLTrackElement */
|
/** HTMLTrackElement */
|
||||||
HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||||
@@ -96,7 +97,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
|||||||
void
|
void
|
||||||
HTMLTrackElement::GetKind(DOMString& aKind) const
|
HTMLTrackElement::GetKind(DOMString& aKind) const
|
||||||
{
|
{
|
||||||
GetEnumAttr(nsGkAtoms::kind, kKindTableDefaultString, aKind);
|
GetEnumAttr(nsGkAtoms::kind, kKindTable[0].tag, aKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -170,7 +171,8 @@ HTMLTrackElement::ParseAttribute(int32_t aNamespaceID,
|
|||||||
{
|
{
|
||||||
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::kind) {
|
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::kind) {
|
||||||
// Case-insensitive lookup, with the first element as the default.
|
// Case-insensitive lookup, with the first element as the default.
|
||||||
return aResult.ParseEnumValue(aValue, kKindTable, false, kKindTable);
|
return aResult.ParseEnumValue(aValue, kKindTable, false,
|
||||||
|
kKindTableInvalidValueDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise call the generic implementation.
|
// Otherwise call the generic implementation.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ reflectLimitedEnumerated({
|
|||||||
"metadata"],
|
"metadata"],
|
||||||
invalidValues: ["foo", "bar", "\u0000", "null", "", "subtitle", "caption",
|
invalidValues: ["foo", "bar", "\u0000", "null", "", "subtitle", "caption",
|
||||||
"description", "chapter", "meta"],
|
"description", "chapter", "meta"],
|
||||||
defaultValue: "subtitles"
|
defaultValue: { missing: "subtitles", invalid: "metadata" },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default attribute
|
// Default attribute
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ test(function(){
|
|||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.setAttribute('kind', 'invalid');
|
track.setAttribute('kind', 'invalid');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
assert_equals(track.getAttribute('kind'), 'invalid');
|
assert_equals(track.getAttribute('kind'), 'invalid');
|
||||||
}, document.title + ' invalid value in content attribute');
|
}, document.title + ' invalid value in content attribute');
|
||||||
|
|
||||||
@@ -27,14 +27,14 @@ test(function(){
|
|||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.setAttribute('kind', 'CAPT\u0130ONS');
|
track.setAttribute('kind', 'CAPT\u0130ONS');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
|
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
|
||||||
}, document.title + ' content attribute with uppercase turkish I (with dot)');
|
}, document.title + ' content attribute with uppercase turkish I (with dot)');
|
||||||
|
|
||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.setAttribute('kind', 'capt\u0131ons');
|
track.setAttribute('kind', 'capt\u0131ons');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
|
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
|
||||||
}, document.title + ' content attribute with lowercase turkish i (dotless)');
|
}, document.title + ' content attribute with lowercase turkish i (dotless)');
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ test(function(){
|
|||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.setAttribute('kind', 'captions\u0000');
|
track.setAttribute('kind', 'captions\u0000');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
assert_equals(track.getAttribute('kind'), 'captions\u0000');
|
assert_equals(track.getAttribute('kind'), 'captions\u0000');
|
||||||
}, document.title + ' content attribute "captions\\u0000"');
|
}, document.title + ' content attribute "captions\\u0000"');
|
||||||
|
|
||||||
@@ -126,21 +126,21 @@ test(function(){
|
|||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.kind = 'CAPT\u0130ONS';
|
track.kind = 'CAPT\u0130ONS';
|
||||||
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
|
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
}, document.title + ' setting IDL attribute with uppercase turkish I (with dot)');
|
}, document.title + ' setting IDL attribute with uppercase turkish I (with dot)');
|
||||||
|
|
||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.kind = 'capt\u0131ons';
|
track.kind = 'capt\u0131ons';
|
||||||
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
|
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
}, document.title + ' setting IDL attribute with lowercase turkish I (dotless)');
|
}, document.title + ' setting IDL attribute with lowercase turkish I (dotless)');
|
||||||
|
|
||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.kind = 'captions\u0000';
|
track.kind = 'captions\u0000';
|
||||||
assert_equals(track.getAttribute('kind'), 'captions\u0000');
|
assert_equals(track.getAttribute('kind'), 'captions\u0000');
|
||||||
assert_equals(track.kind, 'subtitles');
|
assert_equals(track.kind, 'metadata');
|
||||||
}, document.title + ' setting IDL attribute with \\u0000');
|
}, document.title + ' setting IDL attribute with \\u0000');
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ test(function(){
|
|||||||
test(function(){
|
test(function(){
|
||||||
var track = document.createElement('track');
|
var track = document.createElement('track');
|
||||||
track.kind = 'captions\u0000';
|
track.kind = 'captions\u0000';
|
||||||
assert_equals(track.track.kind, 'subtitles');
|
assert_equals(track.track.kind, 'metadata');
|
||||||
}, document.title+', \\u0000');
|
}, document.title+', \\u0000');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user