test_valueAsString.xhtml (1882B)
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <!-- 3 https://bugzilla.mozilla.org/show_bug.cgi?id=539697 4 --> 5 <head> 6 <title>Test valueAsString behavior</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=539697">Mozilla Bug 539697</a> 12 <p id="display"></p> 13 <div id="content"> 14 15 <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="1" id="svg"> 16 <circle id='c' r='1em' display='none'/> 17 <marker id='m' orient='20rad' display='none'/> 18 </svg> 19 20 </div> 21 <pre id="test"> 22 <script class="testbody" type="text/javascript"> 23 <![CDATA[ 24 25 SimpleTest.waitForExplicitFinish(); 26 27 function run() { 28 var c = document.getElementById("c"); 29 var m = document.getElementById("m"); 30 31 is(SVGLength.SVG_LENGTHTYPE_EMS, c.r.baseVal.unitType, "unexpected units"); 32 c.r.baseVal.valueAsString = "2px"; 33 is(SVGLength.SVG_LENGTHTYPE_PX, c.r.baseVal.unitType, "unexpected units"); 34 35 try { 36 c.r.baseVal.valueAsString = "rubbish"; 37 ok(false, "setting a length to rubbish should fail"); 38 } catch (e) { 39 is(e.name, "SyntaxError", "syntax error expected"); 40 is(e.code, DOMException.SYNTAX_ERR, "syntax error expected"); 41 } 42 43 is(SVGAngle.SVG_ANGLETYPE_RAD, m.orientAngle.baseVal.unitType, "unexpected units"); 44 m.orientAngle.baseVal.valueAsString = "2grad"; 45 is(SVGAngle.SVG_ANGLETYPE_GRAD, m.orientAngle.baseVal.unitType, "unexpected units"); 46 47 try { 48 m.orientAngle.baseVal.valueAsString = "rubbish"; 49 ok(false, "setting an angle to rubbish should fail"); 50 } catch (e) { 51 is(e.name, "SyntaxError", "syntax error expected"); 52 is(e.code, DOMException.SYNTAX_ERR, "syntax error expected"); 53 } 54 55 SimpleTest.finish(); 56 } 57 58 window.addEventListener("load", run); 59 60 ]]> 61 </script> 62 </pre> 63 </body> 64 </html>