Bug 1873144 - Disabled test_conformance__textures__misc__texture-npot-video.html...
[gecko.git] / dom / svg / test / test_length.xhtml
blob513c65cbb213796352aaee6674c4cdaee6e12a13
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 </svg>
25 </div>
26 <pre id="test">
27 <script class="testbody" type="text/javascript">
28 <![CDATA[
30 SimpleTest.waitForExplicitFinish();
32 function run() {
33 var svgDoc = document.getElementById("svg");
34 var divElem = document.getElementById("div");
35 var expectedWidth = divElem.clientWidth;
36 // test for the pixel width of the svg
37 is(svgDoc.width.baseVal.value, expectedWidth, "svgDoc.width.baseVal.value");
39 // set the SVG width to ~50% in pixels
40 svgDoc.width.baseVal.newValueSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PX, Math.floor(expectedWidth / 2));
41 svgDoc.width.baseVal.convertToSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PERCENTAGE);
42 // the valueInSpecifiedUnits should now be 50%
43 is(Math.round(svgDoc.width.baseVal.valueInSpecifiedUnits), 50, "valueInSpecifiedUnits after convertToSpecifiedUnits");
45 let r1 = document.getElementById("r1");
46 is(r1.width.baseVal.value, 40, "width in em for elements inside inner <svg> should be resolved against the inner <svg>");
47 is(r1.height.baseVal.value, 60, "height in em for elements inside inner <svg> should be resolved against the inner <svg>");
49 SimpleTest.finish();
52 window.addEventListener("load", run);
54 ]]>
55 </script>
56 </pre>
57 </body>
58 </html>