<!DOCTYPE HTML>
<title>SVGTransformList, with existing item</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGTransformList-helper.js"></script>
<svg width="200" height="200">
<circle id="circle1" cx="40" cy="40" r="40" fill="green" transform="scale(2,2)"/>
<circle id="circle2" cx="40" cy="40" r="40" fill="green" transform="scale(2,2)"/>
</svg>
<script>
test(function() {
// This is of mutations of a SVGTransformList with an SVGTransform that already exist in a list.
var svg = document.querySelector("svg");
var circle1 = document.getElementById("circle1");
var circle2 = document.getElementById("circle2");
var translate = svg.createSVGTransform();
translate.setTranslate(100, 100);
var scale = svg.createSVGTransform();
scale.setScale(3, 3);
var transformList1 = circle1.transform.baseVal;
var transformList2 = circle2.transform.baseVal;
// Test appendItem with SVGTransform that already exist in a list.
transformList1.appendItem(translate);
transformList2.appendItem(translate);
assert_equals(transformList1.numberOfItems, 2);
assert_equals(transformList2.numberOfItems, 2);
assert_equals(transformList1.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
assert_equals(transformList2.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
// Test changing SVGTransform value.
translate.setTranslate(200, 200);
assert_equals(transformList1.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
assert_equals(transformList2.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
// Test insertItemBefore with SVGTransform that already exist in a list.
transformList1.insertItemBefore(translate,0);
transformList2.insertItemBefore(translate,0);
assert_equals(transformList1.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
assert_equals(transformList2.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
assert_equals(transformList1.numberOfItems, 3);
assert_equals(transformList2.numberOfItems, 3);
// Test replaceItem with SVGTransform that already exist in a list.
transformList1.replaceItem(scale,2);
transformList2.replaceItem(scale,2);
assert_equals(transformList1.getItem(2).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
assert_equals(transformList2.getItem(2).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
assert_equals(transformList1.numberOfItems, 3);
assert_equals(transformList2.numberOfItems, 3);
// Test initialize with SVGTransform that already exist in a list.
transformList1.initialize(scale);
transformList2.initialize(scale);
assert_equals(transformList1.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
assert_equals(transformList2.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
assert_equals(transformList1.numberOfItems, 1);
assert_equals(transformList2.numberOfItems, 1);
});
</script>