diff options
Diffstat (limited to 'testing/web-platform/tests/custom-elements')
4 files changed, 120 insertions, 2 deletions
diff --git a/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLMediaElement.html b/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLMediaElement.html index 58e002c52c..dd830b7767 100644 --- a/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLMediaElement.html +++ b/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLMediaElement.html @@ -62,7 +62,7 @@ testReflectBooleanAttributeWithDependentAttributes( ); testReflectAttribute( - 'src', 'src', '/media/video.ogv', + 'src', 'src', '/media/video.webm', '/media/movie_5.mp4', 'src on HTMLMediaElement in video', 'video', HTMLVideoElement ); diff --git a/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLSourceElement.html b/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLSourceElement.html index f7d567ebcb..8168fd1c2e 100644 --- a/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLSourceElement.html +++ b/testing/web-platform/tests/custom-elements/reactions/customized-builtins/HTMLSourceElement.html @@ -22,7 +22,7 @@ function getParentElement(id) { } testReflectAttributeWithParentNode( - 'src', 'src', '/media/video.ogv', + 'src', 'src', '/media/video.webm', '/media/white.mp4', 'src on HTMLSourceElement', 'source', () => getParentElement('video'), HTMLSourceElement ); diff --git a/testing/web-platform/tests/custom-elements/state/state-css-selector-nth-of.html b/testing/web-platform/tests/custom-elements/state/state-css-selector-nth-of.html new file mode 100644 index 0000000000..c7b7183ccb --- /dev/null +++ b/testing/web-platform/tests/custom-elements/state/state-css-selector-nth-of.html @@ -0,0 +1,92 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="author" title="Keith Cirkel" href="mailto:wpt@keithcirkel.co.uk" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/custom-elements.html#custom-state-pseudo-class" /> + <title>:state() css selector applies to nth-of selectors</title> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <custom-state id="myCE">First Element</custom-state> + <p id="mySibling">First Sibling</p> + <custom-state id="myCE2">Second Element</custom-state> + <p id="mySibling2">Second Sibling</p> + <style> + :nth-child(1), :nth-child(2) { + color: #f00; + } + :nth-child(2 of :state(--green)) { + color: #0f0; + } + :nth-child(2 of :state(--green)) + p { + color: #00f; + } + </style> + <script> + customElements.define('custom-state', class extends HTMLElement { + connectedCallback() { + this.elementInternals = this.attachInternals(); + } + }); + + test(function(t) { + t.add_cleanup(() => { myCE.elementInternals.states.delete('--green') }); + t.add_cleanup(() => { myCE2.elementInternals.states.delete('--green') }); + assert_false(myCE.elementInternals.states.has('--green')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(myCE2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + myCE.elementInternals.states.add('--green'); + assert_true(myCE.elementInternals.states.has('--green')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(myCE2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + myCE2.elementInternals.states.add('--green'); + assert_true(myCE2.elementInternals.states.has('--green')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(myCE2).getPropertyValue('color'), 'rgb(0, 255, 0)'); + assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling2).getPropertyValue('color'), 'rgb(0, 0, 255)'); + }, "state selector has influence on nth-of when state is applied"); + + test(function(t) { + t.add_cleanup(() => { myCE.elementInternals.states.delete('--foo') }); + t.add_cleanup(() => { myCE2.elementInternals.states.delete('--foo') }); + myCE.elementInternals.states.add('--foo'); + myCE2.elementInternals.states.add('--foo'); + assert_false(myCE.elementInternals.states.has('--green')); + assert_true(myCE.elementInternals.states.has('--foo')); + assert_false(myCE2.elementInternals.states.has('--green')); + assert_true(myCE2.elementInternals.states.has('--foo')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(myCE2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + }, "state selector only applies on given ident"); + + test(function(t) { + myCE.elementInternals.states.add('--green'); + myCE.elementInternals.states.add('--foo'); + myCE2.elementInternals.states.add('--green'); + myCE2.elementInternals.states.add('--foo'); + assert_true(myCE.elementInternals.states.has('--green')); + assert_true(myCE.elementInternals.states.has('--foo')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(myCE2).getPropertyValue('color'), 'rgb(0, 255, 0)'); + assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling2).getPropertyValue('color'), 'rgb(0, 0, 255)'); + myCE.elementInternals.states.clear(); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(myCE2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_equals(getComputedStyle(mySibling2).getPropertyValue('color'), 'rgb(255, 0, 0)'); + }, "style is invalided on clear()"); + + </script> + </body> +</html> diff --git a/testing/web-platform/tests/custom-elements/state/state-css-selector.html b/testing/web-platform/tests/custom-elements/state/state-css-selector.html index d29c927223..8ead8d7809 100644 --- a/testing/web-platform/tests/custom-elements/state/state-css-selector.html +++ b/testing/web-platform/tests/custom-elements/state/state-css-selector.html @@ -99,6 +99,32 @@ assert_equals(getComputedStyle(mySibling).getPropertyValue('color'), 'rgb(255, 0, 0)'); }, "state selector only applies to has() on given ident"); + test(function(t) { + myCE.elementInternals.states.add('--green'); + myCE.elementInternals.states.add('--green'); + myCE.elementInternals.states.add('--green'); + t.add_cleanup(() => { myCE.elementInternals.states.delete('--green') }); + assert_true(myCE.elementInternals.states.has('--green')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(0, 255, 0)'); + assert_true(myCE.elementInternals.states.delete('--green')); + assert_false(myCE.elementInternals.states.has('--green')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + assert_false(myCE.elementInternals.states.delete('--green')); + }, "states added multiple times counts as one"); + + test(function(t) { + myCE.elementInternals.states.add('--green'); + myCE.elementInternals.states.add('--foo'); + t.add_cleanup(() => { myCE.elementInternals.states.clear() }); + assert_true(myCE.elementInternals.states.has('--green')); + assert_true(myCE.elementInternals.states.has('--foo')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(0, 255, 0)'); + myCE.elementInternals.states.clear(); + assert_false(myCE.elementInternals.states.has('--green')); + assert_false(myCE.elementInternals.states.has('--foo')); + assert_equals(getComputedStyle(myCE).getPropertyValue('color'), 'rgb(255, 0, 0)'); + }, "style is invalided on clear()"); + </script> </body> </html> |