Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /svg/coordinate-systems/viewBox-invalid-attribute-baseval.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>SVGSVGElement.viewBox.baseVal for an invalid (negative-dimension) viewBox attribute</title>
<meta name="assert" content="Tentative: SVG 2 does not define viewBox.baseVal when the viewBox attribute is invalid (negative width/height). This documents the current WebKit behavior (reset to {0,0,0,0}); Gecko and Blink retain the raw parsed values, so cross-engine results differ.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<rect width="10" height="10" fill="red"/>
</svg>
<script>
test(() => {
const vb = document.getElementById("s").viewBox.baseVal;
assert_equals(vb.x, 0, "x");
assert_equals(vb.y, 0, "y");
assert_equals(vb.width, 0, "width");
assert_equals(vb.height, 0, "height");
}, "invalid (negative-width) viewBox attribute exposes baseVal {0, 0, 0, 0}");
</script>