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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-appendItem.html

Issue 2340733002: Convert LayoutTests/svg/dom/SVGLengthList*.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
(Empty)
1 <!DOCTYPE HTML>
2 <title>SVGLengthList, appendItem()</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <svg width="200" height="200">
6 <text id="text1" x="500 50 100 900 1000" y="50">ABC</text>
7 <text id="text2" x="50 100 1000" y="100">ABC</text>
8 </svg>
9 <script>
10 test(function() {
11 // This is a test of the SVGLengthList::appendItem() API.
12 var svg = document.querySelector("svg");
13 var list1 = document.getElementById("text1").x.baseVal;
14 var list2 = document.getElementById("text2").x.baseVal;
15
16 // Create a new SVGLength object, with value=150.
17 var newLength1 = svg.createSVGLength();
18 newLength1.value = 150;
19 assert_equals(newLength1.value, 150);
20
21 // Check initial list state of text1.
22 assert_equals(list1.numberOfItems, 5);
23 assert_equals(list1.getItem(0).value, 500);
24 assert_equals(list1.getItem(1).value, 50);
25 assert_equals(list1.getItem(2).value, 100);
26 assert_equals(list1.getItem(3).value, 900);
27 assert_equals(list1.getItem(4).value, 1000);
28 assert_throws("IndexSizeError", function() { list1.getItem(5); });
29
30 // Check initial list state of text2.
31 assert_equals(list2.numberOfItems, 3);
32 assert_equals(list2.getItem(0).value, 50);
33 assert_equals(list2.getItem(1).value, 100);
34 assert_equals(list2.getItem(2).value, 1000);
35 assert_throws("IndexSizeError", function() { list2.getItem(3); });
36
37 // Append fourth item x=900 to the text1 x list.
38 assert_equals(list1.appendItem(list1.getItem(3)).value, list1.getItem(5).value );
39 assert_equals(list1.numberOfItems, 6);
40 assert_equals(list1.getItem(0).value, 500);
41 assert_equals(list1.getItem(1).value, 50);
42 assert_equals(list1.getItem(2).value, 100);
43 assert_equals(list1.getItem(3).value, 900);
44 assert_equals(list1.getItem(4).value, 1000);
45 assert_equals(list1.getItem(5).value, 900);
46 assert_throws("IndexSizeError", function() { list1.getItem(6); });
47
48 // Append first item x=500 to the text1 x list.
49 assert_equals(list1.appendItem(list1.getItem(0)).value, list1.getItem(6).value );
50 assert_equals(list1.numberOfItems, 7);
51 assert_equals(list1.getItem(0).value, 500);
52 assert_equals(list1.getItem(1).value, 50);
53 assert_equals(list1.getItem(2).value, 100);
54 assert_equals(list1.getItem(3).value, 900);
55 assert_equals(list1.getItem(4).value, 1000);
56 assert_equals(list1.getItem(5).value, 900);
57 assert_equals(list1.getItem(6).value, 500);
58 assert_throws("IndexSizeError", function() { list1.getItem(7); });
59
60 // Append 'newLength1' to the text1 x list.
61 assert_equals(list1.appendItem(newLength1).value, list1.getItem(7).value);
62 assert_equals(list1.numberOfItems, 8);
63 assert_equals(list1.getItem(0).value, 500);
64 assert_equals(list1.getItem(1).value, 50);
65 assert_equals(list1.getItem(2).value, 100);
66 assert_equals(list1.getItem(3).value, 900);
67 assert_equals(list1.getItem(4).value, 1000);
68 assert_equals(list1.getItem(5).value, 900);
69 assert_equals(list1.getItem(6).value, 500);
70 assert_equals(list1.getItem(7).value, 150);
71 assert_throws("IndexSizeError", function() { list1.getItem(8); });
72
73 // Append third and fourth item of the text1 x list to the text2 x list.
74 assert_equals(list2.appendItem(list1.getItem(2)).value, 100);
75 assert_equals(list2.appendItem(list1.getItem(3)).value, 900);
76 assert_equals(list1.numberOfItems, 8);
77 assert_equals(list1.getItem(0).value, 500);
78 assert_equals(list1.getItem(1).value, 50);
79 assert_equals(list1.getItem(2).value, 100);
80 assert_equals(list1.getItem(3).value, 900);
81 assert_equals(list1.getItem(4).value, 1000);
82 assert_equals(list1.getItem(5).value, 900);
83 assert_equals(list1.getItem(6).value, 500);
84 assert_equals(list1.getItem(7).value, 150);
85 assert_throws("IndexSizeError", function() { list1.getItem(8); });
86 assert_equals(list2.numberOfItems, 5);
87 assert_equals(list2.getItem(0).value, 50);
88 assert_equals(list2.getItem(1).value, 100);
89 assert_equals(list2.getItem(2).value, 1000);
90 assert_equals(list2.getItem(3).value, 100);
91 assert_equals(list2.getItem(4).value, 900);
92 assert_throws("IndexSizeError", function() { list2.getItem(5); });
93
94 var newLength2 = svg.createSVGLength();
95 newLength2.value = 150;
96 assert_equals(newLength2.value, 150);
97 list1.clear();
98
99 // Shuffle around items in text1 and text2 list using appendItem, to get x=50, 100,150,... in both lists.
100 assert_equals(list1.appendItem(list2.getItem(0)).value, 50);
101 assert_equals(list1.appendItem(list2.getItem(1)).value, 100);
102 assert_equals(list1.appendItem(newLength2).value, 150);
103 list2.clear();
104 assert_equals(list2.appendItem(list1.getItem(0)).value, 50);
105 assert_equals(list2.appendItem(list1.getItem(1)).value, 100);
106 assert_equals(list2.appendItem(list1.getItem(2)).value, 150);
107 assert_equals(list1.numberOfItems, 3);
108 assert_equals(list1.getItem(0).value, 50);
109 assert_equals(list1.getItem(1).value, 100);
110 assert_equals(list1.getItem(2).value, 150);
111 assert_throws("IndexSizeError", function() { list1.getItem(4); });
112 assert_equals(list2.numberOfItems, 3);
113 assert_equals(list2.getItem(0).value, 50);
114 assert_equals(list2.getItem(1).value, 100);
115 assert_equals(list2.getItem(2).value, 150);
116 assert_throws("IndexSizeError", function() { list2.getItem(6); });
117 });
118 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698