blob: 3f39d54c416f9ecb3f72e91354a2f01f2b6b372a [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="500 1000 1500" y="50"> ABC </text>
<text id="reference" x="50 100" y="100"> ABC </text>
</svg>
<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
<![CDATA[
description("This is a test how SVGLengthList reacts to XML DOM modifications.");
var text1 = document.getElementById("text1");
shouldBe("text1.x.baseVal.numberOfItems", "3");
var text1XBaseValGetItem0 = text1.x.baseVal.getItem(0);
var text1XBaseValGetItem1 = text1.x.baseVal.getItem(1);
var text1XBaseValGetItem2 = text1.x.baseVal.getItem(2);
shouldBe("text1XBaseValGetItem0.value", "500");
shouldBe("text1XBaseValGetItem1.value", "1000");
shouldBe("text1XBaseValGetItem2.value", "1500");
debug("");
debug("Setting x = x - 250 on all three items");
text1XBaseValGetItem0.value -= 250;
text1XBaseValGetItem1.value -= 250;
text1XBaseValGetItem2.value -= 250;
shouldBe("text1XBaseValGetItem0.value", "250");
shouldBe("text1XBaseValGetItem1.value", "750");
shouldBe("text1XBaseValGetItem2.value", "1250");
debug("");
debug("Now using text.setAttribute('x', '50 100')");
text1.setAttribute("x", "50 100");
debug("");
debug("Assure that the wrappers still point to the OLD values");
shouldBe("text1XBaseValGetItem0.value", "250");
shouldBe("text1XBaseValGetItem1.value", "750");
shouldBe("text1XBaseValGetItem2.value", "1250");
debug("");
debug("Assure that obtaining new wrappers will give the right NEW values");
shouldBe("text1.x.baseVal.numberOfItems", "2");
shouldBe("text1.x.baseVal.getItem(0).value", "50");
shouldBe("text1.x.baseVal.getItem(1).value", "100");
debug("");
debug("Setting x = x + 100 on all old wrapper items");
text1XBaseValGetItem0.value += 100;
text1XBaseValGetItem1.value += 100;
text1XBaseValGetItem2.value += 100;
debug("");
debug("Assure that the old wrappers can still be modified, but don't influence the new wrappers");
shouldBe("text1XBaseValGetItem0.value", "350");
shouldBe("text1XBaseValGetItem1.value", "850");
shouldBe("text1XBaseValGetItem2.value", "1350");
debug("");
debug("Assure that the new wrappers stayed the same");
shouldBe("text1.x.baseVal.numberOfItems", "2");
shouldBe("text1.x.baseVal.getItem(0).value", "50");
shouldBe("text1.x.baseVal.getItem(1).value", "100");
debug("");
debug("The test passes if you only see 'PASS' messages, and both elements on top look the same");
debug("");
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>