summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/svg/dom/SVGPathSegList-replaceItem.xhtml
blob: 06dd7c2e955efdd9fe09502255b053df3e104cc1 (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
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>window.enablePixelTesting = true;</script>
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="250" height="250">
    <g transform="translate(10, 10)">
        <path id="path1" d="M 0 0 L 100 100 L 100 0 L 100 100 v 100 L 0 100" fill="green"/>
        <path transform="translate(110, 0)" id="path2" d="M 0 0 h 100 L 200 100 h -100" fill="green"/>
    </g>
</svg>

<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
<![CDATA[
    description("This is a test of the SVGPathSegList::replaceItem() API.");

    var svg = document.getElementById("svg");
    var path1 = document.getElementById("path1");
    var path2 = document.getElementById("path2");

    debug("");
    debug("Check initial 'pathSegList' value of path1");
    shouldBe("path1.pathSegList.numberOfItems", "6");
    shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
    shouldBe("path1.pathSegList.getItem(0).x", "0");
    shouldBe("path1.pathSegList.getItem(0).y", "0");
    shouldBeEqualToString("path1.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(1).x", "100");
    shouldBe("path1.pathSegList.getItem(1).y", "100");
    shouldBeEqualToString("path1.pathSegList.getItem(2).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(2).x", "100");
    shouldBe("path1.pathSegList.getItem(2).y", "0");
    shouldBeEqualToString("path1.pathSegList.getItem(3).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(3).x", "100");
    shouldBe("path1.pathSegList.getItem(3).y", "100");
    shouldBeEqualToString("path1.pathSegList.getItem(4).toString()", "[object SVGPathSegLinetoVerticalRel]");
    shouldBe("path1.pathSegList.getItem(4).y", "100");
    shouldBeEqualToString("path1.pathSegList.getItem(5).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(5).x", "0");
    shouldBe("path1.pathSegList.getItem(5).y", "100");

    debug("");
    debug("Check initial 'pathSegList' value of path2");
    shouldBe("path2.pathSegList.numberOfItems", "4");
    shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
    shouldBe("path2.pathSegList.getItem(0).x", "0");
    shouldBe("path2.pathSegList.getItem(0).y", "0");
    shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoHorizontalRel]");
    shouldBe("path2.pathSegList.getItem(1).x", "100");
    shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path2.pathSegList.getItem(2).x", "200");
    shouldBe("path2.pathSegList.getItem(2).y", "100");
    shouldBeEqualToString("path2.pathSegList.getItem(3).toString()", "[object SVGPathSegLinetoHorizontalRel]");
    shouldBe("path2.pathSegList.getItem(3).x", "-100");

    debug("");
    debug("Replace second item with third item of path1");
    shouldBeEqualToString("path1.pathSegList.replaceItem(path1.pathSegList.getItem(2), 1).toString()", "[object SVGPathSegLinetoAbs]");

    debug("");
    debug("Replace third item of path2 with fourth item of path1");
    shouldBeEqualToString("path2.pathSegList.replaceItem(path1.pathSegList.getItem(3), 2).toString()", "[object SVGPathSegLinetoVerticalRel]");

    debug("");
    debug("Check final 'pathSegList' value of path1");
    shouldBe("path1.pathSegList.numberOfItems", "4");
    shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
    shouldBe("path1.pathSegList.getItem(0).x", "0");
    shouldBe("path1.pathSegList.getItem(0).y", "0");
    shouldBeEqualToString("path1.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(1).x", "100");
    shouldBe("path1.pathSegList.getItem(1).y", "0");
    shouldBeEqualToString("path1.pathSegList.getItem(2).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(2).x", "100");
    shouldBe("path1.pathSegList.getItem(2).y", "100");
    shouldBeEqualToString("path1.pathSegList.getItem(3).toString()", "[object SVGPathSegLinetoAbs]");
    shouldBe("path1.pathSegList.getItem(3).x", "0");
    shouldBe("path1.pathSegList.getItem(3).y", "100");

    debug("");
    debug("Check final 'pathSegList' value of path2");
    shouldBe("path2.pathSegList.numberOfItems", "4");
    shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
    shouldBe("path2.pathSegList.getItem(0).x", "0");
    shouldBe("path2.pathSegList.getItem(0).y", "0");
    shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoHorizontalRel]");
    shouldBe("path2.pathSegList.getItem(1).x", "100");
    shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SVGPathSegLinetoVerticalRel]");
    shouldBe("path2.pathSegList.getItem(2).y", "100");
    shouldBeEqualToString("path2.pathSegList.getItem(3).toString()", "[object SVGPathSegLinetoHorizontalRel]");
    shouldBe("path2.pathSegList.getItem(3).x", "-100");

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