blob: cf9e56680e652aed1b9ae2862ea95c2282920f02 [file] [log] [blame]
<script src="resources/print.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window._beforeloadfired = false;
function runTest()
{
document.addEventListener("beforeload", function(event) {
window._beforeloadfired = true;
}, true);
cachedImage = new Image();
document.body.appendChild(cachedImage);
cachedImage.onload = function(event) {
if (window._beforeloadfired)
print("PASS: load fired after beforeload for a cached image.", "green");
else
print("FAIL: load fired before beforeload for a cached image.", "red");
if (this.width == 16)
print("PASS: image is 16px wide.", "green");
else
print("FAIL: image claims not to be 16px wide.", "red");
if (window.testRunner)
testRunner.notifyDone();
}
cachedImage.src = document.getElementById("originalImage").src;
cachedImage.style.visibility = "hidden";
}
</script>
<p>This is a regression test for <a href="http://webkit.org/b/45586">http://webkit.org/b/45586</a>. It verifies that the beforeload event fires before the load event when loading a cached image, and that the image's style attributes can be queried in the load event handler. On success, you should see two lines of green text starting with the word 'PASS'.</p>
<div id="console"></div>
<img id="originalImage" style="visibility:hidden" onload="runTest()" src="../../images/resources/test-load.jpg">