summaryrefslogtreecommitdiffstats
path: root/dom/svg/test/test_markerOrient.xhtml
blob: 63e285dc8e1fbd4792082f269968658e8bf41638 (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
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=892372
-->
<head>
  <title>Test for Bug 892372</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">
  <![CDATA[

  /** Test for Bug 892372 **/
  SimpleTest.waitForExplicitFinish();

  function testAutoIsSet(marker) {
    is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO,
       "orientType baseVal for auto");
    is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO,
       "orientType animVal for auto");
    is(marker.orientAngle.baseVal.value, 0, "orientAngle baseVal for auto");
    is(marker.orientAngle.animVal.value, 0, "orientAngle animVal for auto");
  }

  function testAutoStartReverseIsSet(marker) {
    is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN,
       "orientType baseVal for auto-start-reverse");
    is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN,
       "orientType animVal for auto-start-reverse");
    is(marker.orientAngle.baseVal.value, 0,
       "orientAngle baseVal for auto-start-reverse");
    is(marker.orientAngle.animVal.value, 0,
       "orientAngle animVal for auto-start-reverse");
  }

  function testAngleIsSet(marker, angleVal) {
    is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE,
       "orientType baseVal after numeric angle is set");
    is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE,
       "orientType animVal after numeric angle is set");
    is(m.orientAngle.baseVal.value, angleVal,
       "orientAngle baseVal after numeric angle is set");
    is(m.orientAngle.animVal.value, angleVal,
       "orientAngle animVal after numeric angle is set");
  }

  function run()
  {
    var m = $("m");

    // Testing two conditions:
    // 1) If orient is set to a numeric angle and then set to auto or
    //    auto-start-reverse, orientAngle should return a value of 0
    // 2) If orient is set to something of type other than
    //    SVG_MARKER_ORIENT_ANGLE and then set to a numeric angle,
    //    orientType should return SVG_MARKER_ORIENT_ANGLE

    // default is orient="0"
    testAngleIsSet(m, 0);

    m.setOrientToAuto();
    testAutoIsSet(m);

    // testing condition 2 for an angle set using setOrientToAngle
    var a = $("svg").createSVGAngle();
    a.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 90);
    m.setOrientToAngle(a);
    testAngleIsSet(m, a.value);

    // testing condition 1 for orient set using setOrientToAuto
    m.setOrientToAuto();
    testAutoIsSet(m);

    // testing condition 2 for an angle set using setAttribute
    m.setAttribute("orient", "180");
    testAngleIsSet(m, 180);

    // testing condition 1 for orient set to "auto" using setAttribute
    m.setAttribute("orient", "auto");
    testAutoIsSet(m);

    m.setAttribute("orient", "270");

    // testing condition 1 for orient set to "auto-start-reverse" using
    // setAttribute
    m.setAttribute("orient", "auto-start-reverse");
    testAutoStartReverseIsSet(m);

    SimpleTest.finish();
  }

  function runTestsWithPref() {
    SpecialPowers.pushPrefEnv({ 'set': [['svg.marker-improvements.enabled', true]] }, run);
  }

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

  ]]>
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=892372">Mozilla Bug 892372</a>
<p id="display"></p>
<div id="content" style="display: none">

  <svg xmlns="http://www.w3.org/2000/svg" id="svg">
    <defs>
      <marker id="m" />
    </defs>
  </svg>

</div>
<pre id="test">
</pre>
</body>
</html>