summaryrefslogtreecommitdiffstats
path: root/dom/svg/test/test_pathLength.html
blob: 499343fa331985496b266b891046a6d10db04340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!doctype html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1024926
-->
<head>
  <meta charset="utf-8">
  <title>Test path length changes when manipulated</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=1024926">Mozilla Bug 1024926</a>
<p id="display"></p>
<div id="content" style="display: none">
  <svg width="100%" height="1" id="svg">
    <path id="path_lines" d="M50,100l0,0l0,-50l100,0l86.3325,122.665z"></path>
    <path id="path_straight_curve" d="M0,0 C100,0 150,0 200,0" />
  </svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

  SimpleTest.waitForExplicitFinish();

  // Test a closed path with a series of lines.
  var path = document.getElementById("path_lines");
  is(path.getTotalLength(), 500, "Unexpected path length");

  // Test a path that's been shortened via the DOM.
  for (var i = 0; i < 2; i++) {
      path.pathSegList.removeItem(path.pathSegList.numberOfItems - 1);
  }
  is(path.getTotalLength(), 150, "Unexpected path length");

  // Test a path that's been shortened to be empty, via the DOM.
  while (path.pathSegList.numberOfItems > 0) {
      path.pathSegList.removeItem(0);
  }
  is(path.getTotalLength(), 0, "Unexpected path length");

  // Test a path with a curve command ("C") that is really a straight line.
  path = document.getElementById("path_straight_curve");
  is(path.getTotalLength(), 200, "Unexpected path length, for straight line " +
                                 "generated by 'C' command");

  SimpleTest.finish();

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