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

Unified Diff: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-replaceItem.html

Issue 2344403002: Convert LayoutTests/svg/dom/SVGLengthList*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: align with review commetns 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-replaceItem.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-replaceItem.html b/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-replaceItem.html
new file mode 100644
index 0000000000000000000000000000000000000000..02ca4d41e10c4c08e440b4fb40ba2c0519be0cda
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-replaceItem.html
@@ -0,0 +1,160 @@
+<!DOCTYPE HTML>
+<title>SVGLengthList, replaceItem()</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<svg width="200" height="200">
+ <text id="text1" x="500 1000 1500" y="50"> ABC </text>
+ <text id="text2" x="500 100 150 50" y="75"> ABC </text>
+ <text id="text3" x="50 50 100 100 150" y="100"> ABC</text>
+ <text id="text4" x="100 50 150 150" y="125"> ABC</text>
+</svg>
+<script>
+test(function() {
+ // This is a test of the SVGLengthList::replaceItem() API.
fs 2016/09/17 17:42:37 Like...
Shanmuga Pandi 2016/09/19 07:40:04 Done.
+
+ var svg = document.querySelector("svg");
+ var list1 = document.getElementById("text1").x.baseVal;
+ var list2 = document.getElementById("text2").x.baseVal;
+ var list3 = document.getElementById("text3").x.baseVal;
+ var list4 = document.getElementById("text4").x.baseVal;
+
+ // Create three SVGLength objects, with values=50,100,150.
+ var newLength1 = svg.createSVGLength();
+ newLength1.value = 50;
+ assert_equals(newLength1.value, 50);
+
+ var newLength2 = svg.createSVGLength();
+ newLength2.value = 100;
+ assert_equals(newLength2.value, 100);
+
+ var newLength3 = svg.createSVGLength();
+ newLength3.value = 150;
+ assert_equals(newLength3.value, 150);
+
+ // Check initial list state of text1.
+ assert_equals(list1.numberOfItems, 3);
Srirama 2016/09/17 12:48:41 this checking looks common in most of the places,
fs 2016/09/17 17:42:37 Yes, that sounds like a good idea. Would cut down
Shanmuga Pandi 2016/09/19 07:40:04 Done.
+ assert_equals(list1.getItem(0).value, 500);
+ assert_equals(list1.getItem(1).value, 1000);
+ assert_equals(list1.getItem(2).value, 1500);
+ assert_throws("IndexSizeError", function() { list1.getItem(3); });
+
+ // Replace the first three values in text1 x list with 'newLength1/2/3'.
+ assert_equals(list1.replaceItem(newLength1, 0).value, newLength1.value);
+ assert_equals(list1.replaceItem(newLength2, 1).value, newLength2.value);
+ assert_equals(list1.replaceItem(newLength3, 2).value, newLength3.value);
+ assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, -100); });
+ assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, -1); });
+ assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, 3); });
+ assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, 100); });
+
+ // Verify that the text1 x value list is correct.
+ assert_equals(list1.numberOfItems, 3);
+ assert_equals(list1.getItem(0).value, 50);
+ assert_equals(list1.getItem(1).value, 100);
+ assert_equals(list1.getItem(2).value, 150);
+
+ // Check initial list state of text2.
+ assert_equals(list2.numberOfItems, 4);
+ assert_equals(list2.getItem(0).value, 500);
+ assert_equals(list2.getItem(1).value, 100);
+ assert_equals(list2.getItem(2).value, 150);
+ assert_equals(list2.getItem(3).value, 50);
+ assert_throws("IndexSizeError", function() { list2.getItem(4); });
+
+ // Spec: If newItem is already in a list, then a new object is created with the same values as newItem and this item is inserted into the list.
+ // Otherwise, newItem itself is inserted into the list.
+
+ // Replace the first item in text2 x list with the fourth item in the list/
+ assert_equals(list2.replaceItem(list2.getItem(3), 0).value, 50);
+ assert_equals(list2.numberOfItems, 4);
+ assert_equals(list2.getItem(0).value, 50);
+ assert_equals(list2.getItem(1).value, 100);
+ assert_equals(list2.getItem(2).value, 150);
+ assert_equals(list2.getItem(3).value, 50);
+
+ // Check initial list state of text3.
+ assert_equals(list3.numberOfItems, 5);
+ assert_equals(list3.getItem(0).value, 50);
+ assert_equals(list3.getItem(1).value, 50);
+ assert_equals(list3.getItem(2).value, 100);
+ assert_equals(list3.getItem(3).value, 100);
+ assert_equals(list3.getItem(4).value, 150);
+ assert_throws("IndexSizeError", function() { list3.getItem(5); });
+
+ // Check initial list state of text4.
+ assert_equals(list4.numberOfItems, 4);
+ assert_equals(list4.getItem(0).value, 100);
+ assert_equals(list4.getItem(1).value, 50);
+ assert_equals(list4.getItem(2).value, 150);
+ assert_equals(list4.getItem(3).value, 150);
+ assert_throws("IndexSizeError", function() { list4.getItem(4); });
+
+ // Replace the first item in text4 x list with the second item in the text3 x list.
+ assert_equals(list4.replaceItem(list3.getItem(1), 0).value, 50);
+ assert_equals(list3.numberOfItems, 5);
+ assert_equals(list3.getItem(0).value, 50);
+ assert_equals(list3.getItem(1).value, 50);
+ assert_equals(list3.getItem(2).value, 100);
+ assert_equals(list3.getItem(3).value, 100);
+ assert_equals(list3.getItem(4).value, 150);
+ assert_throws("IndexSizeError", function() { list3.getItem(5); });
+ assert_equals(list4.numberOfItems, 4);
+ assert_equals(list4.getItem(0).value, 50);
+ assert_equals(list4.getItem(1).value, 50);
+ assert_equals(list4.getItem(2).value, 150);
+ assert_equals(list4.getItem(3).value, 150);
+ assert_throws("IndexSizeError", function() { list4.getItem(4); });
+
+ // Replace the second item in text4 x list with the second item in the text4 x list.
fs 2016/09/17 17:42:37 ...with the third item in the text3 x list. ?
Shanmuga Pandi 2016/09/19 07:40:04 Done.
+ assert_equals(list4.replaceItem(list3.getItem(2), 1).value, 100);
+ assert_equals(list4.numberOfItems, 4);
+ assert_equals(list4.getItem(0).value, 50);
+ assert_equals(list4.getItem(1).value, 100);
+ assert_equals(list4.getItem(2).value, 150);
+ assert_equals(list4.getItem(3).value, 150);
+ assert_throws("IndexSizeError", function() { list4.getItem(4); });
+
+ // Replace the items of text3 x list with the same text3 x list.
+ assert_equals(list3.replaceItem(list3.getItem(2), 1).value, 100);
+ assert_equals(list3.replaceItem(list3.getItem(4), 2).value, 150);
+ assert_equals(list3.numberOfItems, 5);
+ assert_equals(list3.getItem(0).value, 50);
+ assert_equals(list3.getItem(1).value, 100);
+ assert_equals(list3.getItem(2).value, 150);
+ assert_equals(list3.getItem(3).value, 100);
+ assert_equals(list3.getItem(4).value, 150);
+ assert_throws("IndexSizeError", function() { list3.getItem(5); });
+
+ // Check final list state of text1.
+ assert_equals(list1.numberOfItems, 3);
+ assert_equals(list1.getItem(0).value, 50);
+ assert_equals(list1.getItem(1).value, 100);
+ assert_equals(list1.getItem(2).value, 150);
+ assert_throws("IndexSizeError", function() { list1.getItem(3); });
+
+ // Check final list state of text2.
+ assert_equals(list2.numberOfItems, 4);
+ assert_equals(list2.getItem(0).value, 50);
+ assert_equals(list2.getItem(1).value, 100);
+ assert_equals(list2.getItem(2).value, 150);
+ assert_equals(list2.getItem(3).value, 50);
+ assert_throws("IndexSizeError", function() { list2.getItem(4); });
+
+ // Check final list state of text3.
+ assert_equals(list3.numberOfItems, 5);
+ assert_equals(list3.getItem(0).value, 50);
+ assert_equals(list3.getItem(1).value, 100);
+ assert_equals(list3.getItem(2).value, 150);
+ assert_equals(list3.getItem(3).value, 100);
+ assert_equals(list3.getItem(4).value, 150);
+ assert_throws("IndexSizeError", function() { list3.getItem(5); });
+
+ // Check final list state of text4.
+ assert_equals(list4.numberOfItems, 4);
+ assert_equals(list4.getItem(0).value, 50);
+ assert_equals(list4.getItem(1).value, 100);
+ assert_equals(list4.getItem(2).value, 150);
+ assert_equals(list4.getItem(3).value, 150);
+ assert_throws("IndexSizeError", function() { list4.getItem(4); });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698