| OLD | NEW |
| (Empty) |
| 1 <html xmlns="http://www.w3.org/1999/xhtml"> | |
| 2 <head> | |
| 3 <script>window.enablePixelTesting = true;</script> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 <script src="../../fast/repaint/resources/text-based-repaint.js"></script> | |
| 6 <script type="text/javascript"> | |
| 7 window.outputRepaintRects = false; | |
| 8 function repaintTest() { | |
| 9 window.jsTestIsAsync = true; | |
| 10 if (window.testRunner) | |
| 11 testRunner.waitUntilDone(); | |
| 12 | |
| 13 path = document.getElementById("path"); | |
| 14 shouldBe("path.pathSegList.numberOfItems", "3"); | |
| 15 | |
| 16 // Check initial 'd' attribute value. | |
| 17 shouldBeEqualToString("path.getAttribute('d').formatDAttribute()", "M 20
0 0 L 100 0 L 100 100"); | |
| 18 | |
| 19 // Append one item, check 'd' attribute changed. | |
| 20 path.pathSegList.appendItem(path.createSVGPathSegLinetoAbs(0, 100)); | |
| 21 shouldBeEqualToString("path.getAttribute('d').formatDAttribute()", "M 20
0 0 L 100 0 L 100 100 L 0 100"); | |
| 22 | |
| 23 // Modify first item, check 'd' attribute changed. | |
| 24 path.pathSegList.getItem(0).x -= 100; | |
| 25 shouldBeEqualToString("path.getAttribute('d').formatDAttribute()", "M 10
0 0 L 100 0 L 100 100 L 0 100"); | |
| 26 | |
| 27 // Modify first item, check 'd' attribute changed, now a green rectangle
should be visible. | |
| 28 path.pathSegList.getItem(0).x -= 100; | |
| 29 shouldBeEqualToString("path.getAttribute('d').formatDAttribute()", "M 0
0 L 100 0 L 100 100 L 0 100"); | |
| 30 | |
| 31 finishJSTest(); | |
| 32 } | |
| 33 </script> | |
| 34 </head> | |
| 35 <body onload="runRepaintAndPixelTest()"> | |
| 36 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200"> | |
| 37 <path id="path" fill="green" transform="translate(10 10)" d="M 200 0 L 100 0
L 100 100"/> | |
| 38 </svg> | |
| 39 | |
| 40 <p id="description"></p> | |
| 41 <div id="console"></div> | |
| 42 <script type="text/javascript"> | |
| 43 <![CDATA[ | |
| 44 description("This is a test how SVGLengthList reacts to XML DOM modification
s."); | |
| 45 | |
| 46 // Extend String prototype, to offer a function, that formats the d attribut
e in the same way across browsers | |
| 47 String.prototype.formatDAttribute = function() { | |
| 48 return this.replace(/,/g, " ") // Remove Firefox commas | |
| 49 .replace(/([A-Z])/g, " $1 ") // "M 100 0L 50 0" -> " M 100 0
L 50 0" | |
| 50 .replace(/^\s/, "") // " M 100 0" -> "M 100 0" | |
| 51 .replace(/\s\s/g, " "); // If there was already whitespa
ce between coordinates & commands, fix it up again. | |
| 52 } | |
| 53 ]]> | |
| 54 </script> | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |