Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-with-existing-item.html

Issue 2362653002: Convert LayoutTests/svg/dom/SVGTransform*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: Align with review comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <script src="../../resources/js-test.js"></script> 2 <title>SVGTransformList, with existing item</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
3 <script src="resources/SVGTransformList-helper.js"></script> 5 <script src="resources/SVGTransformList-helper.js"></script>
4 6
5 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200"> 7 <svg width="200" height="200">
6 <circle id="circle1" cx="40" cy="40" r="40" fill="green" transform="scale(2, 2)"/> 8 <circle id="circle1" cx="40" cy="40" r="40" fill="green" transform="scale(2, 2)"/>
7 <circle id="circle2" cx="40" cy="40" r="40" fill="green" transform="scale(2, 2)"/> 9 <circle id="circle2" cx="40" cy="40" r="40" fill="green" transform="scale(2, 2)"/>
8 </svg> 10 </svg>
9 11
10 <script type="text/javascript"> 12 <script>
11 description("This is a test of more SVGTransformList API parts."); 13 test(function() {
14 // This is of mutations of a SVGTransformList with an SVGTransform that alread y exist in a list.
12 15
13 if (window.testRunner) 16 var svg = document.querySelector("svg");
14 testRunner.dumpAsText(); 17 var circle1 = document.getElementById("circle1");
18 var circle2 = document.getElementById("circle2");
15 19
16 var svg = document.getElementById("svg"); 20 var translate = svg.createSVGTransform();
17 var circle1 = document.getElementById("circle1"); 21 translate.setTranslate(100, 100);
18 var circle2 = document.getElementById("circle2");
19
20 var translate = svg.createSVGTransform();
21 translate.setTranslate(100, 100);
22
23 var scale = svg.createSVGTransform();
24 scale.setScale(3, 3);
25
26 var transformList1 = circle1.transform.baseVal;
27 var transformList2 = circle2.transform.baseVal;
28
29 debug("Test appendItem with SVGTransform that already exist in a list");
30 transformList1.appendItem(translate);
31 transformList2.appendItem(translate);
32 shouldBe("transformList1.numberOfItems", "2");
33 shouldBe("transformList2.numberOfItems", "2");
34 shouldBeEqualToString("transformList1.getItem(1).toString()", "type=SVG_TRAN SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
35 shouldBeEqualToString("transformList2.getItem(1).toString()", "type=SVG_TRAN SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
36
37 debug("");
38 debug("Test changing SVGTransform value");
39 translate.setTranslate(200, 200);
40 shouldBeEqualToString("transformList1.getItem(1).toString()", "type=SVG_TRAN SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
41 shouldBeEqualToString("transformList2.getItem(1).toString()", "type=SVG_TRAN SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
42
43 debug("");
44 debug("Test insertItemBefore with SVGTransform that already exist in a list" );
45 transformList1.insertItemBefore(translate,0);
46 transformList2.insertItemBefore(translate,0);
47 shouldBeEqualToString("transformList1.getItem(0).toString()", "type=SVG_TRAN SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
48 shouldBeEqualToString("transformList2.getItem(0).toString()", "type=SVG_TRAN SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
49 shouldBe("transformList1.numberOfItems", "3");
50 shouldBe("transformList2.numberOfItems", "3");
51
52 debug("");
53 debug("Test replaceItem with SVGTransform that already exist in a list");
54 transformList1.replaceItem(scale,2);
55 transformList2.replaceItem(scale,2);
56 shouldBeEqualToString("transformList1.getItem(2).toString()", "type=SVG_TRAN SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
57 shouldBeEqualToString("transformList2.getItem(2).toString()", "type=SVG_TRAN SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
58 shouldBe("transformList1.numberOfItems", "3");
59 shouldBe("transformList2.numberOfItems", "3");
60
61 debug("");
62 debug("Test initialize with SVGTransform that already exist in a list");
63 transformList1.initialize(scale);
64 transformList2.initialize(scale);
65 shouldBeEqualToString("transformList1.getItem(0).toString()", "type=SVG_TRAN SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
66 shouldBeEqualToString("transformList2.getItem(0).toString()", "type=SVG_TRAN SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
67 shouldBe("transformList1.numberOfItems", "1");
68 shouldBe("transformList2.numberOfItems", "1");
69 22
70 </script> 23 var scale = svg.createSVGTransform();
24 scale.setScale(3, 3);
25
26 var transformList1 = circle1.transform.baseVal;
27 var transformList2 = circle2.transform.baseVal;
28
29 // Test appendItem with SVGTransform that already exist in a list.
30 transformList1.appendItem(translate);
31 transformList2.appendItem(translate);
32 assert_equals(transformList1.numberOfItems, 2);
33 assert_equals(transformList2.numberOfItems, 2);
34 assert_equals(transformList1.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSL ATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
35 assert_equals(transformList2.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSL ATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
36
37 // Test changing SVGTransform value.
38 translate.setTranslate(200, 200);
39 assert_equals(transformList1.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSL ATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
40 assert_equals(transformList2.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSL ATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]");
41
42 // Test insertItemBefore with SVGTransform that already exist in a list.
43 transformList1.insertItemBefore(translate,0);
44 transformList2.insertItemBefore(translate,0);
45 assert_equals(transformList1.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSL ATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
46 assert_equals(transformList2.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSL ATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]");
47 assert_equals(transformList1.numberOfItems, 3);
48 assert_equals(transformList2.numberOfItems, 3);
49
50 // Test replaceItem with SVGTransform that already exist in a list.
51 transformList1.replaceItem(scale,2);
52 transformList2.replaceItem(scale,2);
53 assert_equals(transformList1.getItem(2).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
54 assert_equals(transformList2.getItem(2).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
55 assert_equals(transformList1.numberOfItems, 3);
56 assert_equals(transformList2.numberOfItems, 3);
57
58 // Test initialize with SVGTransform that already exist in a list.
59 transformList1.initialize(scale);
60 transformList2.initialize(scale);
61 assert_equals(transformList1.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
62 assert_equals(transformList2.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]");
63 assert_equals(transformList1.numberOfItems, 1);
64 assert_equals(transformList2.numberOfItems, 1);
65 });
66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698