| <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 50 100 900 1000" y="50">ABC</text> |
| <text id="text2" x="50 100 1000" y="100">ABC</text> |
| <text id="reference" x="50 100 150" y="150">ABC</text> |
| </svg> |
| |
| <p id="description"></p> |
| <div id="console"></div> |
| <script type="text/javascript"> |
| <![CDATA[ |
| description("This is a test of the SVGLengthList::appendItem() API."); |
| |
| var svg = document.getElementById("svg"); |
| var text1 = document.getElementById("text1"); |
| var text2 = document.getElementById("text2"); |
| |
| debug(""); |
| debug("Create a new SVGLength object, with value=150"); |
| var newLength1 = svg.createSVGLength(); |
| newLength1.value = 150; |
| shouldBe("newLength1.value", "150"); |
| |
| debug(""); |
| debug("Check initial list state of text1"); |
| shouldBe("text1.x.baseVal.numberOfItems", "5"); |
| shouldBe("text1.x.baseVal.getItem(0).value", "500"); |
| shouldBe("text1.x.baseVal.getItem(1).value", "50"); |
| shouldBe("text1.x.baseVal.getItem(2).value", "100"); |
| shouldBe("text1.x.baseVal.getItem(3).value", "900"); |
| shouldBe("text1.x.baseVal.getItem(4).value", "1000"); |
| shouldThrow("text1.x.baseVal.getItem(5)"); |
| |
| debug(""); |
| debug("Check initial list state of text2"); |
| shouldBe("text2.x.baseVal.numberOfItems", "3"); |
| shouldBe("text2.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text2.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text2.x.baseVal.getItem(2).value", "1000"); |
| shouldThrow("text2.x.baseVal.getItem(3)"); |
| |
| debug(""); |
| debug("Append fourth item x=900 to the text1 x list"); |
| shouldBe("text1.x.baseVal.appendItem(text1.x.baseVal.getItem(3))", "text1.x.baseVal.getItem(5)"); |
| shouldBeEqualToString("text1.x.baseVal.removeItem(3).toString()", "[object SVGLength]"); |
| shouldBe("text1.x.baseVal.numberOfItems", "5"); |
| shouldBe("text1.x.baseVal.getItem(0).value", "500"); |
| shouldBe("text1.x.baseVal.getItem(1).value", "50"); |
| shouldBe("text1.x.baseVal.getItem(2).value", "100"); |
| shouldBe("text1.x.baseVal.getItem(3).value", "1000"); |
| shouldBe("text1.x.baseVal.getItem(4).value", "900"); |
| shouldThrow("text1.x.baseVal.getItem(5)"); |
| |
| debug(""); |
| debug("Append first item x=500 to the text1 x list"); |
| shouldBe("text1.x.baseVal.appendItem(text1.x.baseVal.getItem(0))", "text1.x.baseVal.getItem(5)"); |
| shouldBeEqualToString("text1.x.baseVal.removeItem(0).toString()", "[object SVGLength]"); |
| shouldBe("text1.x.baseVal.numberOfItems", "5"); |
| shouldBe("text1.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text1.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text1.x.baseVal.getItem(2).value", "1000"); |
| shouldBe("text1.x.baseVal.getItem(3).value", "900"); |
| shouldBe("text1.x.baseVal.getItem(4).value", "500"); |
| shouldThrow("text1.x.baseVal.getItem(5)"); |
| |
| debug(""); |
| debug("Append 'newLength1' to the text1 x list"); |
| shouldBe("text1.x.baseVal.appendItem(newLength1)", "text1.x.baseVal.getItem(5)"); |
| shouldBe("text1.x.baseVal.numberOfItems", "6"); |
| shouldBe("text1.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text1.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text1.x.baseVal.getItem(2).value", "1000"); |
| shouldBe("text1.x.baseVal.getItem(3).value", "900"); |
| shouldBe("text1.x.baseVal.getItem(4).value", "500"); |
| shouldBe("text1.x.baseVal.getItem(5).value", "150"); |
| shouldThrow("text1.x.baseVal.getItem(6)"); |
| |
| debug(""); |
| debug("Append third and fourth item of the text1 x list to the text2 x list"); |
| shouldBe("text2.x.baseVal.appendItem(text1.x.baseVal.getItem(2)).value", "1000"); |
| shouldBeEqualToString("text1.x.baseVal.removeItem(2).toString()", "[object SVGLength]"); |
| shouldBe("text2.x.baseVal.appendItem(text1.x.baseVal.getItem(2)).value", "900"); |
| shouldBeEqualToString("text1.x.baseVal.removeItem(2).toString()", "[object SVGLength]"); |
| shouldBe("text1.x.baseVal.numberOfItems", "4"); |
| shouldBe("text1.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text1.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text1.x.baseVal.getItem(2).value", "500"); |
| shouldBe("text1.x.baseVal.getItem(3).value", "150"); |
| shouldThrow("text1.x.baseVal.getItem(4)"); |
| shouldBe("text2.x.baseVal.numberOfItems", "5"); |
| shouldBe("text2.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text2.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text2.x.baseVal.getItem(2).value", "1000"); |
| shouldBe("text2.x.baseVal.getItem(3).value", "1000"); |
| shouldBe("text2.x.baseVal.getItem(4).value", "900"); |
| shouldThrow("text2.x.baseVal.getItem(5)"); |
| |
| var newLength2 = svg.createSVGLength(); |
| newLength2.value = 150; |
| shouldBe("newLength2.value", "150"); |
| |
| debug(""); |
| debug("Shuffle around items in text1 and text2 list using appendItem, to get x=50,100,150,... in both lists"); |
| shouldBe("text1.x.baseVal.appendItem(text1.x.baseVal.getItem(2)).value", "500"); |
| shouldBeEqualToString("text1.x.baseVal.removeItem(2).toString()", "[object SVGLength]"); |
| shouldBe("text2.x.baseVal.appendItem(newLength2).value", "150"); |
| shouldBe("text2.x.baseVal.appendItem(text2.x.baseVal.getItem(2)).value", "1000"); |
| shouldBeEqualToString("text2.x.baseVal.removeItem(2).toString()", "[object SVGLength]"); |
| shouldBe("text2.x.baseVal.appendItem(text2.x.baseVal.getItem(3)).value", "900"); |
| shouldBeEqualToString("text2.x.baseVal.removeItem(3).toString()", "[object SVGLength]"); |
| shouldBe("text2.x.baseVal.appendItem(text2.x.baseVal.getItem(2)).value", "1000"); |
| shouldBeEqualToString("text2.x.baseVal.removeItem(2).toString()", "[object SVGLength]"); |
| shouldBe("text1.x.baseVal.numberOfItems", "4"); |
| shouldBe("text1.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text1.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text1.x.baseVal.getItem(2).value", "150"); |
| shouldBe("text1.x.baseVal.getItem(3).value", "500"); |
| shouldThrow("text1.x.baseVal.getItem(4)"); |
| shouldBe("text2.x.baseVal.numberOfItems", "6"); |
| shouldBe("text2.x.baseVal.getItem(0).value", "50"); |
| shouldBe("text2.x.baseVal.getItem(1).value", "100"); |
| shouldBe("text2.x.baseVal.getItem(2).value", "150"); |
| shouldBe("text2.x.baseVal.getItem(3).value", "1000"); |
| shouldBe("text2.x.baseVal.getItem(4).value", "900"); |
| shouldBe("text2.x.baseVal.getItem(5).value", "1000"); |
| shouldThrow("text2.x.baseVal.getItem(6)"); |
| |
| debug(""); |
| debug("The test passes if you only see 'PASS' messages, and all three text elements on top look the same"); |
| debug(""); |
| |
| ]]> |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |