|
46 | 46 | test((t) => {
|
47 | 47 | assert_throws_dom("NotSupportedError",() => {
|
48 | 48 | open1.attachShadow({mode: "closed"});
|
49 |
| - },'Mismatched shadow root type should throw'); |
| 49 | + },'Mismatched shadow root mode should throw'); |
50 | 50 | const initialShadow = open1.shadowRoot;
|
51 | 51 | const shadow = open1.attachShadow({mode: "open"}); // Shouldn't throw
|
52 | 52 | assert_equals(shadow,initialShadow,'Same shadow should be returned');
|
53 | 53 | assert_equals(shadow.textContent,'','Shadow should be empty');
|
54 |
| -},'Calling attachShadow() on declarative shadow root must match type'); |
| 54 | +},'Calling attachShadow() on declarative shadow root must match mode'); |
55 | 55 | </script>
|
56 | 56 |
|
57 | 57 | <div id=open2>
|
58 |
| - <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable> |
| 58 | + <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable serializable> |
59 | 59 | Open, delegates focus (not the default), clonable (not the default)
|
60 |
| - named slot assignment (the default) |
| 60 | + serializable (not the default), named slot assignment (the default) |
61 | 61 | </template>
|
62 | 62 | </div>
|
63 | 63 |
|
64 | 64 | <script>
|
65 | 65 | test((t) => {
|
| 66 | + t.add_cleanup(() => open2.remove()); |
| 67 | + assert_true(!!open2.shadowRoot); |
| 68 | + // Changing the mode should throw. |
66 | 69 | assert_throws_dom("NotSupportedError",() => {
|
67 |
| - open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true}); |
| 70 | + open2.attachShadow({mode: "closed"}); |
68 | 71 | },'Mismatched shadow root mode should throw');
|
| 72 | + assert_throws_dom("NotSupportedError",() => { |
| 73 | + open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true, serializable: true}); |
| 74 | + },'Mismatched shadow root mode should throw (explicit args)'); |
69 | 75 |
|
| 76 | + // Changing other things should not throw, and should not change the shadow root's settings |
70 | 77 | const initialShadow = open2.shadowRoot;
|
71 |
| - const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true}); // Shouldn't throw |
72 |
| - assert_equals(shadow,initialShadow,'Same shadow should be returned'); |
73 |
| - assert_equals(shadow.textContent,'','Shadow should be empty'); |
74 |
| - |
| 78 | + assert_equals(initialShadow.delegatesFocus,true); |
| 79 | + assert_equals(initialShadow.slotAssignment,"named"); |
| 80 | + assert_true(initialShadow.clonable); |
| 81 | + assert_true(initialShadow.serializable); |
| 82 | + let newShadow = open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "manual", clonable: false, serializable: false}); |
| 83 | + assert_equals(newShadow,initialShadow,'Same shadow should be returned'); |
| 84 | + assert_equals(newShadow.textContent,'','Shadow should be empty'); |
| 85 | + assert_equals(newShadow.delegatesFocus,true); |
| 86 | + assert_equals(newShadow.slotAssignment,"named"); |
| 87 | + assert_true(newShadow.clonable); |
| 88 | + assert_true(newShadow.serializable); |
75 | 89 | assert_throws_dom("NotSupportedError",() => {
|
76 | 90 | open2.attachShadow({mode: "open"});
|
77 | 91 | },'Invoking attachShadow() on a non-declarative shadow root should throw');
|
78 |
| - |
79 | 92 | },'Calling attachShadow() on declarative shadow root must match all parameters');
|
80 | 93 | </script>
|
0 commit comments