blob: de5c2a78101c7733ce5732b15d03745f41b43060 [file] [log] [blame]
<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="200" height="200">
<text id="text1" x="50 100" rotate="90 180 270">ABC</text>
</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 SVGLengthList interface.");
if (window.testRunner)
testRunner.dumpAsText();
var svg = document.getElementById("svg");
var text1 = document.getElementById("text1");
var length1 = svg.createSVGLength();
var length2 = svg.createSVGLength();
var number1 = svg.createSVGNumber();
var number2 = svg.createSVGNumber();
var number3 = svg.createSVGNumber();
length1.value = 40;
length2.value = 80;
number1.value = 45;
number2.value = 90;
number3.value = 135;
debug("Test list length/numberOfItems");
shouldBe("text1.x.baseVal.length", "2");
shouldBe("text1.x.baseVal.numberOfItems", "2");
shouldBe("text1.rotate.baseVal.length", "3");
shouldBe("text1.rotate.baseVal.numberOfItems", "3");
debug("");
debug("Test item getter");
shouldBe("text1.x.baseVal.getItem(0).value", "50");
shouldBe("text1.x.baseVal[0].value", "50");
shouldBe("text1.x.baseVal.getItem(1).value", "100");
shouldBe("text1.x.baseVal[1].value", "100");
shouldThrow("text1.x.baseVal.getItem(2)");
shouldBeUndefined("text1.x.baseVal[2]");
debug("");
shouldBe("text1.rotate.baseVal.getItem(0).value", "90");
shouldBe("text1.rotate.baseVal[0].value", "90");
shouldBe("text1.rotate.baseVal.getItem(1).value", "180");
shouldBe("text1.rotate.baseVal[1].value", "180");
shouldBe("text1.rotate.baseVal.getItem(2).value", "270");
shouldBe("text1.rotate.baseVal[2].value", "270");
shouldThrow("text1.rotate.baseVal.getItem(3)");
shouldBeUndefined("text1.rotate.baseVal[3]");
debug("");
debug("Test item setter");
shouldBe("text1.x.baseVal[0] = length1", "length1");
shouldBe("text1.x.baseVal[1] = length2", "length2");
shouldBe("text1.x.baseVal.getItem(0).value", "40");
shouldBe("text1.x.baseVal[0].value", "40");
shouldBe("text1.x.baseVal.getItem(1).value", "80");
shouldBe("text1.x.baseVal[1].value", "80");
shouldThrow("text1.x.baseVal[1] = 0");
shouldThrow("text1.x.baseVal[1] = 'aString'");
shouldThrow("text1.x.baseVal[1] = null");
shouldThrow("text1.x.baseVal[2] = length2");
debug("");
shouldBe("text1.rotate.baseVal[0] = number1", "number1");
shouldBe("text1.rotate.baseVal[1] = number2", "number2");
shouldBe("text1.rotate.baseVal[2] = number3", "number3");
shouldBe("text1.rotate.baseVal.getItem(0).value", "45");
shouldBe("text1.rotate.baseVal[0].value", "45");
shouldBe("text1.rotate.baseVal.getItem(1).value", "90");
shouldBe("text1.rotate.baseVal[1].value", "90");
shouldBe("text1.rotate.baseVal.getItem(2).value", "135");
shouldBe("text1.rotate.baseVal[2].value", "135");
shouldThrow("text1.rotate.baseVal[2] = 0");
shouldThrow("text1.rotate.baseVal[2] = 'aString'");
shouldThrow("text1.rotate.baseVal[2] = null");
shouldThrow("text1.rotate.baseVal[3] = number3");
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>