summaryrefslogtreecommitdiffstats
path: root/dom/svg/test/test_pathSeg.xhtml
blob: 698d078f43c0cfc6b66d17e2b9df997ba3f9981b (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=459953
-->
<head>
  <title>Test for Bug 459953</title>
  <script type="application/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=459953">Mozilla Bug 459953</a>
<p id="display"></p>

<pre id="test">
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();

function runTest()
{
  var svgns="http://www.w3.org/2000/svg";

  var path1=document.createElementNS(svgns, "path");

  var sseg;
  
  var a=10,s=20,d=30,z=9; //Arbitrary numbers for arguments
  
  var whatever=true; //This is often so, but here it does not matter
  
  sseg=path1.createSVGPathSegMovetoAbs(a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegMovetoRel(a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegLinetoAbs(a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegLinetoRel(a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegLinetoVerticalAbs(a);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegLinetoVerticalRel(a);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegLinetoHorizontalAbs(a);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegLinetoHorizontalRel(a);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoCubicAbs(a, s, d, z, a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoCubicRel(a, s, d, z, a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoCubicSmoothAbs(a, s, d, z);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoCubicSmoothRel(a, s, d, z);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoQuadraticAbs(a, s, d, z);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoQuadraticRel(a, s, d, z);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoQuadraticSmoothAbs(a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegCurvetoQuadraticSmoothRel(a, s);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegArcAbs(a, s, d, z, a, whatever, whatever);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegArcRel(a, s, d, z, a, whatever, whatever);
  path1.pathSegList.appendItem(sseg);
  sseg=path1.createSVGPathSegClosePath();
  path1.pathSegList.appendItem(sseg);
  
  for(var i=0;i<path1.pathSegList.numberOfItems;i++){
    var seg=path1.pathSegList.getItem(i);
    switch(seg.pathSegType){
    case seg.PATHSEG_MOVETO_ABS:
      is(seg.pathSegTypeAsLetter, "M", "wrong path segment letter");      
      break;
    case seg.PATHSEG_MOVETO_REL:
      is(seg.pathSegTypeAsLetter, "m", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CLOSEPATH:
      is(seg.pathSegTypeAsLetter, "z", "wrong path segment letter");      
      break;
    case seg.PATHSEG_LINETO_ABS:
      is(seg.pathSegTypeAsLetter, "L", "wrong path segment letter");      
      break;
    case seg.PATHSEG_LINETO_REL:
      is(seg.pathSegTypeAsLetter, "l", "wrong path segment letter");      
      break;
    case seg.PATHSEG_LINETO_VERTICAL_ABS:
      is(seg.pathSegTypeAsLetter, "V", "wrong path segment letter");      
      break;
    case seg.PATHSEG_LINETO_VERTICAL_REL:
      is(seg.pathSegTypeAsLetter, "v", "wrong path segment letter");      
      break;
    case seg.PATHSEG_LINETO_HORIZONTAL_ABS:
      is(seg.pathSegTypeAsLetter, "H", "wrong path segment letter");      
      break;
    case seg.PATHSEG_LINETO_HORIZONTAL_REL:
      is(seg.pathSegTypeAsLetter, "h", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_CUBIC_ABS:
      is(seg.pathSegTypeAsLetter, "C", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_CUBIC_REL:
      is(seg.pathSegTypeAsLetter, "c", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
      is(seg.pathSegTypeAsLetter, "S", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
      is(seg.pathSegTypeAsLetter, "s", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_QUADRATIC_ABS:
      is(seg.pathSegTypeAsLetter, "Q", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_QUADRATIC_REL:
      is(seg.pathSegTypeAsLetter, "q", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
      is(seg.pathSegTypeAsLetter, "T", "wrong path segment letter");      
      break;
    case seg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
      is(seg.pathSegTypeAsLetter, "t", "wrong path segment letter");      
      break;
    case seg.PATHSEG_ARC_ABS:
      is(seg.pathSegTypeAsLetter, "A", "wrong path segment letter");      
      break;
    case seg.PATHSEG_ARC_REL:
      is(seg.pathSegTypeAsLetter, "a", "wrong path segment letter");      
      break;
      
    }
  }
  SimpleTest.finish();
}

window.addEventListener("load", runTest, false);
]]>
</script>
</pre>
</body>
</html>