Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<title>SVGLength with 'cap' unit</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="cap_ref" style="font-family:initial; font-size:20px; width:10cap"></div>
<svg>
<text id="cap_test" x="10cap" style="font-family:initial; font-size:20px"></text>
</svg>
<script>
let ref_width = cap_ref.offsetWidth;
let cap_length = cap_test.x.baseVal[0];
test(() => {
assert_equals(cap_length.unitType, SVGLength.SVG_LENGTHTYPE_UNKNOWN);
assert_approx_equals(cap_length.value, ref_width, 0.5);
}, "cap unit in SVGLength");
test(() => {
cap_length.value = ref_width * 2;
assert_approx_equals(cap_length.valueInSpecifiedUnits, 20, 0.1);
}, "Convert back to cap from new user unit value");
</script>