Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / navigation / image-load-in-unload-handler.html
blobf4376c6d3b2b0dac9d4d75935a103bc9564e0b2c
1 <html><head>
2 <title>Image load in unload handler</title>
3 <script>
5 var testCalled = false;
7 function test() {
8 if (!testCalled) {
9 if (window.testRunner) {
10 testRunner.dumpAsText();
11 testRunner.waitUntilDone();
13 testCalled = true;
14 return;
16 // We can't go to check-ping.php directly, since that doesn't start sending
17 // a response until the ping data is detected, but unload handlers (where
18 // we send the ping) are only run once we've begun receiving data from the
19 // page being navigated to. Instead, we go through a dummy redirect page,
20 // to make sure that the onunload handler has run before we get to
21 // check-ping.php.
22 location.assign("resources/ping-redirect.html");
25 function ping() {
26 var img = new Image(1, 1);
27 img.src = "resources/save-Ping.php";
30 </script>
31 </head>
32 <body onload="test();" onunload="ping();">
33 <img src="resources/delete-ping.php" onload="test();" onerror="test();"></img>
34 Test case for https://bugs.webkit.org/show_bug.cgi?id=30457. Previously, if an image<br>
35 load was trigger from an unload handler, we would kill it almost immediately due to the<br>
36 navigation stopping all loaders. These loads now happen entirely in the background and detached<br>
37 from the DOM, so they're invisible to the normal resource load callback infrastructure. We generate a<br>
38 timestamp, then in the unload handler, we load an 'image' (actually a php script) that takes the<br>
39 timestamp as a parameter and saves it to a file. The destination page is a php script that checks for<br>
40 the existence of that file and passes the test if the file contains the expected timestamp.<br>
41 </body></html>