| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <script>window.enablePixelTesting = true;</script> |
| <script src="../../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 0 L 100 100" fill="green"/> |
| <path transform="translate(110, 0)" id="path2" d="M 0 0 L 50 100 h 100 h 100 v 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 'length' attribute and the indexed property access of the SVGPathSegList interface."); |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| var svg = document.getElementById("svg"); |
| var path1 = document.getElementById("path1"); |
| var path2 = document.getElementById("path2"); |
| |
| var pathSeg1 = path1.createSVGPathSegLinetoAbs(50, 50); |
| var pathSeg2 = path1.createSVGPathSegLinetoVerticalAbs(50); |
| |
| debug(""); |
| debug("Test list length/numberOfItems"); |
| shouldBe("path1.pathSegList.length", "3"); |
| shouldBe("path1.pathSegList.numberOfItems", "3"); |
| shouldBe("path2.pathSegList.length", "5"); |
| shouldBe("path2.pathSegList.numberOfItems", "5"); |
| |
| debug(""); |
| debug("Test item getter"); |
| shouldBeEqualToString("path1.pathSegList[0].toString()", "[object SVGPathSegMovetoAbs]"); |
| shouldBe("path1.pathSegList[0].x", "0"); |
| shouldBe("path1.pathSegList[0].y", "0"); |
| shouldBeEqualToString("path1.pathSegList[1].toString()", "[object SVGPathSegLinetoAbs]"); |
| shouldBe("path1.pathSegList[1].x", "100"); |
| shouldBe("path1.pathSegList[1].y", "0"); |
| shouldBeEqualToString("path1.pathSegList[2].toString()", "[object SVGPathSegLinetoAbs]"); |
| shouldBe("path1.pathSegList[2].x", "100"); |
| shouldBe("path1.pathSegList[2].y", "100"); |
| shouldBeUndefined("path1.pathSegList[3]"); |
| debug(""); |
| shouldBeEqualToString("path2.pathSegList[0].toString()", "[object SVGPathSegMovetoAbs]"); |
| shouldBe("path2.pathSegList[0].x", "0"); |
| shouldBe("path2.pathSegList[0].y", "0"); |
| shouldBeEqualToString("path2.pathSegList[1].toString()", "[object SVGPathSegLinetoAbs]"); |
| shouldBe("path2.pathSegList[1].x", "50"); |
| shouldBe("path2.pathSegList[1].y", "100"); |
| shouldBeEqualToString("path2.pathSegList[2].toString()", "[object SVGPathSegLinetoHorizontalRel]"); |
| shouldBe("path2.pathSegList[2].x", "100"); |
| shouldBeEqualToString("path2.pathSegList[3].toString()", "[object SVGPathSegLinetoHorizontalRel]"); |
| shouldBe("path2.pathSegList[3].x", "100"); |
| shouldBeEqualToString("path2.pathSegList[4].toString()", "[object SVGPathSegLinetoVerticalRel]"); |
| shouldBe("path2.pathSegList[4].y", "100"); |
| shouldBeUndefined("path2.pathSegList[5]"); |
| |
| debug(""); |
| debug("Test item setter"); |
| shouldBe("path1.pathSegList[2] = pathSeg1", "pathSeg1"); |
| shouldBeEqualToString("path1.pathSegList[2].toString()", "[object SVGPathSegLinetoAbs]"); |
| shouldBe("path1.pathSegList[2].x", "50"); |
| shouldBe("path1.pathSegList[2].y", "50"); |
| shouldThrow("path1.pathSegList[2] = 0"); |
| shouldThrow("path1.pathSegList[2] = 'aString'"); |
| shouldThrow("path1.pathSegList[2] = null"); |
| debug(""); |
| shouldBe("path2.pathSegList[4] = pathSeg2", "pathSeg2"); |
| shouldBeEqualToString("path2.pathSegList[4].toString()", "[object SVGPathSegLinetoVerticalAbs]"); |
| shouldBe("path2.pathSegList[4].y", "50"); |
| shouldThrow("path2.pathSegList[4] = 0"); |
| shouldThrow("path2.pathSegList[4] = 'aString'"); |
| shouldThrow("path2.pathSegList[4] = null"); |
| ]]> |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |