blob: 483a9697396ba4dc35c24be3f82f8aea7443ada4 [file] [log] [blame]
<!DOCTYPE html>
<title>SVG*List immutability</title>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<script>
var root = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
[
{
element: 'polygon', attr: 'points', value: '0,0 10,10', listName: 'SVGPointList',
accessor: function(elm) { return elm.animatedPoints; },
constructItem: function(elm) { return root.createSVGPoint(); }
}, {
element: 'text', attr: 'x', value: '0 10', listName: 'SVGLengthList',
accessor: function(elm) { return elm.x.animVal; },
constructItem: function(elm) { return root.createSVGLength(); }
}, {
element: 'rect', attr: 'transform', value: 'rotate(0) scale(1)', listName: 'SVGTransformList',
accessor: function(elm) { return elm.transform.animVal; },
constructItem: function(elm) { return root.createSVGTransform(); }
}
].forEach(function(testItem) {
var element = document.createElementNS('http://www.w3.org/2000/svg', testItem.element);
element.setAttribute(testItem.attr, testItem.value);
var list = testItem.accessor(element);
var item = testItem.constructItem(element);
test(function() {
assert_equals(list.length, 2);
assert_throws('NoModificationAllowedError', function() { list.clear(); });
assert_throws('NoModificationAllowedError', function() { list.initialize(item); });
assert_throws('NoModificationAllowedError', function() { list[0] = item; });
assert_throws('NoModificationAllowedError', function() { list.insertItemBefore(item, 0); });
assert_throws('NoModificationAllowedError', function() { list.replaceItem(item, 0); });
assert_throws('NoModificationAllowedError', function() { list.removeItem(0); });
assert_throws('NoModificationAllowedError', function() { list.appendItem(item); });
}, document.title + ', ' + testItem.listName);
});
</script>