Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
#parent { color: rgb(0, 128, 0); font-size: 20px; }
@layer base {
#layered { margin-left: 7px; background-color: rgb(0, 0, 255); }
#layered-shorthand { margin: 3px; }
}
@layer top {
#layered { margin-left: var(--missing, revert-layer); background-color: var(--missing, revert); }
#layered-shorthand { margin: var(--missing, revert-layer); }
}
</style>
<div id="parent"></div>
<script>
// Each element substitutes a revert keyword into a longhand, written or through a shorthand. Each
// line prints what the reverted longhands computed to.
const cases = [
["inline", "font-size: var(--missing, revert); margin-left: var(--missing, revert-layer); background-color: var(--missing, revert-layer)"],
["background-color", "background-color: var(--missing, revert-layer)"],
["shorthand", "background: var(--missing, revert-layer)"],
["layered", null],
["layered-shorthand", null],
];
test(() => {
const parent = document.getElementById("parent");
internals.updateStyle();
for (const [id, inlineStyle] of cases) {
const element = document.createElement("div");
element.id = id;
if (inlineStyle)
element.setAttribute("style", inlineStyle);
parent.appendChild(element);
internals.updateStyle();
const style = getComputedStyle(element);
println(`${id}: color=${style.color} font-size=${style.fontSize} margin-left=${style.marginLeft} background-color=${style.backgroundColor}`);
}
});
</script>