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

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

Issue 2344403002: 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 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <script>window.enablePixelTesting = true;</script>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
8 <text id="text1" x="500 1000 1500" y="25"> ABC </text>
9 <text id="text2" x="50 500" y="50"> ABC </text>
10 <text id="text3" x="50 500 50" y="75">ABC</text>
11 <text id="text4" x="500" y="100">ABC</text>
12 <text id="reference" x="50" y="125">ABC</text>
13 </svg>
14
15 <p id="description"></p>
16 <div id="console"></div>
17 <script type="text/javascript">
18 <![CDATA[
19 description("This is a test of the SVGLengthList::initialize() API.");
20
21 var svg = document.getElementById("svg");
22 var text1 = document.getElementById("text1");
23 var text2 = document.getElementById("text2");
24 var text3 = document.getElementById("text3");
25 var text4 = document.getElementById("text4");
26
27 debug("Check initial list state of text1");
28 shouldBe("text1.x.baseVal.numberOfItems", "3");
29 shouldBe("text1.x.baseVal.getItem(0).value", "500");
30 shouldBe("text1.x.baseVal.getItem(1).value", "1000");
31 shouldBe("text1.x.baseVal.getItem(2).value", "1500");
32 shouldThrow("text1.x.baseVal.getItem(3)");
33
34 debug("");
35 debug("Check initial list state of text2");
36 shouldBe("text2.x.baseVal.numberOfItems", "2");
37 shouldBe("text2.x.baseVal.getItem(0).value", "50");
38 shouldBe("text2.x.baseVal.getItem(1).value", "500");
39 shouldThrow("text2.x.baseVal.getItem(2)");
40
41 debug("");
42 debug("Check initial list state of text3");
43 shouldBe("text3.x.baseVal.numberOfItems", "3");
44 shouldBe("text3.x.baseVal.getItem(0).value", "50");
45 shouldBe("text3.x.baseVal.getItem(1).value", "500");
46 shouldBe("text3.x.baseVal.getItem(2).value", "50");
47 shouldThrow("text3.x.baseVal.getItem(3)");
48
49 debug("");
50 debug("Check initial list state of text4");
51 shouldBe("text4.x.baseVal.numberOfItems", "1");
52 shouldBe("text4.x.baseVal.getItem(0).value", "500");
53 shouldThrow("text4.x.baseVal.getItem(1)");
54
55 debug("");
56 debug("Create a new SVGLength object, that will be the only x coordinate in the first text element.");
57 var newLength = svg.createSVGLength();
58 newLength.value = 50;
59 shouldBe("newLength.value", "50");
60
61 // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
62 debug("");
63 debug("Initialize SVGLengthList with 'newLength'");
64 shouldBe("text1.x.baseVal.initialize(newLength)", "newLength");
65 shouldBe("text1.x.baseVal.getItem(0)", "newLength");
66
67 debug("");
68 debug("Take the second x item '500' of the second text element, store it in 'itemInAnotherList' change it to '50'");
69 shouldBe("text2.x.baseVal.getItem(1).value", "500");
70 var itemInAnotherList = text2.x.baseVal.getItem(1);
71 itemInAnotherList.value = 50;
72 shouldBe("text2.x.baseVal.getItem(1).value", "50");
73
74 // 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.
75 // Otherwise, newItem itself is inserted into the list..
76 debug("");
77 debug("Override the third text elements x list with the item x=50 from the s econd text element, where it should not be removed afterwards");
78 shouldBe("text3.x.baseVal.initialize(itemInAnotherList)", "itemInAnotherList ");
79 shouldBe("text3.x.baseVal.getItem(0).value", "50");
80 shouldBe("text2.x.baseVal.getItem(0).value", "50");
81 shouldNotThrow("text2.x.baseVal.getItem(1)");
82
83 debug("")
84 debug("Assure that the 'itemInAnotherList' item is still live anymore, set v alue to 999 then back to 50");
85 shouldBe("itemInAnotherList.value = 999;", "999");
86 shouldBe("itemInAnotherList.value", "999");
87 shouldBe("text3.x.baseVal.getItem(0).value", "50");
88 shouldBe("itemInAnotherList.value = 50;", "50");
89 shouldBe("itemInAnotherList.value", "50");
90 shouldBe("text3.x.baseVal.getItem(0).value", "50");
91
92 debug("");
93 debug("Copy item from text3 to text4");
94 shouldBe("text4.x.baseVal.initialize(text3.x.baseVal.getItem(0))", "itemInAn otherList");
95 shouldBe("text4.x.baseVal.getItem(0).value", "50");
96 shouldNotThrow("text3.x.baseVal.getItem(0)");
97
98 debug("");
99 debug("Initialize text2 using setAttribute('x', '50')");
100 text2.setAttribute("x", "50");
101 shouldBe("text2.x.baseVal.getItem(0).value", "50");
102
103 debug("");
104 debug("Final check whether the lists all look like expected");
105 shouldBe("text1.x.baseVal.getItem(0).value", "50");
106 shouldBe("text2.x.baseVal.getItem(0).value", "50");
107 shouldBe("text3.x.baseVal.getItem(0).value", "50");
108 shouldBe("text4.x.baseVal.getItem(0).value", "50");
109 shouldBe("text1.x.baseVal.numberOfItems", "1");
110 shouldBe("text2.x.baseVal.numberOfItems", "1");
111 shouldBe("text3.x.baseVal.numberOfItems", "1");
112 shouldBe("text4.x.baseVal.numberOfItems", "1");
113 shouldThrow("text1.x.baseVal.getItem(1)");
114 shouldThrow("text2.x.baseVal.getItem(1)");
115 shouldThrow("text3.x.baseVal.getItem(1)");
116 shouldThrow("text4.x.baseVal.getItem(1)");
117
118 debug("");
119 debug("The test passes if you only see 'PASS' messages, and all five text el ements on top look the same");
120 debug("");
121
122 ]]>
123 </script>
124 </body>
125 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698