| <html> |
| <head> |
| <script> |
| var pageWasPrerendered = false; |
| |
| // Make sure plugin was not loaded while prerendering. |
| function DidPrerenderPass() { |
| pageWasPrerendered = true; |
| return true; |
| } |
| |
| // Make sure DidPrerenderPass() was called first. Otherwise, the page was |
| // most likely reloaded instead of using the prerendered page. |
| function DidDisplayPass() { |
| return pageWasPrerendered; |
| } |
| |
| function do_xhr() { |
| var xhr = new XMLHttpRequest(); |
| xhr.onreadystatechange = function() { |
| if(xhr.readyState == 4) { |
| if(xhr.status == 200) { |
| document.getElementById("dynamic").innerHTML = |
| "Received:" + xhr.responseText; |
| } else { |
| document.getElementById("dynamic").innerHTML = |
| "Error code: " + xhr.status; |
| } |
| } |
| }; |
| |
| xhr.open("DELETE", "non-existant-file", true); |
| xhr.send(null); |
| } |
| |
| // Fire the XHR after onload so to consistently abort after |
| // webkitprerenderload, rather than racily abort on one side or the |
| // other. |
| window.onload = setTimeout.bind(null, do_xhr); |
| </script> |
| </head> |
| <body> |
| <div id="dynamic"> |
| Waiting for XHR response. |
| </div> |
| </body> |
| </html> |