Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
#declares-color { color: rgb(255, 0, 0); }
#em-margin { margin-left: 2em; }
#bordered { border: 2px solid; }
</style>
<div id="host">
<div><div><div id="plain">plain</div></div></div>
<div id="declares-color">declares color</div>
<div id="em-margin">em margin</div>
<div id="bordered">bordered</div>
</div>
<script>
test(() => {
const host = document.getElementById("host");
const plain = document.getElementById("plain");
const declaresColor = document.getElementById("declares-color");
const emMargin = document.getElementById("em-margin");
getComputedStyle(plain).color;
internals.updateStyle();
// An inherited color change flows to fully inheriting descendants and leaves an element
// that declares its own color alone. A default border color is currentcolor, so the
// bordered element's border must follow the color it inherits.
host.style.color = "rgb(0, 128, 0)";
internals.updateStyle();
println(`plain color: ${getComputedStyle(plain).color}`);
println(`declared color: ${getComputedStyle(declaresColor).color}`);
println(`border color: ${getComputedStyle(document.getElementById("bordered")).borderTopColor}`);
// An inherited font-size change must still recompute the element whose margin is declared
// in em, so its declared value is re-resolved against the new font size.
host.style.fontSize = "20px";
internals.updateStyle();
println(`em margin after font-size change: ${getComputedStyle(emMargin).marginLeft}`);
println(`plain font-size: ${getComputedStyle(plain).fontSize}`);
});
</script>