Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
internals.updateStyle();
const parent = document.createElement("div");
parent.style.fontSize = "20px";
const target = document.createElement("div");
target.style.cssText = `
font-size: calc(50% + 5px);
font-style: oblique calc(10deg + 5deg);
font-weight: calc(300 + 400);
font-stretch: calc(50% + 25%);
line-height: calc(1em + 5px);
letter-spacing: calc(0.1em + 1px);
word-spacing: calc(0.2em + 2px);
math-depth: add(calc(1 + 2));
`;
parent.appendChild(target);
const contextTarget = document.createElement("div");
contextTarget.style.cssText = `
font-size: calc(1em + 200%);
font-weight: calc(sign(1rem - 1px) * 10);
font-stretch: calc(sign(1rem - 1px) * 100%);
`;
parent.appendChild(contextTarget);
const anchorTarget = document.createElement("div");
anchorTarget.style.cssText = `
position: absolute;
left: calc(anchor(--missing left, 5px) + 1px);
top: calc(anchor(--missing top, 7px) + 2px);
`;
parent.appendChild(anchorTarget);
document.body.appendChild(parent);
internals.updateStyle();
const computedStyle = getComputedStyle(target);
for (const property of [
"font-size",
"font-style",
"font-weight",
"font-stretch",
"line-height",
"letter-spacing",
"word-spacing",
"math-depth",
]) {
println(`${property}: ${computedStyle.getPropertyValue(property)}`);
}
const contextStyle = getComputedStyle(contextTarget);
println(`context font-size: ${contextStyle.fontSize}`);
println(`context font-weight: ${contextStyle.fontWeight}`);
println(`context font-stretch: ${contextStyle.fontStretch}`);
const anchorStyle = getComputedStyle(anchorTarget);
println(`deferred anchor left: ${anchorStyle.left}`);
println(`deferred anchor top: ${anchorStyle.top}`);
target.style.fontSize = "16px";
internals.updateStyle();
println(`partial font-size: ${getComputedStyle(target).fontSize}`);
});
</script>