blob: d406309466fc1fcede063df099d408c3b5b4cbf4 [file] [log] [blame]
<html><head>
<title>Image load in unload handler</title>
<script>
var testCalled = false;
function test() {
if (!testCalled) {
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
testCalled = true;
return;
}
// We can't go to check-ping.php directly, since that doesn't start sending
// a response until the ping data is detected, but unload handlers (where
// we send the ping) are only run once we've begun receiving data from the
// page being navigated to. Instead, we go through a dummy redirect page,
// to make sure that the onunload handler has run before we get to
// check-ping.php.
location.assign("resources/image-load-in-unload-handler-2.html");
}
function ping() {
var img = new Image(1, 1);
img.src = "resources/save-Ping.php";
}
</script>
</head>
<body onload="test();" onunload="ping();">
<img src="resources/delete-ping.php" onload="test();" onerror="test();"></img>
Test case for https://bugs.webkit.org/show_bug.cgi?id=30457. Previously, if an image<br>
load was trigger from an unload handler, we would kill it almost immediately due to the<br>
navigation stopping all loaders. These loads now happen entirely in the background and detached<br>
from the DOM, so they're invisible to the normal resource load callback infrastructure. We generate a<br>
timestamp, then in the unload handler, we load an 'image' (actually a php script) that takes the<br>
timestamp as a parameter and saves it to a file. The destination page is a php script that checks for<br>
the existence of that file and passes the test if the file contains the expected timestamp.<br>
</body></html>