<html>
<body>
<div class="one">Line 1<div class="two">Line 2</div><p>Line <i>3</i></p></div>
<div id="test" class="one two"><div class="one two">line 4</div><p class="two">line 5</p></div>
<p><ol id="console"></ol></p>
<script type="text/javascript">
    if (window.testRunner)
        testRunner.dumpAsText();

    function log(message)
    {
        var item = document.createElement("li");
        item.appendChild(document.createTextNode(message));
        document.getElementById("console").appendChild(item);
    }
    
    HTMLCollection.prototype.dump = function()
    {
        var result = "";
        var i = 0;
        for (; i < this.length; i++)
            result += this[i] + ", ";
        result += "length: " + i;
        return result;
    }

    try {
        var elm = document.getElementById("test");

        log(document.getElementsByClassName("one").dump());
        log(document.getElementsByClassName("two").dump());
        log(document.getElementsByClassName("one two").dump());
        log(document.getElementsByClassName("one\t\t\n \ftwo").dump());
        log(document.getElementsByClassName("").dump());
        log(document.getElementsByClassName("onetwo").dump());
        log(document.getElementsByClassName(null).dump());
        log(document.getElementsByClassName(undefined).dump());

        log(elm.getElementsByClassName("one").dump());
        log(elm.getElementsByClassName("two").dump());
        log(elm.getElementsByClassName("one two").dump());
        log(elm.getElementsByClassName("one\t\t\n \ftwo").dump());
        log(elm.getElementsByClassName("").dump());
        log(elm.getElementsByClassName("onetwo").dump());
        log(elm.getElementsByClassName(null).dump());
        log(elm.getElementsByClassName(undefined).dump());
    } catch (ex) {
        log("Exception: " + ex.description);
    }
</script>
</body>
</html>
