diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /testing/web-platform/tests/shadow-dom/declarative | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/shadow-dom/declarative')
4 files changed, 125 insertions, 32 deletions
diff --git a/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-basic.html b/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-basic.html index 8bc6bec5f5..4f174b8e5f 100644 --- a/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-basic.html +++ b/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-basic.html @@ -55,6 +55,49 @@ test(() => { }, 'Shadowrootmode reflection, setter'); test(() => { + const t = document.createElement('template'); + t.setAttribute('shadowrootdelegatesfocus',''); + assert_equals(t.shadowRootDelegatesFocus,true,'The shadowRootDelegatesFocus IDL should reflect the content attribute'); + t.setAttribute('shadowrootdelegatesfocus','foobar'); + assert_equals(t.shadowRootDelegatesFocus,true,'The value doesn\'t matter'); + t.removeAttribute('shadowrootdelegatesfocus'); + assert_equals(t.shadowRootDelegatesFocus,false,'No shadowRootDelegatesFocus attribute maps to false'); +}, 'Shadowrootdelegatesfocus reflection'); + +test(() => { + const t = document.createElement('template'); + assert_equals(t.getAttribute('shadowrootdelegatesfocus'), null); + t.shadowRootDelegatesFocus = true; + assert_equals(t.getAttribute('shadowrootdelegatesfocus'), ''); + assert_equals(t.shadowRootDelegatesFocus, true); + t.shadowRootDelegatesFocus = false; + assert_equals(t.getAttribute('shadowrootdelegatesfocus'), null); + assert_equals(t.shadowRootDelegatesFocus, false); +}, 'Shadowrootdelegatesfocus reflection, setter'); + + +test(() => { + const t = document.createElement('template'); + t.setAttribute('shadowrootclonable',''); + assert_equals(t.shadowRootClonable,true,'The shadowRootClonable IDL should reflect the content attribute'); + t.setAttribute('shadowrootclonable','foobar'); + assert_equals(t.shadowRootClonable,true,'The value doesn\'t matter'); + t.removeAttribute('shadowrootclonable'); + assert_equals(t.shadowRootClonable,false,'No shadowRootClonable attribute maps to false'); +}, 'Shadowrootclonable reflection'); + +test(() => { + const t = document.createElement('template'); + assert_equals(t.getAttribute('shadowrootclonable'), null); + t.shadowRootClonable = true; + assert_equals(t.getAttribute('shadowrootclonable'), ''); + assert_equals(t.shadowRootClonable, true); + t.shadowRootClonable = false; + assert_equals(t.getAttribute('shadowrootclonable'), null); + assert_equals(t.shadowRootClonable, false); +}, 'Shadowrootclonable reflection, setter'); + +test(() => { const div = document.createElement('div'); div.setHTMLUnsafe(` <div id="host"> diff --git a/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats-2.html b/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats-2.html new file mode 100644 index 0000000000..74b14b8d8f --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats-2.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<title>Duplicate declarative shadow trees</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> + +<div id=multiple1> + <template shadowrootmode=open>1</template> + <template shadowrootmode=open>2</template> + <template shadowrootmode=open>3</template> +</div> + +<div id=multiple2> + <template shadowrootmode=closed>1</template> + <template shadowrootmode=closed>2</template> + <template shadowrootmode=open>3</template> +</div> + +<script> +test((t) => { + t.add_cleanup(() => { + multiple1.remove(); + multiple2.remove(); + }); + let shadow = multiple1.shadowRoot; + assert_true(!!shadow,'Remaining shadow root should be open'); + assert_equals(shadow.textContent,"1"); + assert_equals(multiple1.childElementCount, 2); + assert_equals(multiple1.firstElementChild.content.textContent, "2"); + assert_equals(multiple1.lastElementChild.content.textContent, "3"); + shadow = multiple2.shadowRoot; + assert_false(!!shadow,'Remaining shadow root should be closed'); + assert_equals(multiple2.childElementCount, 2); + assert_equals(multiple2.firstElementChild.content.textContent, "2"); + assert_equals(multiple2.lastElementChild.content.textContent, "3"); +},'Repeated declarative shadow roots keep only the first'); +</script> diff --git a/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats.html b/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats.html index 69f5c0f077..9cee41f2f3 100644 --- a/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats.html +++ b/testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats.html @@ -22,13 +22,19 @@ <script> test((t) => { + t.add_cleanup(() => { + multiple1.remove(); + multiple2.remove(); + }); let shadow = multiple1.shadowRoot; assert_true(!!shadow,'Remaining shadow root should be open'); assert_equals(shadow.textContent,"Open"); + assert_equals(multiple1.childElementCount, 1); + assert_equals(multiple1.firstElementChild.shadowRootMode, "closed"); shadow = multiple2.shadowRoot; assert_false(!!shadow,'Remaining shadow root should be closed'); - multiple1.remove(); // Cleanup - multiple2.remove(); + assert_equals(multiple2.childElementCount, 1); + assert_equals(multiple2.firstElementChild.shadowRootMode, "open"); },'Repeated declarative shadow roots keep only the first'); </script> @@ -40,39 +46,48 @@ test((t) => { test((t) => { assert_throws_dom("NotSupportedError",() => { open1.attachShadow({mode: "closed"}); - },'Mismatched shadow root type should throw'); + },'Mismatched shadow root mode should throw'); const initialShadow = open1.shadowRoot; const shadow = open1.attachShadow({mode: "open"}); // Shouldn't throw assert_equals(shadow,initialShadow,'Same shadow should be returned'); assert_equals(shadow.textContent,'','Shadow should be empty'); -},'Calling attachShadow() on declarative shadow root must match type'); +},'Calling attachShadow() on declarative shadow root must match mode'); </script> <div id=open2> - <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable> + <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable serializable> Open, delegates focus (not the default), clonable (not the default) - named slot assignment (the default) + serializable (not the default), named slot assignment (the default) </template> </div> <script> test((t) => { + t.add_cleanup(() => open2.remove()); + assert_true(!!open2.shadowRoot); + // Changing the mode should throw. assert_throws_dom("NotSupportedError",() => { - open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true}); - },'Mismatched shadow root type should throw'); + open2.attachShadow({mode: "closed"}); + },'Mismatched shadow root mode should throw'); assert_throws_dom("NotSupportedError",() => { - open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "named", clonable: true}); - },'Mismatched shadow root delegatesFocus should throw'); - assert_throws_dom("NotSupportedError",() => { - open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "manual", clonable: true}); - },'Mismatched shadow root slotAssignment should throw'); - assert_throws_dom("NotSupportedError",() => { - open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: false}); - },'Mismatched shadow root clonable should throw'); + open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true, serializable: true}); + },'Mismatched shadow root mode should throw (explicit args)'); + // Changing other things should not throw, and should not change the shadow root's settings const initialShadow = open2.shadowRoot; - const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true}); // Shouldn't throw - assert_equals(shadow,initialShadow,'Same shadow should be returned'); - assert_equals(shadow.textContent,'','Shadow should be empty'); + assert_equals(initialShadow.delegatesFocus,true); + assert_equals(initialShadow.slotAssignment,"named"); + assert_true(initialShadow.clonable); + assert_true(initialShadow.serializable); + let newShadow = open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "manual", clonable: false, serializable: false}); + assert_equals(newShadow,initialShadow,'Same shadow should be returned'); + assert_equals(newShadow.textContent,'','Shadow should be empty'); + assert_equals(newShadow.delegatesFocus,true); + assert_equals(newShadow.slotAssignment,"named"); + assert_true(newShadow.clonable); + assert_true(newShadow.serializable); + assert_throws_dom("NotSupportedError",() => { + open2.attachShadow({mode: "open"}); + },'Invoking attachShadow() on a non-declarative shadow root should throw'); },'Calling attachShadow() on declarative shadow root must match all parameters'); </script> diff --git a/testing/web-platform/tests/shadow-dom/declarative/gethtml.tentative.html b/testing/web-platform/tests/shadow-dom/declarative/gethtml.tentative.html index c48230c170..eabd39131b 100644 --- a/testing/web-platform/tests/shadow-dom/declarative/gethtml.tentative.html +++ b/testing/web-platform/tests/shadow-dom/declarative/gethtml.tentative.html @@ -69,29 +69,28 @@ function testElementType(allowsShadowDom, elementType, runGetHTMLOnShadowRoot, d const emptyElement = `<${elementType}></${elementType}>`; if (isOpen) { if (expectedSerializable) { - assert_equals(wrapper.getHTML({includeShadowRoots: true}), correctHtml); + assert_equals(wrapper.getHTML({serializableShadowRoots: true}), correctHtml); } else { - assert_equals(wrapper.getHTML({includeShadowRoots: true}), emptyElement); + assert_equals(wrapper.getHTML({serializableShadowRoots: true}), emptyElement); } } else { // Closed shadow roots should not be returned unless shadowRoots specifically contains the shadow root: - assert_equals(wrapper.getHTML({includeShadowRoots: true}), emptyElement); - assert_equals(wrapper.getHTML({includeShadowRoots: true, shadowRoots: []}), emptyElement); + assert_equals(wrapper.getHTML({serializableShadowRoots: true}), emptyElement); + assert_equals(wrapper.getHTML({serializableShadowRoots: true, shadowRoots: []}), emptyElement); } - // If we provide the shadow root, serialize it, regardless of includeShadowRoots. - assert_equals(wrapper.getHTML({includeShadowRoots: true, shadowRoots: [shadowRoot]}),correctHtml); + // If we provide the shadow root, serialize it, regardless of serializableShadowRoots. + assert_equals(wrapper.getHTML({serializableShadowRoots: true, shadowRoots: [shadowRoot]}),correctHtml); + assert_equals(wrapper.getHTML({serializableShadowRoots: false, shadowRoots: [shadowRoot]}),correctHtml); assert_equals(wrapper.getHTML({shadowRoots: [shadowRoot]}),correctHtml); - // This should always throw - includeShadowRoots false, but we've provided roots. - assert_throws_dom("NotSupportedError",() => wrapper.getHTML({includeShadowRoots: false, shadowRoots: [shadowRoot]})); } else { // For non-shadow hosts, getHTML() should also match .innerHTML - assert_equals(wrapper.getHTML({includeShadowRoots: true}),wrapper.innerHTML); + assert_equals(wrapper.getHTML({serializableShadowRoots: true}),wrapper.innerHTML); } - // Either way, make sure getHTML({includeShadowRoots: false}) matches .innerHTML - assert_equals(wrapper.getHTML({includeShadowRoots: false}),wrapper.innerHTML,'getHTML() with includeShadowRoots false should return the same as .innerHTML'); - // ...and that the default for includeShadowRoots is false. - assert_equals(wrapper.getHTML(),wrapper.innerHTML,'The default for includeShadowRoots should be false'); + // Either way, make sure getHTML({serializableShadowRoots: false}) matches .innerHTML + assert_equals(wrapper.getHTML({serializableShadowRoots: false}),wrapper.innerHTML,'getHTML() with serializableShadowRoots false should return the same as .innerHTML'); + // ...and that the default for serializableShadowRoots is false. + assert_equals(wrapper.getHTML(),wrapper.innerHTML,'The default for serializableShadowRoots should be false'); }, `${runGetHTMLOnShadowRoot ? 'ShadowRoot' : 'Element'}.getHTML() on <${elementType}>${allowsShadowDom ? `, with ${declarativeShadowDom ? 'declarative' : 'imperative'} shadow, mode=${mode}, delegatesFocus=${delegatesFocus}, serializable=${serializable}, clonable=${clonable}.` : ''}`); } |