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

Unified Diff: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-insertItemBefore.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-insertItemBefore.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-insertItemBefore.html b/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-insertItemBefore.html
new file mode 100644
index 0000000000000000000000000000000000000000..b93799011570d0548298fd79f7bc5c542f1f1480
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-insertItemBefore.html
@@ -0,0 +1,115 @@
+<!DOCTYPE HTML>
+<title>SVGLengthList, insertItemBefore()</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<svg width="200" height="200">
+ <text x="500 1000 1500" y="50"> ABC </text>
+</svg>
+<script>
+test(function() {
+ // This is a test of the SVGLengthList::insertItemBefore() API.
+
+ var svg = document.querySelector("svg");
+ var list = document.querySelector("text").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);
+
+ assert_equals(newLength1 != newLength2, true);
Srirama 2016/09/17 11:27:52 use assert_not_equals here and below.
Shanmuga Pandi 2016/09/17 12:29:33 Done.
+ assert_equals(newLength2 != newLength3, true);
+ assert_equals(newLength3 != newLength1, true);
+ assert_equals(newLength1.value == newLength2.value - 50, true);
Srirama 2016/09/17 11:27:52 assert_equals(newLength1.value, newLength2.value -
Shanmuga Pandi 2016/09/17 12:29:33 Done.
+ assert_equals(newLength2.value + 50 == newLength3.value, true);
Srirama 2016/09/17 11:27:52 modify this as well.
Shanmuga Pandi 2016/09/17 12:29:33 Done.
+
+ // Check initial list state");
+ assert_equals(list.numberOfItems, 3);
+ assert_equals(list.getItem(0).value, 500);
+ assert_equals(list.getItem(1).value, 1000);
+ assert_equals(list.getItem(2).value, 1500);
+ assert_throws("IndexSizeError", function() { list.getItem(3); });
+
+ // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.
+ // Insert item 'newLength1' at the end of the list, by using a large index.
+ assert_equals(list.insertItemBefore(newLength1, 1000).value, newLength1.value);
+ assert_equals(list.numberOfItems, 4);
+ assert_equals(list.getItem(0).value, 500);
+ assert_equals(list.getItem(1).value, 1000);
+ assert_equals(list.getItem(2).value, 1500);
+ assert_equals(list.getItem(3).value, 50);
+ assert_throws("IndexSizeError", function() { list.getItem(4); });
+
+ // Storing getItem(0/1/2) in local variables.
+ var item0 = list.getItem(0);
+ var item1 = list.getItem(1);
+ var item2 = list.getItem(2);
+ var item3 = list.getItem(3);
+
+ // Spec: If the index is equal to 0, then the new item is inserted at the front of the list.
+ // Insert item 'newLength2' at the front of the list, by using index=0".
+ assert_equals(list.insertItemBefore(newLength2, 0).value, newLength2.value);
+ assert_equals(list.numberOfItems, 5);
+ assert_equals(list.getItem(0).value, 100);
+ assert_equals(list.getItem(1).value, 500);
+ assert_equals(list.getItem(2).value, 1000);
+ assert_equals(list.getItem(3).value, 1500);
+ assert_equals(list.getItem(4).value, 50);
+ assert_throws("IndexSizeError", function() { list.getItem(5); });
+
+ // Assure that previously saved wrappers still show the old values.
+ assert_equals(item0.value, 500);
+ assert_equals(item1.value, 1000);
+ assert_equals(item2.value, 1500);
+ assert_equals(item3.value, 50);
+
+ // Spec: The index of the item before which the new item is to be inserted.
+
+ // Insert item 'newLength3' at position=2, between '500' and '1000'.
+ assert_equals(list.insertItemBefore(newLength3, 2).value, newLength3.value);
+ assert_equals(list.numberOfItems, 6);
+ assert_equals(list.getItem(0).value, 100);
+ assert_equals(list.getItem(1).value, 500);
+ assert_equals(list.getItem(2).value, 150);
+ assert_equals(list.getItem(3).value, 1000);
+ assert_equals(list.getItem(4).value, 1500);
+ assert_equals(list.getItem(5).value, 50);
+ assert_throws("IndexSizeError", function() { list.getItem(6); });
+
+ // 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.
+
+ // Insert item 'newLength3' at position=1, between '100' and '500', should not remove it from the old position=2 afterwards.");
+ assert_equals(list.insertItemBefore(newLength3, 1).value, newLength3.value);
+ assert_equals(list.numberOfItems, 7);
+ assert_equals(list.getItem(0).value, 100);
+ assert_equals(list.getItem(1).value, 150);
+ assert_equals(list.getItem(2).value, 500);
+ assert_equals(list.getItem(3).value, 150);
+ assert_equals(list.getItem(4).value, 1000);
+ assert_equals(list.getItem(5).value, 1500);
+ assert_equals(list.getItem(6).value, 50);
+ assert_throws("IndexSizeError", function() { list.getItem(7); });
+
+ // Insert item 'newLength1' at position=0, before '100', should not remove it from the old position=6 afterwards.
+ assert_equals(list.insertItemBefore(newLength1, 0).value, newLength1.value);
+ assert_equals(list.numberOfItems, 8);
+ assert_equals(list.getItem(0).value, 50);
+ assert_equals(list.getItem(1).value, 100);
+ assert_equals(list.getItem(2).value, 150);
+ assert_equals(list.getItem(3).value, 500);
+ assert_equals(list.getItem(4).value, 150);
+ assert_equals(list.getItem(5).value, 1000);
+ assert_equals(list.getItem(6).value, 1500);
+ assert_equals(list.getItem(7).value, 50);
+ assert_throws("IndexSizeError", function() { list.getItem(8); });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698