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

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

Issue 2344403002: Convert LayoutTests/svg/dom/SVGLengthList*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: 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, initialize()</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 1000 1500" y="25"> ABC </text>
7 <text id="text2" x="50 500" y="50"> ABC </text>
8 <text id="text3" x="50 500 50" y="75">ABC</text>
9 <text id="text4" x="500" y="100">ABC</text>
10 </svg>
11 <script>
12 test(function() {
13 // This is a test of the SVGLengthList::initialize() API.
14
15 var svg = document.querySelector("svg");
16 var list1 = document.getElementById("text1").x.baseVal;
17 var list2 = document.getElementById("text2").x.baseVal;
18 var list3 = document.getElementById("text3").x.baseVal;
19 var list4 = document.getElementById("text4").x.baseVal;
20
21 // Check initial list state of text1.
22 assert_equals(list1.numberOfItems, 3);
23 assert_equals(list1.getItem(0).value, 500);
24 assert_equals(list1.getItem(1).value, 1000);
25 assert_equals(list1.getItem(2).value, 1500);
26 assert_throws("IndexSizeError", function() { list1.getItem(3); });
27
28 // Check initial list state of text2.
29 assert_equals(list2.numberOfItems, 2);
30 assert_equals(list2.getItem(0).value, 50);
31 assert_equals(list2.getItem(1).value, 500);
32 assert_throws("IndexSizeError", function() { list2.getItem(2); });
33
34 // Check initial list state of text3.
35 assert_equals(list3.numberOfItems, 3);
36 assert_equals(list3.getItem(0).value, 50);
37 assert_equals(list3.getItem(1).value, 500);
38 assert_equals(list3.getItem(2).value, 50);
39 assert_throws("IndexSizeError", function() { list3.getItem(3); });
40
41 // Check initial list state of text4.
42 assert_equals(list4.numberOfItems, 1);
43 assert_equals(list4.getItem(0).value, 500);
44 assert_throws("IndexSizeError", function() { list4.getItem(1); });
45
46 // Create a new SVGLength object, that will be the only x coordinate in the fi rst text element.
47 var newLength = svg.createSVGLength();
48 newLength.value = 50;
49 assert_equals(newLength.value, 50);
50
51 // Spec: Clears all existing current items from the list and re-initializes th e list to hold the single item specified by the parameter.
52
53 // Initialize SVGLengthList with 'newLength'.
54 assert_equals(list1.initialize(newLength).value, newLength.value);
55 assert_equals(list1.getItem(0).value, newLength.value);
56
57 // Take the second x item '500' of the second text element, store it in 'itemI nAnotherList' change it to '50'.
58 assert_equals(list2.getItem(1).value, 500);
59 var itemInAnotherList = list2.getItem(1);
60 itemInAnotherList.value = 50;
61 assert_equals(list2.getItem(1).value, 50);
62
63 // Spec: If newItem is already in a list, then a new object is created with th e same values as newItem and this item is inserted into the list.
64 // Otherwise, newItem itself is inserted into the list..
65
66 // Override the third text elements x list with the item x=50 from the second text element, where it should not be removed afterwards.
67 assert_equals(list3.initialize(itemInAnotherList).value, itemInAnotherList.val ue);
68 assert_equals(list3.getItem(0).value, 50);
69 assert_equals(list2.getItem(0).value, 50);
70 list2.getItem(1); // Should not throw.
71
72 // Assure that the 'itemInAnotherList' item is still live anymore, set value t o 999 then back to 50.
73 itemInAnotherList.value = 999;
74 assert_equals(itemInAnotherList.value, 999);
75 assert_equals(list3.getItem(0).value, 50);
76 itemInAnotherList.value = 50;
77 assert_equals(itemInAnotherList.value, 50);
78 assert_equals(list3.getItem(0).value, 50);
79
80 // Copy item from text3 to text4.
81 assert_equals(list4.initialize(list3.getItem(0)).value, itemInAnotherList.valu e);
82 assert_equals(list4.getItem(0).value, 50);
83 list3.getItem(0); // Should not throw.
84
85 // Initialize text2 using setAttribute('x', '50').
86 text2.setAttribute("x", "50");
87 assert_equals(list2.getItem(0).value, 50);
88
89 // Final check whether the lists all look like expected.
90 assert_equals(list1.getItem(0).value, 50);
91 assert_equals(list2.getItem(0).value, 50);
92 assert_equals(list3.getItem(0).value, 50);
93 assert_equals(list4.getItem(0).value, 50);
94 assert_equals(list1.numberOfItems, 1);
95 assert_equals(list2.numberOfItems, 1);
96 assert_equals(list3.numberOfItems, 1);
97 assert_equals(list4.numberOfItems, 1);
98 assert_throws("IndexSizeError", function() { list1.getItem(1); });
99 assert_throws("IndexSizeError", function() { list2.getItem(1); });
100 assert_throws("IndexSizeError", function() { list3.getItem(1); });
101 assert_throws("IndexSizeError", function() { list4.getItem(1); });
102 });
103 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698