OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <div class="one">Line 1<div class="two">Line 2</div><p>Line <i>3</i></p></div> | 3 <div class="one">Line 1<div class="two">Line 2</div><p>Line <i>3</i></p></div> |
4 <div id="test" class="one two"><div class="one two">line 4</div><p class="two">l
ine 5</p></div> | 4 <div id="test" class="one two"><div class="one two">line 4</div><p class="two">l
ine 5</p></div> |
5 <p><ol id="console"></ol></p> | 5 <p><ol id="console"></ol></p> |
6 <script type="text/javascript"> | 6 <script type="text/javascript"> |
7 if (window.testRunner) | 7 if (window.testRunner) |
8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
9 | 9 |
10 function log(message) | 10 function log(message) |
11 { | 11 { |
12 var item = document.createElement("li"); | 12 var item = document.createElement("li"); |
13 item.appendChild(document.createTextNode(message)); | 13 item.appendChild(document.createTextNode(message)); |
14 document.getElementById("console").appendChild(item); | 14 document.getElementById("console").appendChild(item); |
15 } | 15 } |
16 | 16 |
17 NodeList.prototype.dump = function() | 17 HTMLCollection.prototype.dump = function() |
18 { | 18 { |
19 var result = ""; | 19 var result = ""; |
20 var i = 0; | 20 var i = 0; |
21 for (; i < this.length; i++) | 21 for (; i < this.length; i++) |
22 result += this[i] + ", "; | 22 result += this[i] + ", "; |
23 result += "length: " + i; | 23 result += "length: " + i; |
24 return result; | 24 return result; |
25 } | 25 } |
26 | 26 |
27 try { | 27 try { |
(...skipping 15 matching lines...) Expand all Loading... |
43 log(elm.getElementsByClassName("").dump()); | 43 log(elm.getElementsByClassName("").dump()); |
44 log(elm.getElementsByClassName("onetwo").dump()); | 44 log(elm.getElementsByClassName("onetwo").dump()); |
45 log(elm.getElementsByClassName(null).dump()); | 45 log(elm.getElementsByClassName(null).dump()); |
46 log(elm.getElementsByClassName(undefined).dump()); | 46 log(elm.getElementsByClassName(undefined).dump()); |
47 } catch (ex) { | 47 } catch (ex) { |
48 log("Exception: " + ex.description); | 48 log("Exception: " + ex.description); |
49 } | 49 } |
50 </script> | 50 </script> |
51 </body> | 51 </body> |
52 </html> | 52 </html> |
OLD | NEW |