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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-appendItem.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-appendItem.html b/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-appendItem.html
new file mode 100644
index 0000000000000000000000000000000000000000..b5f7176f8cb1be98ad231b39857a5eff5e157898
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-appendItem.html
@@ -0,0 +1,118 @@
+<!DOCTYPE HTML>
+<title>SVGLengthList, appendItem()</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<svg width="200" height="200">
+ <text id="text1" x="500 50 100 900 1000" y="50">ABC</text>
+ <text id="text2" x="50 100 1000" y="100">ABC</text>
+</svg>
+<script>
+test(function() {
+ // This is a test of the SVGLengthList::appendItem() API.
+ var svg = document.querySelector("svg");
+ var list1 = document.getElementById("text1").x.baseVal;
+ var list2 = document.getElementById("text2").x.baseVal;
+
+ // Create a new SVGLength object, with value=150.
+ var newLength1 = svg.createSVGLength();
+ newLength1.value = 150;
+ assert_equals(newLength1.value, 150);
+
+ // Check initial list state of text1.
+ assert_equals(list1.numberOfItems, 5);
+ assert_equals(list1.getItem(0).value, 500);
+ assert_equals(list1.getItem(1).value, 50);
+ assert_equals(list1.getItem(2).value, 100);
+ assert_equals(list1.getItem(3).value, 900);
+ assert_equals(list1.getItem(4).value, 1000);
+ assert_throws("IndexSizeError", function() { list1.getItem(5); });
+
+ // Check initial list state of text2.
+ assert_equals(list2.numberOfItems, 3);
+ assert_equals(list2.getItem(0).value, 50);
+ assert_equals(list2.getItem(1).value, 100);
+ assert_equals(list2.getItem(2).value, 1000);
+ assert_throws("IndexSizeError", function() { list2.getItem(3); });
+
+ // Append fourth item x=900 to the text1 x list.
+ assert_equals(list1.appendItem(list1.getItem(3)).value, list1.getItem(5).value);
+ assert_equals(list1.numberOfItems, 6);
+ assert_equals(list1.getItem(0).value, 500);
+ assert_equals(list1.getItem(1).value, 50);
+ assert_equals(list1.getItem(2).value, 100);
+ assert_equals(list1.getItem(3).value, 900);
+ assert_equals(list1.getItem(4).value, 1000);
+ assert_equals(list1.getItem(5).value, 900);
+ assert_throws("IndexSizeError", function() { list1.getItem(6); });
+
+ // Append first item x=500 to the text1 x list.
+ assert_equals(list1.appendItem(list1.getItem(0)).value, list1.getItem(6).value);
+ assert_equals(list1.numberOfItems, 7);
+ assert_equals(list1.getItem(0).value, 500);
+ assert_equals(list1.getItem(1).value, 50);
+ assert_equals(list1.getItem(2).value, 100);
+ assert_equals(list1.getItem(3).value, 900);
+ assert_equals(list1.getItem(4).value, 1000);
+ assert_equals(list1.getItem(5).value, 900);
+ assert_equals(list1.getItem(6).value, 500);
+ assert_throws("IndexSizeError", function() { list1.getItem(7); });
+
+ // Append 'newLength1' to the text1 x list.
+ assert_equals(list1.appendItem(newLength1).value, list1.getItem(7).value);
+ assert_equals(list1.numberOfItems, 8);
+ assert_equals(list1.getItem(0).value, 500);
+ assert_equals(list1.getItem(1).value, 50);
+ assert_equals(list1.getItem(2).value, 100);
+ assert_equals(list1.getItem(3).value, 900);
+ assert_equals(list1.getItem(4).value, 1000);
+ assert_equals(list1.getItem(5).value, 900);
+ assert_equals(list1.getItem(6).value, 500);
+ assert_equals(list1.getItem(7).value, 150);
+ assert_throws("IndexSizeError", function() { list1.getItem(8); });
+
+ // Append third and fourth item of the text1 x list to the text2 x list.
+ assert_equals(list2.appendItem(list1.getItem(2)).value, 100);
+ assert_equals(list2.appendItem(list1.getItem(3)).value, 900);
+ assert_equals(list1.numberOfItems, 8);
+ assert_equals(list1.getItem(0).value, 500);
+ assert_equals(list1.getItem(1).value, 50);
+ assert_equals(list1.getItem(2).value, 100);
+ assert_equals(list1.getItem(3).value, 900);
+ assert_equals(list1.getItem(4).value, 1000);
+ assert_equals(list1.getItem(5).value, 900);
+ assert_equals(list1.getItem(6).value, 500);
+ assert_equals(list1.getItem(7).value, 150);
+ assert_throws("IndexSizeError", function() { list1.getItem(8); });
+ assert_equals(list2.numberOfItems, 5);
+ assert_equals(list2.getItem(0).value, 50);
+ assert_equals(list2.getItem(1).value, 100);
+ assert_equals(list2.getItem(2).value, 1000);
+ assert_equals(list2.getItem(3).value, 100);
+ assert_equals(list2.getItem(4).value, 900);
+ assert_throws("IndexSizeError", function() { list2.getItem(5); });
+
+ var newLength2 = svg.createSVGLength();
+ newLength2.value = 150;
+ assert_equals(newLength2.value, 150);
+ list1.clear();
+
+ // Shuffle around items in text1 and text2 list using appendItem, to get x=50,100,150,... in both lists.
+ assert_equals(list1.appendItem(list2.getItem(0)).value, 50);
+ assert_equals(list1.appendItem(list2.getItem(1)).value, 100);
+ assert_equals(list1.appendItem(newLength2).value, 150);
+ list2.clear();
+ assert_equals(list2.appendItem(list1.getItem(0)).value, 50);
+ assert_equals(list2.appendItem(list1.getItem(1)).value, 100);
+ assert_equals(list2.appendItem(list1.getItem(2)).value, 150);
+ 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(4); });
+ assert_equals(list2.numberOfItems, 3);
+ assert_equals(list2.getItem(0).value, 50);
+ assert_equals(list2.getItem(1).value, 100);
+ assert_equals(list2.getItem(2).value, 150);
+ assert_throws("IndexSizeError", function() { list2.getItem(6); });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698