Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<style>
body { margin: 0; }
#svg { display: block; }
#after { width: 80px; height: 20px; }
</style>
<svg id="svg" width="100" height="80" viewBox="0 0 100 80">
<text id="t" x="10" y="30">hi</text>
</svg>
<div id="after"></div>
<script>
// A mutation inside the <svg> registers it as a partial relayout root, leaving its
// ancestors clean. A size change on the <svg> itself in the same update must still
// escalate to a full layout so the surrounding content (#after) reflows.
function rectToString(rect) {
return `${rect.left},${rect.top},${rect.width},${rect.height}`;
}
promiseTest(async () => {
document.body.offsetHeight;
document.getElementById("t").firstChild.data = "hello longer text";
document.getElementById("svg").style.width = "300px";
document.getElementById("svg").style.height = "200px";
document.body.offsetHeight;
const svg = document.getElementById("svg").getBoundingClientRect();
const after = document.getElementById("after").getBoundingClientRect();
println(`svg=${rectToString(svg)}`);
println(`after=${rectToString(after)}`);
println(svg.width === 300 && svg.height === 200 && after.top === svg.height ? "PASS" : "FAIL");
});
</script>