forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement updated TextTrackCue constructor proposal
https://bugs.webkit.org/show_bug.cgi?id=262053 rdar://116002871 Reviewed by Eric Carlson. Implements spec changes suggested at: whatwg/html#9771 Specifically: * supports `b` and `i` elements, to match WebVTT * drops support for allowing `img` in the cue fragment * implements more robust error checking to prevent malformed ::cue and :cuebackground hierarchies * As such, ::tagPseudoObjects() can now throw * Switch from InvalidStateError to InvalidNodeTypeError for when required attributes are missing * implements cuebackground and cue global attributes * LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/HTMLElement-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/HTMLElement.html: * LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cue-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cue.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cuebackground-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cuebackground.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/historical-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/historical.html: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/constructor-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/constructor.html: * LayoutTests/inspector/model/remote-object/dom-expected.txt: * LayoutTests/media/track/texttrackcue/texttrackcue-constructor-expected.txt: * LayoutTests/media/track/texttrackcue/texttrackcue-constructor.html: * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLElement.idl: * Source/WebCore/html/track/TextTrackCue.cpp: (WebCore::isLegalNode): (WebCore::tagPseudoObjects): (WebCore::removePseudoAttributes): (WebCore::TextTrackCue::create): (WebCore::TextTrackCue::setPauseOnExit): (WebCore::cueAttributName): Deleted. (WebCore::cueBackgroundAttributName): Deleted. Canonical link: https://commits.webkit.org/268644@main
- Loading branch information
1 parent
b5117f4
commit ed93c31
Showing
16 changed files
with
1,069 additions
and
60 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...tTests/imported/w3c/web-platform-tests/custom-elements/reactions/HTMLElement-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cue-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
PASS "cue" attribute in HTML defaults to false | ||
PASS Boolean attributes should be case-insensitive | ||
PASS Setting "cue" attribute in HTML should set the property to true | ||
PASS Getting a present "cue" attribute should return the attribute value | ||
PASS Setting "cue" attribute using setAttribute should set the property to true | ||
PASS Setting the 'cue' to true should set its value to empty string | ||
PASS Toggling "cue" attribute should result in the correct value | ||
PASS Cloning an element should preserve the boolean attribute | ||
PASS Boolean attribute should work correctly on dynamically created elements | ||
PASS Removing "cue" attribute using removeAttribute should set the property to false | ||
PASS Setting "cue" property via JavaScript should reflect the correct boolean value | ||
PASS Setting "cue" property via JavaScript should reflect in the content attribute | ||
PASS Setting "cue" property in JavaScript with truthy value (boolean true) should set the property to true | ||
PASS Setting "cue" property in JavaScript with truthy value (number 1) should set the property to true | ||
PASS Setting "cue" property in JavaScript with truthy value (string true) should set the property to true | ||
PASS Setting "cue" property in JavaScript with truthy value (object [object Object]) should set the property to true | ||
PASS Setting "cue" property in JavaScript with truthy value (object ) should set the property to true | ||
PASS Setting "cue" property in JavaScript with truthy value (string any-non-empty-string) should set the property to true | ||
PASS Setting "cue" property in JavaScript with falsy value (false) should set the property to false | ||
PASS Setting "cue" property in JavaScript with falsy value (0) should set the property to false | ||
PASS Setting "cue" property in JavaScript with falsy value () should set the property to false | ||
PASS Setting "cue" property in JavaScript with falsy value (null) should set the property to false | ||
PASS Setting "cue" property in JavaScript with falsy value (undefined) should set the property to false | ||
|
112 changes: 112 additions & 0 deletions
112
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cue.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test for cue attribute</title> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/9771" /> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<span id="element1"></span> | ||
<span id="element2" cue></span> | ||
<span id="element3" cue="custom value"></span> | ||
</body> | ||
<script> | ||
const element1 = document.getElementById("element1"); | ||
const element2 = document.getElementById("element2"); | ||
const element3 = document.getElementById("element3"); | ||
test(() => { | ||
assert_false(element1.cue); | ||
}, '"cue" attribute in HTML defaults to false'); | ||
|
||
test(() => { | ||
element1.setAttribute("CUE", ""); | ||
assert_true(element1.cue); | ||
element1.removeAttribute("CUE"); | ||
assert_false(element1.cue); | ||
}, "Boolean attributes should be case-insensitive"); | ||
|
||
test(() => { | ||
assert_true(element2.cue); | ||
}, 'Setting "cue" attribute in HTML should set the property to true'); | ||
|
||
test(() => { | ||
assert_true(element3.cue); | ||
assert_equals(element3.getAttribute("cue"), "custom value"); | ||
element3.setAttribute("cue", "new value") | ||
assert_true(element3.cue); | ||
assert_equals(element3.getAttribute("cue"), "new value"); | ||
element3.cue = false; | ||
assert_equals(element3.getAttribute("cue"), null); | ||
}, 'Getting a present "cue" attribute should return the attribute value'); | ||
|
||
test(() => { | ||
element1.setAttribute("cue", ""); | ||
assert_true(element1.cue); | ||
}, 'Setting "cue" attribute using setAttribute should set the property to true'); | ||
|
||
test(() => { | ||
element1.cuebackground = true; | ||
assert_equals(element1.getAttribute("cue"), ""); | ||
}, "Setting the 'cue' to true should set its value to empty string"); | ||
|
||
test(() => { | ||
element1.cue = true; | ||
assert_true(element1.cue); | ||
element1.cue = false; | ||
assert_false(element1.cue); | ||
element1.cue = true; | ||
assert_true(element1.cue); | ||
}, 'Toggling "cue" attribute should result in the correct value'); | ||
|
||
test(() => { | ||
element1.cue = true; | ||
const clone = element1.cloneNode(true); | ||
assert_true(clone.cue); | ||
}, "Cloning an element should preserve the boolean attribute"); | ||
|
||
test(() => { | ||
const dynamicElement = document.createElement("example-element"); | ||
assert_false(dynamicElement.cue); | ||
dynamicElement.cue = true; | ||
assert_true(dynamicElement.cue); | ||
}, "Boolean attribute should work correctly on dynamically created elements"); | ||
|
||
test(() => { | ||
element1.setAttribute("cue", ""); | ||
assert_true(element1.cue); | ||
element1.removeAttribute("cue"); | ||
assert_false(element1.cue); | ||
}, 'Removing "cue" attribute using removeAttribute should set the property to false'); | ||
|
||
test(() => { | ||
element1.cue = true; | ||
assert_true(element1.cue); | ||
element1.cue = false; | ||
assert_false(element1.cue); | ||
}, 'Setting "cue" property via JavaScript should reflect the correct boolean value'); | ||
|
||
test(() => { | ||
element1.cue = false; | ||
assert_false(element1.hasAttribute("cue")); | ||
element1.cue = true; | ||
assert_true(element1.hasAttribute("cue")); | ||
}, 'Setting "cue" property via JavaScript should reflect in the content attribute'); | ||
|
||
const truthyValues = [true, 1, "true", {}, [], "any-non-empty-string"]; | ||
truthyValues.forEach((value) => { | ||
test(() => { | ||
element1.cue = value; | ||
assert_true(element1.cue); | ||
}, `Setting "cue" property in JavaScript with truthy value (${typeof value} ${value}) should set the property to true`); | ||
}); | ||
|
||
const falsyValues = [false, 0, "", null, undefined]; | ||
falsyValues.forEach((value, index) => { | ||
test(() => { | ||
element1.cue = value; | ||
assert_false(element1.cue); | ||
}, `Setting "cue" property in JavaScript with falsy value (${value}) should set the property to false`); | ||
}); | ||
</script> | ||
</html> |
25 changes: 25 additions & 0 deletions
25
...ted/w3c/web-platform-tests/html/dom/elements/global-attributes/cuebackground-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
PASS "cuebackground" attribute in HTML defaults to false | ||
PASS Boolean attributes should be case-insensitive | ||
PASS Setting "cuebackground" attribute in HTML should set the property to true | ||
PASS Getting a present "cuebackground" attribute should return the attribute value | ||
PASS Setting "cuebackground" attribute using setAttribute should set the property to true | ||
PASS Setting the 'cuebackground' to true should set its value to empty string | ||
PASS Toggling "cuebackground" attribute should result in the correct value | ||
PASS Cloning an element should preserve the boolean attribute | ||
PASS Boolean attribute should work correctly on dynamically created elements | ||
PASS Removing "cuebackground" attribute using removeAttribute should set the property to false | ||
PASS Setting "cuebackground" property via JavaScript should reflect the correct boolean value | ||
PASS Setting "cue" property via JavaScript should reflect in the content attribute | ||
PASS Setting "cuebackground" property in JavaScript with truthy value (boolean true) should set the property to true | ||
PASS Setting "cuebackground" property in JavaScript with truthy value (number 1) should set the property to true | ||
PASS Setting "cuebackground" property in JavaScript with truthy value (string true) should set the property to true | ||
PASS Setting "cuebackground" property in JavaScript with truthy value (object [object Object]) should set the property to true | ||
PASS Setting "cuebackground" property in JavaScript with truthy value (object ) should set the property to true | ||
PASS Setting "cuebackground" property in JavaScript with truthy value (string any-non-empty-string) should set the property to true | ||
PASS Setting "cuebackground" property in JavaScript with falsy value (false) should set the property to false | ||
PASS Setting "cuebackground" property in JavaScript with falsy value (0) should set the property to false | ||
PASS Setting "cuebackground" property in JavaScript with falsy value () should set the property to false | ||
PASS Setting "cuebackground" property in JavaScript with falsy value (null) should set the property to false | ||
PASS Setting "cuebackground" property in JavaScript with falsy value (undefined) should set the property to false | ||
|
110 changes: 110 additions & 0 deletions
110
...ts/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/cuebackground.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test for cuebackground attribute</title> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/9771" /> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<span id="element1"></span> | ||
<span id="element2" cuebackground></span> | ||
<span id="element3" cuebackground="custom value"></span> | ||
</body> | ||
<script> | ||
const element1 = document.getElementById("element1"); | ||
const element2 = document.getElementById("element2"); | ||
const element3 = document.getElementById("element3"); | ||
test(() => { | ||
assert_false(element1.cuebackground); | ||
}, '"cuebackground" attribute in HTML defaults to false'); | ||
|
||
test(() => { | ||
element1.setAttribute("CUEBACKGROUND", ""); | ||
assert_true(element1.cuebackground); | ||
}, "Boolean attributes should be case-insensitive"); | ||
|
||
test(() => { | ||
assert_true(element2.cuebackground); | ||
}, 'Setting "cuebackground" attribute in HTML should set the property to true'); | ||
|
||
test(() => { | ||
assert_true(element3.cuebackground); | ||
assert_equals(element3.getAttribute("cuebackground"), "custom value"); | ||
element3.setAttribute("cuebackground", "new value") | ||
assert_true(element3.cuebackground); | ||
assert_equals(element3.getAttribute("cuebackground"), "new value"); | ||
element3.cuebackground = false; | ||
assert_equals(element3.getAttribute("cuebackground"), null); | ||
}, 'Getting a present "cuebackground" attribute should return the attribute value'); | ||
|
||
test(() => { | ||
element1.setAttribute("cuebackground", ""); | ||
assert_true(element1.cuebackground); | ||
}, 'Setting "cuebackground" attribute using setAttribute should set the property to true'); | ||
|
||
test(() => { | ||
element1.cuebackground = true; | ||
assert_equals(element1.getAttribute("cuebackground"), ""); | ||
}, "Setting the 'cuebackground' to true should set its value to empty string"); | ||
|
||
test(() => { | ||
element1.cuebackground = true; | ||
assert_true(element1.cuebackground); | ||
element1.cuebackground = false; | ||
assert_false(element1.cuebackground); | ||
element1.cuebackground = true; | ||
assert_true(element1.cuebackground); | ||
}, 'Toggling "cuebackground" attribute should result in the correct value'); | ||
|
||
test(() => { | ||
element1.cuebackground = true; | ||
const clone = element1.cloneNode(true); | ||
assert_true(clone.cuebackground); | ||
}, "Cloning an element should preserve the boolean attribute"); | ||
|
||
test(() => { | ||
const dynamicElement = document.createElement("example-element"); | ||
assert_false(dynamicElement.cuebackground); | ||
dynamicElement.cuebackground = true; | ||
assert_true(dynamicElement.cuebackground); | ||
}, "Boolean attribute should work correctly on dynamically created elements"); | ||
|
||
test(() => { | ||
element1.setAttribute("cuebackground", ""); | ||
assert_true(element1.cuebackground); | ||
element1.removeAttribute("cuebackground"); | ||
assert_false(element1.cuebackground); | ||
}, 'Removing "cuebackground" attribute using removeAttribute should set the property to false'); | ||
|
||
test(() => { | ||
element1.cuebackground = true; | ||
assert_true(element1.cuebackground); | ||
element1.cuebackground = false; | ||
assert_false(element1.cuebackground); | ||
}, 'Setting "cuebackground" property via JavaScript should reflect the correct boolean value'); | ||
|
||
test(() => { | ||
element1.cue = false; | ||
assert_false(element1.hasAttribute("cue")); | ||
element1.cue = true; | ||
assert_true(element1.hasAttribute("cue")); | ||
}, 'Setting "cue" property via JavaScript should reflect in the content attribute'); | ||
|
||
const truthyValues = [true, 1, "true", {}, [], "any-non-empty-string"]; | ||
truthyValues.forEach((value) => { | ||
test(() => { | ||
element1.cuebackground = value; | ||
assert_true(element1.cuebackground); | ||
}, `Setting "cuebackground" property in JavaScript with truthy value (${typeof value} ${value}) should set the property to true`); | ||
}); | ||
|
||
const falsyValues = [false, 0, "", null, undefined]; | ||
falsyValues.forEach((value, index) => { | ||
test(() => { | ||
element1.cuebackground = value; | ||
assert_false(element1.cuebackground); | ||
}, `Setting "cuebackground" property in JavaScript with falsy value (${value}) should set the property to false`); | ||
}); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.