<html>
<body>

<img id="img" onload="logStatus(true)" onerror="logStatus(false)"></img>
<script id="script" onload="logStatus(true)" onerror="logStatus(false)"></script>
<script>
var test = JSON.parse(decodeURIComponent(location.hash.substring(1)));

function logStatus(status)
{
    var msg = "Test " + test.id;
    msg += test.shouldPass == status ? " PASS: " : " FAIL: ";

    msg += status ? "Loaded" : "Did not load";
    msg += " " + test.node + " " + node.src + " from " + location.host;
    if (test.crossOrigin)
        msg += " (crossOrigin=" + test.crossOrigin + ")";

    parent.postMessage(msg, "*");
}

var node = document.getElementById(test.node);
if (test.crossOrigin !== undefined)
    node.crossOrigin = test.crossOrigin;
node.src = test.url;
</script>
</body>
</html>
