<html>
<head>
<script>
function print(message, color) 
{
    var paragraph = document.createElement("div");
    paragraph.appendChild(document.createTextNode(message));
    paragraph.style.fontFamily = "monospace";
    if (color)
        paragraph.style.color = color;
    document.getElementById("console").appendChild(paragraph);
}

function test() 
{
    if (window.testRunner) {
       testRunner.dumpAsText();
       testRunner.waitUntilDone(); 
    }
    var img1 = document.getElementById('img1');
    img1.onerror = function (error) {
        print("PASS: caught image load error: " + error, "green");
        if (window.testRunner) {
            testRunner.notifyDone();
        }
    };
    img1.src = "invalidinvalid.jpg";
}
</script>
</head>
<body onload="test();">
<p>This page tests setting onerror handlers through the DOM. If it passes, you will
   see "PASS" message below.</p>
<hr>
<div id='console'></div>
<img style="display:none" id="img1">
</body>
</html>
