1 <html> 2 <body> 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">line 5</p></div> 5 <p><ol id="console"></ol></p> 6 <script type="text/javascript"> 7 if (window.layoutTestController) 8 layoutTestController.dumpAsText(); 9 10 function log(message) 11 { 12 var item = document.createElement("li"); 13 item.appendChild(document.createTextNode(message)); 14 document.getElementById("console").appendChild(item); 15 } 16 17 NodeList.prototype.dump = function() 18 { 19 var result = ""; 20 var i = 0; 21 for (; i < this.length; i++) 22 result += this[i] + ", "; 23 result += "length: " + i; 24 return result; 25 } 26 27 try { 28 var elm = document.getElementById("test"); 29 30 log(document.getElementsByClassName("one").dump()); 31 log(document.getElementsByClassName("two").dump()); 32 log(document.getElementsByClassName("one two").dump()); 33 log(document.getElementsByClassName("one\t\t\n \ftwo").dump()); 34 log(document.getElementsByClassName("").dump()); 35 log(document.getElementsByClassName("onetwo").dump()); 36 log(document.getElementsByClassName().dump()); 37 log(document.getElementsByClassName(null).dump()); 38 log(document.getElementsByClassName(undefined).dump()); 39 40 log(elm.getElementsByClassName("one").dump()); 41 log(elm.getElementsByClassName("two").dump()); 42 log(elm.getElementsByClassName("one two").dump()); 43 log(elm.getElementsByClassName("one\t\t\n \ftwo").dump()); 44 log(elm.getElementsByClassName("").dump()); 45 log(elm.getElementsByClassName("onetwo").dump()); 46 log(elm.getElementsByClassName().dump()); 47 log(elm.getElementsByClassName(null).dump()); 48 log(elm.getElementsByClassName(undefined).dump()); 49 } catch (ex) { 50 log("Exception: " + ex.description); 51 } 52 </script> 53 </body> 54 </html> 55