dom/svg/test/test_SVGPointList.xhtml
author Birunthan Mohanathas <birunthan@mohanathas.com>
Mon, 12 May 2014 22:29:04 +0300
changeset 201961 85228ee8ce8b1ed628e49baf88104469fb0ea7e6
parent 106320 content/svg/content/test/test_SVGPointList.xhtml@cad2a6ac68ca231ab797a992503f8bca261fc974
permissions -rw-r--r--
Bug 946065 - Part 8: Move content/svg/ to dom/ and flatten subdirectories. r=jwatt

<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=629200
-->
<head>
  <title>Tests specific to SVGPointList</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="MutationEventChecker.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629200">Mozilla Bug 629200</a>
<p id="display"></p>
<div id="content" style="display:none;">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
  <polyline id="polyline" points="50,375 150,380"/>
</svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[

SimpleTest.waitForExplicitFinish();

/*
This file runs a series of SVGPointList specific tests. Generic SVGXxxList
tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
to other list types belongs there.
*/

function run_tests()
{
  document.getElementById('svg').pauseAnimations();

  var polyline = document.getElementById("polyline");
  var points = polyline.points;

  is(points.numberOfItems, 2, 'Checking numberOfItems');

  // Test mutation events
  // --- Initialization
  eventChecker = new MutationEventChecker;
  eventChecker.watchAttr(polyline, "points");
  // -- Actual changes
  eventChecker.expect("modify modify");
  points[0].x = 40;
  polyline.setAttribute("points", "30,375 150,380");
  // -- Redundant changes
  eventChecker.expect("");
  points[0].x = 30;
  points[1].y = 380;
  polyline.setAttribute("points", "30,375 150,380");
  // -- Invalid attribute
  eventChecker.expect("modify");
  polyline.setAttribute("points", ",30,375");
  is(points.numberOfItems, 0, 'Checking that parsing stops at invalid token');
  // -- Attribute removal
  eventChecker.expect("remove");
  polyline.removeAttribute("points");
  // -- Non-existent attribute removal
  eventChecker.expect("");
  polyline.removeAttribute("points");
  polyline.removeAttributeNS(null, "points");
  eventChecker.finish();

  SimpleTest.finish();
}

window.addEventListener("load", run_tests, false);

]]>
</script>
</pre>
</body>
</html>