Truly independent web browser
<!doctype html>
<script src="../include.js"></script>
<svg id="svg" width="200" height="100" viewBox="0 0 400 100" preserveAspectRatio="none">
<svg id="nested-svg" width="100" height="100"></svg>
</svg>
<script>
test(() => {
const svg = document.getElementById("svg");
const nestedSVG = document.getElementById("nested-svg");
const widthWithViewBox = nestedSVG.getBoundingClientRect().width;
if (widthWithViewBox !== 50) throw new Error(`width with viewBox: got ${widthWithViewBox}, expected 50`);
svg.removeAttribute("viewBox");
const widthWithoutViewBox = nestedSVG.getBoundingClientRect().width;
if (widthWithoutViewBox !== 100)
throw new Error(`width without viewBox: got ${widthWithoutViewBox}, expected 100`);
println("PASS");
});
</script>