blob: a105376b30a59242da30f3c761c0ef0975385ada [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" y="50" requiredFeatures="1 2 3">ABC</text>
</svg>
<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
<![CDATA[
description("This is a test of the simple SVGStringList API parts.");
var text1 = document.getElementById("text1");
shouldBe("text1.requiredFeatures.numberOfItems", "3");
debug("");
debug("Test uncommon arguments for initialize()");
shouldBeEqualToString("text1.requiredFeatures.initialize('30')", "30");
shouldBe("text1.requiredFeatures.numberOfItems", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "30");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "30");
shouldBeEqualToString("text1.requiredFeatures.initialize(text1)", "[object SVGTextElement]");
shouldBe("text1.requiredFeatures.numberOfItems", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "[object SVGTextElement]");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "[object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.initialize(0)", "0");
shouldBe("text1.requiredFeatures.numberOfItems", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "0");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "0");
shouldBeEqualToString("text1.requiredFeatures.initialize('aString')", "aString");
shouldBe("text1.requiredFeatures.numberOfItems", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "aString");
debug("");
debug("Test uncommon arguments for getItem()");
shouldThrow("text1.requiredFeatures.getItem(30)");
shouldBe("text1.requiredFeatures.getItem('aString')", "text1.requiredFeatures.getItem(0)");
shouldBe("text1.requiredFeatures.getItem(text1)", "text1.requiredFeatures.getItem(0)");
shouldBe("text1.requiredFeatures.getItem(null)", "text1.requiredFeatures.getItem(0)");
debug("");
debug("Test uncommon arguments for insertItemBefore()");
shouldThrow("text1.requiredFeatures.insertItemBefore(30)");
shouldThrow("text1.requiredFeatures.insertItemBefore('aString')");
shouldThrow("text1.requiredFeatures.insertItemBefore(text1)");
shouldThrow("text1.requiredFeatures.insertItemBefore(null)");
shouldThrow("text1.requiredFeatures.insertItemBefore(text1.requiredFeatures.getItem(1), 'aString')");
shouldThrow("text1.requiredFeatures.insertItemBefore(text1.requiredFeatures.getItem(1), text1)");
shouldThrow("text1.requiredFeatures.insertItemBefore(text1.requiredFeatures.getItem(1), null)");
shouldThrow("text1.requiredFeatures.insertItemBefore(text1.requiredFeatures.getItem(1), 0)");
shouldBeEqualToString("text1.requiredFeatures.insertItemBefore(30, 0)", "30");
shouldBe("text1.requiredFeatures.numberOfItems", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "30 aString");
shouldBeEqualToString("text1.requiredFeatures.insertItemBefore('aString', 0)", "aString");
shouldBe("text1.requiredFeatures.numberOfItems", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "aString");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "aString 30 aString");
shouldBeEqualToString("text1.requiredFeatures.insertItemBefore(text1, 0)", "[object SVGTextElement]");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "[object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "aString");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "[object SVGTextElement] aString 30 aString");
shouldBeEqualToString("text1.requiredFeatures.insertItemBefore(null, 0)", "null");
shouldBe("text1.requiredFeatures.numberOfItems", "5");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "null");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "[object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "aString");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(4)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "null [object SVGTextElement] aString 30 aString");
debug("");
debug("Set requiredFeatures='1 2 3 4' for text1");
shouldBeUndefined("text1.setAttribute('requiredFeatures', '1 2 3 4')");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "1 2 3 4");
debug("");
debug("Test uncommon arguments for replaceItem() - part 1");
shouldThrow("text1.requiredFeatures.replaceItem(30)");
shouldThrow("text1.requiredFeatures.replaceItem('aString')");
shouldThrow("text1.requiredFeatures.replaceItem(text1)");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(null, 0)", "null");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "null");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "null 2 3 4");
shouldBeEqualToString("text1.requiredFeatures.replaceItem('aString', 3)", "aString");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "null");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "null 2 3 aString");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(text1, 2)", "[object SVGTextElement]");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "null");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "[object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "null 2 [object SVGTextElement] aString");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(1, 1)", "1");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "null");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "[object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "null 1 [object SVGTextElement] aString");
debug("");
debug("Set requiredFeatures='1 2 3 4' for text1");
shouldBeUndefined("text1.setAttribute('requiredFeatures', '1 2 3 4')");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "1 2 3 4");
debug("");
debug("Test uncommon arguments for replaceItem() - part 2");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(text1.requiredFeatures.getItem(0), 0)", "1");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "1 2 3 4");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(text1.requiredFeatures.getItem(0), 'aString')", "1");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "1 2 3 4");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(text1.requiredFeatures.getItem(0), text1)", "1");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "1 2 3 4");
shouldBeEqualToString("text1.requiredFeatures.replaceItem(text1.requiredFeatures.getItem(0), null)", "1");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "1");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "1 2 3 4");
debug("");
debug("Test uncommon arguments for removeItem()");
shouldThrow("text1.requiredFeatures.removeItem(30)");
shouldBeEqualToString("text1.requiredFeatures.removeItem('aString')", "1");
shouldBe("text1.requiredFeatures.numberOfItems", "3");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "2 3 4");
shouldBeEqualToString("text1.requiredFeatures.removeItem(text1)", "2");
shouldBe("text1.requiredFeatures.numberOfItems", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "4");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "3 4");
shouldBeEqualToString("text1.requiredFeatures.removeItem(null)", "3");
shouldBe("text1.requiredFeatures.numberOfItems", "1");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "4");
debug("");
debug("Test uncommon arguments for appendItem()");
shouldBeEqualToString("text1.requiredFeatures.appendItem(30)", "30");
shouldBe("text1.requiredFeatures.numberOfItems", "2");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "30");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "4 30");
shouldBeEqualToString("text1.requiredFeatures.appendItem('aString')", "aString");
shouldBe("text1.requiredFeatures.numberOfItems", "3");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "aString");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "4 30 aString");
shouldBeEqualToString("text1.requiredFeatures.appendItem(text1)", "[object SVGTextElement]");
shouldBe("text1.requiredFeatures.numberOfItems", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "aString");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "[object SVGTextElement]");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "4 30 aString [object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.appendItem(null)", "null");
shouldBe("text1.requiredFeatures.numberOfItems", "5");
shouldBeEqualToString("text1.requiredFeatures.getItem(0)", "4");
shouldBeEqualToString("text1.requiredFeatures.getItem(1)", "30");
shouldBeEqualToString("text1.requiredFeatures.getItem(2)", "aString");
shouldBeEqualToString("text1.requiredFeatures.getItem(3)", "[object SVGTextElement]");
shouldBeEqualToString("text1.requiredFeatures.getItem(4)", "null");
shouldBeEqualToString("text1.getAttribute('requiredFeatures')", "4 30 aString [object SVGTextElement] null");
debug("");
debug("clear() requiredFeatures list so text on top shows up");
shouldBeUndefined("text1.requiredFeatures.clear()");
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>