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

Side by Side Diff: LayoutTests/fast/dom/Attr/change-id-via-attr-node-value.html

Issue 1158433004: Remove Attr child nodes (making Attr a Node, not a ContainerNode) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address feedback Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body id="a"> 6 <body id="a">
7 <script> 7 <script>
8 8
9 description("Test that different ways of changing an element's id all work prope rly."); 9 description("Test that different ways of changing an element's id all work prope rly.");
10 10
(...skipping 28 matching lines...) Expand all
39 39
40 var attrNode = document.body.getAttributeNode("id"); 40 var attrNode = document.body.getAttributeNode("id");
41 41
42 debug("\n6. Change Attr.nodeValue."); 42 debug("\n6. Change Attr.nodeValue.");
43 document.body.getAttributeNode("id").nodeValue = "f"; 43 document.body.getAttributeNode("id").nodeValue = "f";
44 shouldBe('document.getElementById("e")', 'null'); 44 shouldBe('document.getElementById("e")', 'null');
45 shouldBe('document.getElementById("f")', 'document.body'); 45 shouldBe('document.getElementById("f")', 'document.body');
46 shouldBe('document.body.id', '"f"'); 46 shouldBe('document.body.id', '"f"');
47 shouldBe('document.body.getAttribute("id")', '"f"'); 47 shouldBe('document.body.getAttribute("id")', '"f"');
48 shouldBe('attrNode.value', '"f"'); 48 shouldBe('attrNode.value', '"f"');
49 shouldBe('attrNode.childNodes.length', '1');
50
51 // Firefox doesn't support these for Attr nodes.
52 debug("\n7. Attr.replaceChild().");
53 try {
54 attrNode.replaceChild(document.createTextNode("g"), attrNode.firstChild);
55 shouldBe('document.getElementById("f")', 'null');
56 shouldBe('document.getElementById("g")', 'document.body');
57 shouldBe('document.body.id', '"g"');
58 shouldBe('document.body.getAttribute("id")', '"g"');
59 shouldBe('attrNode.value', '"g"');
60 shouldBe('attrNode.childNodes.length', '1');
61 } catch (ex) {
62 debug(ex);
63 }
64
65 debug("\n8. Attr.insertBefore().");
66 try {
67 attrNode.insertBefore(document.createTextNode("0"), attrNode.firstChild);
68 shouldBe('document.getElementById("g")', 'null');
69 shouldBe('document.getElementById("0g")', 'document.body');
70 shouldBe('document.body.id', '"0g"');
71 shouldBe('document.body.getAttribute("id")', '"0g"');
72 shouldBe('attrNode.value', '"0g"');
73 shouldBe('attrNode.childNodes.length', '2');
74 } catch (ex) {
75 debug(ex);
76 }
77
78 debug("\n9. attr.appendChild().");
79 try {
80 attrNode.appendChild(document.createTextNode("2"));
81 shouldBe('document.getElementById("0g")', 'null');
82 shouldBe('document.getElementById("0g2")', 'document.body');
83 shouldBe('document.body.id', '"0g2"');
84 shouldBe('document.body.getAttribute("id")', '"0g2"');
85 shouldBe('attrNode.value', '"0g2"');
86 shouldBe('attrNode.childNodes.length', '3');
87 } catch (ex) {
88 debug(ex);
89 }
90
91 debug("\n10. Attr.removeChild()");
92 attrNode.nodeValue = "h";
93 attrNode.removeChild(attrNode.firstChild);
94 shouldBe('document.body.getAttributeNode("id").childNodes.length', '0');
95 shouldBe('document.getElementById("h")', 'null');
96 shouldBe('document.getElementById("")', 'null');
97 shouldBe('document.body.id', '""');
98 shouldBe('document.body.getAttribute("id")', '""');
99 shouldBe('document.body.getAttributeNode("id").value', '""');
100
101 debug("\n11. Changing Text.nodeValue.");
102 attrNode.nodeValue = "h";
103 attrNode.firstChild.nodeValue = "i";
104 shouldBe('attrNode.firstChild.nodeValue', '"i"');
105 shouldBe('document.getElementById("i")', 'document.body');
106 shouldBe('document.body.id', '"i"');
107 shouldBe('document.body.getAttribute("id")', '"i"');
108 shouldBe('attrNode.value', '"i"');
109 shouldBe('attrNode.childNodes.length', '1');
110 49
111 debug("\n12. Chnaging Attr.value."); 50 debug("\n12. Chnaging Attr.value.");
112 attrNode.value = "hi"; 51 attrNode.value = "hi";
113 shouldBe('document.getElementById("i")', 'null'); 52 shouldBe('document.getElementById("i")', 'null');
114 shouldBe('document.getElementById("hi")', 'document.body'); 53 shouldBe('document.getElementById("hi")', 'document.body');
115 shouldBe('document.body.id', '"hi"'); 54 shouldBe('document.body.id', '"hi"');
116 shouldBe('document.body.getAttribute("id")', '"hi"'); 55 shouldBe('document.body.getAttribute("id")', '"hi"');
117 shouldBe('attrNode.value', '"hi"'); 56 shouldBe('attrNode.value', '"hi"');
118 shouldBe('attrNode.childNodes.length', '1');
119
120 debug("\n13. Text.splitText().");
121 attrNode.firstChild.splitText(1);
122 shouldBe('document.getElementById("hi")', 'document.body');
123 shouldBe('document.body.id', '"hi"');
124 shouldBe('document.body.getAttribute("id")', '"hi"');
125 shouldBe('document.body.getAttributeNode("id").value', '"hi"');
126 shouldBe('document.body.getAttributeNode("id").childNodes.length', '2');
127
128 debug("\n14. Node.normalize(), joining text nodes.");
129 attrNode.normalize();
130 shouldBe('document.getElementById("hi")', 'document.body');
131 shouldBe('document.body.id', '"hi"');
132 shouldBe('document.body.getAttribute("id")', '"hi"');
133 shouldBe('document.body.getAttributeNode("id").value', '"hi"');
134 shouldBe('document.body.getAttributeNode("id").childNodes.length', '1');
135
136 debug("\n15. Changing Attr.nodeValue.");
137 attrNode.nodeValue = "foo";
138 attrNode.firstChild.data = "j";
139 shouldBe('document.getElementById("hi")', 'null');
140 shouldBe('document.getElementById("j")', 'document.body');
141 shouldBe('document.body.id', '"j"');
142 shouldBe('document.body.getAttribute("id")', '"j"');
143 shouldBe('attrNode.value', '"j"');
144 shouldBe('attrNode.childNodes.length', '1');
145
146 debug("\n16. Changing Text.data.");
147 attrNode.firstChild.data = "k";
148 shouldBe('document.getElementById("j")', 'null');
149 shouldBe('document.getElementById("k")', 'document.body');
150 shouldBe('document.body.id', '"k"');
151 shouldBe('document.body.getAttribute("id")', '"k"');
152 shouldBe('attrNode.value', '"k"');
153 shouldBe('attrNode.childNodes.length', '1');
154
155 debug("\n17. Changing text child with appendData().");
156 attrNode.firstChild.appendData("l");
157 shouldBe('document.getElementById("k")', 'null');
158 shouldBe('document.getElementById("kl")', 'document.body');
159 shouldBe('document.body.id', '"kl"');
160 shouldBe('document.body.getAttribute("id")', '"kl"');
161 shouldBe('attrNode.value', '"kl"');
162 shouldBe('attrNode.childNodes.length', '1');
163
164 debug("\n18. Changing text child with insertData().");
165 attrNode.firstChild.insertData(1, "1");
166 shouldBe('document.getElementById("kl")', 'null');
167 shouldBe('document.getElementById("k1l")', 'document.body');
168 shouldBe('document.body.id', '"k1l"');
169 shouldBe('document.body.getAttribute("id")', '"k1l"');
170 shouldBe('attrNode.value', '"k1l"');
171 shouldBe('attrNode.childNodes.length', '1');
172
173 debug("\n19. Changing text child with deleteData().");
174 attrNode.firstChild.deleteData(0, 2);
175 shouldBe('document.getElementById("k1l")', 'null');
176 shouldBe('document.getElementById("l")', 'document.body');
177 shouldBe('document.body.id', '"l"');
178 shouldBe('document.body.getAttribute("id")', '"l"');
179 shouldBe('attrNode.value', '"l"');
180 shouldBe('attrNode.childNodes.length', '1');
181
182 debug("\n20. Changing text child with replaceData().");
183 attrNode.firstChild.replaceData(0, 1, "mn");
184 shouldBe('document.getElementById("l")', 'null');
185 shouldBe('document.getElementById("mn")', 'document.body');
186 shouldBe('document.body.id', '"mn"');
187 shouldBe('document.body.getAttribute("id")', '"mn"');
188 shouldBe('attrNode.value', '"mn"');
189 shouldBe('attrNode.childNodes.length', '1');
190 57
191 debug("\n21. Remove an Attr node."); 58 debug("\n21. Remove an Attr node.");
192 document.body.removeAttributeNode(attrNode); 59 document.body.removeAttributeNode(attrNode);
193 shouldBe('document.body.id', '""'); 60 shouldBe('document.body.id', '""');
194 shouldBe('document.getElementById("mn")', 'null'); 61 shouldBe('document.getElementById("mn")', 'null');
195 shouldBe('document.body.getAttribute("id")', 'null'); 62 shouldBe('document.body.getAttribute("id")', 'null');
196 shouldBe('document.body.getAttributeNode("id")', 'null'); 63 shouldBe('document.body.getAttributeNode("id")', 'null');
197 64
198 debug("\n22. Add an Attr node."); 65 debug("\n22. Add an Attr node.");
199 var attrNode = document.createAttribute("id"); 66 var attrNode = document.createAttribute("id");
200 attrNode.value = "o"; 67 attrNode.value = "o";
201 document.body.setAttributeNode(attrNode); 68 document.body.setAttributeNode(attrNode);
202 shouldBe('document.getElementById("o")', 'document.body'); 69 shouldBe('document.getElementById("o")', 'document.body');
203 shouldBe('document.body.id', '"o"'); 70 shouldBe('document.body.id', '"o"');
204 shouldBe('document.body.getAttribute("id")', '"o"'); 71 shouldBe('document.body.getAttribute("id")', '"o"');
205 72
206 debug("\n23. Add an Attr node over an existing one."); 73 debug("\n23. Add an Attr node over an existing one.");
207 var attrNode = document.createAttribute("id"); 74 var attrNode = document.createAttribute("id");
208 attrNode.value = "p"; 75 attrNode.value = "p";
209 document.body.setAttributeNode(attrNode); 76 document.body.setAttributeNode(attrNode);
210 shouldBe('document.getElementById("o")', 'null'); 77 shouldBe('document.getElementById("o")', 'null');
211 shouldBe('document.getElementById("p")', 'document.body'); 78 shouldBe('document.getElementById("p")', 'document.body');
212 shouldBe('document.body.id', '"p"'); 79 shouldBe('document.body.id', '"p"');
213 shouldBe('document.body.getAttribute("id")', '"p"'); 80 shouldBe('document.body.getAttribute("id")', '"p"');
214 </script> 81 </script>
215 </body> 82 </body>
216 </html> 83 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698