test_valueAsString.xhtml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 type="text/javascript" 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. <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="1" id="svg">
  15. <circle id='c' r='1em' display='none'/>
  16. <marker id='m' orient='20rad' display='none'/>
  17. </svg>
  18. </div>
  19. <pre id="test">
  20. <script class="testbody" type="text/javascript">
  21. <![CDATA[
  22. SimpleTest.waitForExplicitFinish();
  23. function run()
  24. {
  25. var c = document.getElementById('c');
  26. var m = document.getElementById('m');
  27. is(SVGLength.SVG_LENGTHTYPE_EMS, c.r.baseVal.unitType, 'unexpected units');
  28. c.r.baseVal.valueAsString = '2px';
  29. is(SVGLength.SVG_LENGTHTYPE_PX, c.r.baseVal.unitType, 'unexpected units');
  30. try {
  31. c.r.baseVal.valueAsString = 'rubbish';
  32. ok(false, 'setting a length to rubbish should fail');
  33. } catch (e) {
  34. is(e.name, 'SyntaxError', 'syntax error expected');
  35. is(e.code, DOMException.SYNTAX_ERR, 'syntax error expected');
  36. }
  37. is(SVGAngle.SVG_ANGLETYPE_RAD, m.orientAngle.baseVal.unitType, 'unexpected units');
  38. m.orientAngle.baseVal.valueAsString = '2grad';
  39. is(SVGAngle.SVG_ANGLETYPE_GRAD, m.orientAngle.baseVal.unitType, 'unexpected units');
  40. try {
  41. m.orientAngle.baseVal.valueAsString = 'rubbish';
  42. ok(false, 'setting an angle to rubbish should fail');
  43. } catch (e) {
  44. is(e.name, 'SyntaxError', 'syntax error expected');
  45. is(e.code, DOMException.SYNTAX_ERR, 'syntax error expected');
  46. }
  47. SimpleTest.finish();
  48. }
  49. window.addEventListener("load", run, false);
  50. ]]>
  51. </script>
  52. </pre>
  53. </body>
  54. </html>