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