OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>SVG*List immutability</title> |
| 3 <script src=../../resources/testharness.js></script> |
| 4 <script src=../../resources/testharnessreport.js></script> |
| 5 <script> |
| 6 var root = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); |
| 7 [ |
| 8 { |
| 9 element: 'path', attr: 'd', value: 'M0,0l10,10', listName: 'SVGPathSegLi
st', |
| 10 accessor: function(elm) { return elm.animatedPathSegList; }, |
| 11 constructItem: function(elm) { return elm.createSVGPathSegLinetoAbs(20,
20); } |
| 12 }, { |
| 13 element: 'polygon', attr: 'points', value: '0,0 10,10', listName: 'SVGPo
intList', |
| 14 accessor: function(elm) { return elm.animatedPoints; }, |
| 15 constructItem: function(elm) { return root.createSVGPoint(); } |
| 16 }, { |
| 17 element: 'text', attr: 'x', value: '0 10', listName: 'SVGLengthList', |
| 18 accessor: function(elm) { return elm.x.animVal; }, |
| 19 constructItem: function(elm) { return root.createSVGLength(); } |
| 20 }, { |
| 21 element: 'rect', attr: 'transform', value: 'rotate(0) scale(1)', listNam
e: 'SVGTransformList', |
| 22 accessor: function(elm) { return elm.transform.animVal; }, |
| 23 constructItem: function(elm) { return root.createSVGTransform(); } |
| 24 } |
| 25 ].forEach(function(testItem) { |
| 26 var element = document.createElementNS('http://www.w3.org/2000/svg', testIte
m.element); |
| 27 element.setAttribute(testItem.attr, testItem.value); |
| 28 var list = testItem.accessor(element); |
| 29 var item = testItem.constructItem(element); |
| 30 test(function() { |
| 31 assert_equals(list.length, 2); |
| 32 assert_throws('NoModificationAllowedError', function() { list.clear(); }
); |
| 33 assert_throws('NoModificationAllowedError', function() { list.initialize
(item); }); |
| 34 assert_throws('NoModificationAllowedError', function() { list[0] = item;
}); |
| 35 assert_throws('NoModificationAllowedError', function() { list.insertItem
Before(item, 0); }); |
| 36 assert_throws('NoModificationAllowedError', function() { list.replaceIte
m(item, 0); }); |
| 37 assert_throws('NoModificationAllowedError', function() { list.removeItem
(0); }); |
| 38 assert_throws('NoModificationAllowedError', function() { list.appendItem
(item); }); |
| 39 }, document.title + ', ' + testItem.listName); |
| 40 }); |
| 41 </script> |
OLD | NEW |