4 https://bugzilla.mozilla.org/show_bug.cgi?id=946529
8 <title>Test transform parsing
</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=946529">Mozilla Bug
946529</a>
15 <div id=
"content" style=
"display: none">
16 <svg width=
"100%" height=
"1" id=
"svg">
21 <script class=
"testbody" type=
"text/javascript">
24 checkParseOk(
"-.1", -
0.1);
25 checkParseOk(
"1e1",
10);
26 checkParseOk(
"1em",
1,
"em");
27 checkParseOk(
"1ex",
1,
"ex");
28 checkParseOk(
"1e1em",
10,
"em");
29 checkParseOk(
"1E+2",
100);
30 checkParseOk(
".1e-2",
0.001);
31 checkParseOk(
" 10",
10);
32 checkParseOk(
"10 ",
10);
33 checkParseOk(
" 10 ",
10);
34 checkParseOk(
" 10em ",
10,
"em");
38 checkParseFail(
"1 e");
39 checkParseFail(
"1 em");
40 checkParseFail(
"1ee");
41 checkParseFail(
" 10 20");
43 function checkParseOk(spec, valueInUnits, units) {
44 var rect = document.getElementById(
"rect");
46 // Clear previous value
47 rect.removeAttribute(
"x");
48 rect.setAttribute(
"x", spec);
51 const tolerance =
1 /
65535;
52 var actual = rect.x.baseVal.valueInSpecifiedUnits;
53 ok(Math.abs(actual - valueInUnits) < tolerance,
54 spec +
" (value) - got " + actual +
", expected " + valueInUnits);
58 "unknown": SVGLength.SVG_LENGTHTYPE_UNKNOWN,
59 "": SVGLength.SVG_LENGTHTYPE_NUMBER,
60 "%": SVGLength.SVG_LENGTHTYPE_PERCENTAGE,
61 "em": SVGLength.SVG_LENGTHTYPE_EMS,
62 "ex": SVGLength.SVG_LENGTHTYPE_EXS,
63 "px": SVGLength.SVG_LENGTHTYPE_PX,
64 "cm": SVGLength.SVG_LENGTHTYPE_CM,
65 "mm": SVGLength.SVG_LENGTHTYPE_MM,
66 "in": SVGLength.SVG_LENGTHTYPE_IN,
67 "pt": SVGLength.SVG_LENGTHTYPE_PT,
68 "pc": SVGLength.SVG_LENGTHTYPE_PC,
70 if (typeof units ==
"undefined") {
73 is(rect.x.baseVal.unitType, unitMapping[units], spec +
" (unit)");
76 function checkParseFail(spec) {
77 checkParseOk(spec,
0);