Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<div id="host"></div>
<script>
test(() => {
const host = document.getElementById("host");
const shadowRoot = host.attachShadow({ mode: "open" });
const target = document.createElement("div");
target.className = "foo";
shadowRoot.appendChild(target);
const nonTarget = document.createElement("div");
nonTarget.className = "bar";
shadowRoot.appendChild(nonTarget);
println(`before target: ${getComputedStyle(target).color}`);
println(`before non-target: ${getComputedStyle(nonTarget).color}`);
const style = document.createElement("style");
style.textContent = ".foo { color: rgb(255, 0, 0); }";
shadowRoot.appendChild(style);
println(`after target: ${getComputedStyle(target).color}`);
println(`after non-target: ${getComputedStyle(nonTarget).color}`);
});
</script>