Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/post-connection-steps-shadow-tree.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8">
<title>Post-connection steps in a shadow tree</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
test(t => {
const host = document.createElement("div");
const shadowRoot = host.attachShadow({ mode: "closed" });
const script = document.createElement("script");
window.shadowTreeScriptExecutions = 0;
t.add_cleanup(() => {
delete window.shadowTreeScriptExecutions;
host.remove();
});
script.text = "window.shadowTreeScriptExecutions++";
shadowRoot.append(script);
assert_equals(window.shadowTreeScriptExecutions, 0, "script does not run while disconnected");
document.body.append(host);
assert_equals(window.shadowTreeScriptExecutions, 1, "script runs when its shadow-including tree becomes connected");
}, "Script post-connection steps run in a newly-connected shadow tree");
</script>