test_scientific.html (3121B)
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=302971 5 --> 6 <head> 7 <title>Test for Bug 302971</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=302971">Mozilla Bug 302971</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"></div> 15 16 <iframe id="svg" src="scientific-helper.svg"></iframe> 17 18 <pre id="test"> 19 <script class="testbody" type="application/javascript"> 20 SimpleTest.waitForExplicitFinish(); 21 22 function runTests() { 23 var doc = $("svg").contentWindow.document; 24 var rect = doc.getElementById("rect"); 25 26 // ordinary 27 28 rect.setAttribute("stroke-width", "5"); 29 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "5px", "Ordinary"); 30 31 // valid exponential notation 32 33 rect.setAttribute("stroke-width", "4E1"); 34 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "40px", "Exponent"); 35 36 rect.setAttribute("stroke-width", "6e1"); 37 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "60px", "Lower-case Exponent"); 38 39 rect.setAttribute("stroke-width", "2E+1"); 40 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "20px", "Positive Exponent"); 41 42 rect.setAttribute("stroke-width", "100E-1"); 43 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "10px", "Negative Exponent"); 44 45 rect.setAttribute("stroke-width", "0.7E1"); 46 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "7px", "Floating Point with Exponent"); 47 48 rect.setAttribute("stroke-width", "50.0E-1"); 49 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "5px", "Floating Point with Negative Exponent"); 50 51 rect.setAttribute("stroke-width", "0.8E+1"); 52 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "8px", "Floating Point with Positive Exponent"); 53 54 rect.setAttribute("stroke-width", "4E1px"); 55 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "40px", "Units"); 56 57 // check units that begin with the letter e 58 59 var font_size = doc.defaultView.getComputedStyle(rect).getPropertyValue("font-size"); 60 61 rect.setAttribute("stroke-width", "1em"); 62 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), font_size, "em Units"); 63 64 // invalid exponential notation 65 66 rect.setAttribute("stroke-width", "1E1.1"); 67 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "1px", "Floating Point Exponent"); 68 69 rect.setAttribute("stroke-width", "E1"); 70 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "1px", "No Mantissa"); 71 72 rect.setAttribute("stroke-width", "1 e"); 73 is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "1px", "Spaces"); 74 75 SimpleTest.finish(); 76 } 77 78 window.addEventListener("load", runTests); 79 </script> 80 </pre> 81 </body> 82 </html>