Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / svg / test / test_length.xhtml
blob34ea694246864263e9861ee7b1e3e2c0da1a8c93
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi?id=342513
4 -->
5 <head>
6 <title>Test SVG Length conversions</title>
7 <script src="/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 </head>
10 <body>
11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=342513">Mozilla Bug 342513</a>
12 <p id="display"></p>
13 <div id="content">
15 <div width="100%" height="1" id="div">
16 </div>
17 <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="1" id="svg">
18 </svg>
19 <svg xmlns="http://www.w3.org/2000/svg" width="600" height="400" font-size="5">
20 <svg font-size="10" width="20em" height="20em">
21 <rect id="r1" x="5em" y="6em" width="20%" height="30%" />
22 </svg>
23 <div style="zoom: 2;">
24 <svg width="40" height="40">
25 <rect id="r2" width="25" height="20" />
26 </svg>
27 </div>
28 </svg>
30 </div>
31 <pre id="test">
32 <script class="testbody" type="text/javascript">
33 <![CDATA[
35 SimpleTest.waitForExplicitFinish();
37 function run() {
38 var svgDoc = document.getElementById("svg");
39 var divElem = document.getElementById("div");
40 var expectedWidth = divElem.clientWidth;
41 // test for the pixel width of the svg
42 isfuzzy(svgDoc.width.baseVal.value, expectedWidth, 0.01, "svgDoc.width.baseVal.value");
44 // set the SVG width to ~50% in pixels
45 svgDoc.width.baseVal.newValueSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PX, Math.floor(expectedWidth / 2));
46 svgDoc.width.baseVal.convertToSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PERCENTAGE);
47 // the valueInSpecifiedUnits should now be 50%
48 is(Math.round(svgDoc.width.baseVal.valueInSpecifiedUnits), 50, "valueInSpecifiedUnits after convertToSpecifiedUnits");
50 let r1 = document.getElementById("r1");
51 is(r1.width.baseVal.value, 40, "width in em for elements inside inner <svg> should be resolved against the inner <svg>");
52 is(r1.height.baseVal.value, 60, "height in em for elements inside inner <svg> should be resolved against the inner <svg>");
54 let r2 = document.getElementById("r2");
55 is(r2.width.baseVal.value, 25, "width in px for elements in zoomed div should be the same as unzoomed");
56 is(r2.height.baseVal.value, 20, "height in px for elements inside zoomed div should be the same as unzoomed");
58 SimpleTest.finish();
61 window.addEventListener("load", run);
63 ]]>
64 </script>
65 </pre>
66 </body>
67 </html>