<html>
<head>
<script>

function print(message, color) {
    var paragraph = document.createElement("p");
    if (color)
        paragraph.style.color = color;
    paragraph.appendChild(document.createTextNode(message));
    document.getElementById("console").appendChild(paragraph);
}

function printPrototypes(e)
{
    var a = new Array();
    for (p = e.__proto__; p != null; p = p.__proto__) {
        a.push(p);
    }
    
    print("----- " + e + " (" + a.length + " prototypes) -----", "blue");
    // Print back-to-front so the root of the chain comes out on top
    for (var i = a.length - 1; i >= 0; i--) { /* > */
        print(a[i]);
    }
}

function test()
{
    if (window.testRunner)
        testRunner.dumpAsText();
        
    var e;

    e = document;
    printPrototypes(e);
    
    e = document.getElementById("div");
    printPrototypes(e);

    e = document.createElement("form");
    printPrototypes(e);
    
    e = document.createEvent("UIEvents");
    printPrototypes(e);

    e = document.createEvent("MouseEvents");
    printPrototypes(e);
    
    e = document.createEvent("KeyboardEvents");
    printPrototypes(e);
    
}

</script>
</head>
<body onload="test()">
<p>This page prints out the prototype chains of select DOM objects. Older versions of WebCore didn't 
properly implement prototype chaining for these objects.</p>
<p>NOTE: This test will start failing if you change the layout of a related prototype chain in WebCore.
That does not necessarily mean that you have done something wrong; you may just need to check in new
results.</p>
<hr>
<div id="console"></div>
<div id="div"></div>
</body>
</html>
