mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-29 02:17:45 -10:00
Bug 1632383 [wpt PR 23195] - Add a test for declarative Shadow DOM after attachShadow(), a=testonly
Automatic update from web-platform-tests Add a test for declarative Shadow DOM after attachShadow() This is a new test to verify that declarative shadow DOM (properly) fails if attachShadow() has already been called on the host node. Bug: 1042130 Change-Id: Ibca94f9be5f6a1eb3c3bdd491f84e782e8cc6d9f -- wpt-commits: 84f93271efe15a4e37fed477a2ad364f8659a0f8 wpt-pr: 23195
This commit is contained in:
1 parent
b03f1d635a
commit
1264169010
1 file changed
+44
+44
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<title>Declarative Shadow DOM after attachShadow</title>
|
||||
<link rel='author' title='Mason Freed' href='mailto:[email protected]'>
|
||||
<link rel='help' href='https://github.com/whatwg/dom/issues/831'>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
let gotHost = false;
|
||||
function myObserver(mutationsList, observer) {
|
||||
for (let mutation of mutationsList) {
|
||||
for (let n of mutation.addedNodes) {
|
||||
if (n.id === 'host') {
|
||||
gotHost = true;
|
||||
const shadowRoot = n.attachShadow( {mode: 'closed'});
|
||||
assert_true(!!shadowRoot, 'Unable to attach shadow imperatively');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const observer = new MutationObserver(myObserver);
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
assert_false(gotHost, 'No mutations yet');
|
||||
</script>
|
||||
|
||||
<div id=host>
|
||||
<script></script> <!-- Make sure MutationObserver gets to run -->
|
||||
<template shadowroot=open>
|
||||
<slot></slot>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
test(t => {
|
||||
t.add_cleanup(function() { observer.disconnect(); });
|
||||
assert_true(gotHost);
|
||||
let host = document.querySelector('#host');
|
||||
let template = host.querySelector('template');
|
||||
assert_true(!!template, 'Declarative shadow attach should fail, so template should be left over');
|
||||
assert_true(!host.shadowRoot, 'Shadow root should be closed (from attachShadow call)');
|
||||
}, 'Declarative Shadow DOM: declarative shadow should fail if attachShadow() already called');
|
||||
</script>
|
||||
</body>
|
||||
Reference in new issue
Block a user