Skip to content

Commit

Permalink
Bug 1890506 [wpt PR 45624] - Remove getHTML() shouldn't branch on sha…
Browse files Browse the repository at this point in the history
…dow root's mode, a=testonly

Automatic update from web-platform-tests
Remove getHTML() shouldn't branch on shadow root's mode

As with clonable and delegatesFocus, serializable is an explicit API and therefore fine from an encapsulation point of view.

For whatwg/html#10260.
--

wpt-commits: dd2e51de9985a1c9d381607c2b314b6562545d37
wpt-pr: 45624
  • Loading branch information
annevk authored and moz-wptsync-bot committed Apr 15, 2024
1 parent 9cf3c80 commit 6e4ee7a
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions testing/web-platform/tests/shadow-dom/declarative/gethtml.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
}

let shadowRoot;
const isOpen = mode === 'open';
let initDict = {mode: mode, delegatesFocus: delegatesFocus, clonable};
let expectedSerializable = null;
switch (serializable) {
Expand All @@ -47,12 +46,8 @@
`shadowrootmode=${mode}${delegatesAttr}${serializableAttr}` +
`${clonableAttr}>`;
wrapper.setHTMLUnsafe(html);
if (isOpen) {
shadowRoot = wrapper.firstElementChild.shadowRoot;
} else {
// For closed shadow root, we rely on the behavior of attachShadow to return it to us
shadowRoot = wrapper.firstElementChild.attachShadow(initDict);
}
// Get hold of the declarative shadow root in a way that works when its mode is "closed"
shadowRoot = wrapper.firstElementChild.attachShadow(initDict);
} else {
// Imperative shadow dom
const element = document.createElement(elementType);
Expand All @@ -78,22 +73,14 @@
assert_equals(shadowRoot.clonable,clonable);
shadowRoot.appendChild(document.createElement('slot'));
const emptyElement = `<${elementType}>${lightDOMContent}</${elementType}>`;
if (isOpen) {
if (expectedSerializable) {
assert_equals(wrapper.getHTML({serializableShadowRoots: true}),
correctHtml);
assert_equals(wrapper.firstElementChild.getHTML({
serializableShadowRoots: true}),
`${correctShadowHtml}${lightDOMContent}`);
} else {
assert_equals(wrapper.getHTML({serializableShadowRoots: true}), emptyElement);
}
} else {
// Closed shadow roots should not be returned unless shadowRoots specifically contains the shadow root:
if (expectedSerializable) {
assert_equals(wrapper.getHTML({serializableShadowRoots: true}),
emptyElement);
assert_equals(wrapper.getHTML({serializableShadowRoots: true,
shadowRoots: []}), emptyElement);
correctHtml);
assert_equals(wrapper.firstElementChild.getHTML({
serializableShadowRoots: true}),
`${correctShadowHtml}${lightDOMContent}`);
} else {
assert_equals(wrapper.getHTML({serializableShadowRoots: true}), emptyElement);
}
// If we provide the shadow root, serialize it, regardless of serializableShadowRoots.
assert_equals(wrapper.getHTML({serializableShadowRoots: true, shadowRoots:
Expand Down

0 comments on commit 6e4ee7a

Please sign in to comment.