Skip to content

Commit

Permalink
Check for matching serializable in attachShadow
Browse files Browse the repository at this point in the history
This parameter was added ([1]) after the initial check code was written
([3]). Note that [2] also added `clonable` but there's an issue [4]
about checking that in a similar way.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/5239221
[2] https://chromium-review.googlesource.com/c/chromium/src/+/5239277
[3] https://chromium-review.googlesource.com/c/chromium/src/+/5191750
[4] whatwg/html#10107

Bug: 1517959
Change-Id: I689c6a6f84fb7ce298cf187076ae228fef6cc348
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Jan 30, 2024
1 parent 49a46a3 commit f83978a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions shadow-dom/declarative/declarative-shadow-dom-repeats.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,30 @@

<div id=open2>
<template shadowrootmode=open shadowrootdelegatesfocus>
Open, delegates focus (not the default), named slot assignment (the default)
Open, delegates focus (not the default),
named slot assignment (the default), clonable (the default for declarative)
</template>
</div>

<script>
test((t) => {
assert_throws_dom("NotSupportedError",() => {
open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named"});
open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true});
},'Mismatched shadow root type should throw');
assert_throws_dom("NotSupportedError",() => {
open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "named"});
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"});
open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "manual", clonable: true});
},'Mismatched shadow root slotAssignment should throw');
// See https://github.com/whatwg/html/issues/10107: the behavior of the
// clonable flag is still being discussed.
// assert_throws_dom("NotSupportedError",() => {
// open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: false});
// },'Mismatched shadow root clonable should throw');

const initialShadow = open2.shadowRoot;
const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named"}); // Shouldn't throw
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');
},'Calling attachShadow() on declarative shadow root must match all parameters');
Expand Down

0 comments on commit f83978a

Please sign in to comment.