- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / prerender / prerender_xhr_delete.html
1 <html>
2   <head>
3     <script>
4       var pageWasPrerendered = false;
5
6       // Make sure plugin was not loaded while prerendering.
7       function DidPrerenderPass() {
8         pageWasPrerendered = true;
9         return true;
10       }
11
12       // Make sure DidPrerenderPass() was called first.  Otherwise, the page was
13       // most likely reloaded instead of using the prerendered page.
14       function DidDisplayPass() {
15         return pageWasPrerendered;
16       }
17
18       function do_xhr() {
19         var xhr = new XMLHttpRequest();
20         xhr.onreadystatechange  = function() {
21           if(xhr.readyState == 4) {
22             if(xhr.status == 200) {
23               document.getElementById("dynamic").innerHTML =
24                   "Received:"  + xhr.responseText;
25             } else {
26               document.getElementById("dynamic").innerHTML =
27                   "Error code: " + xhr.status;
28             }
29           }
30         };
31
32         xhr.open("DELETE", "non-existant-file", true);
33         xhr.send(null);
34       }
35
36       // Fire the XHR after onload so to consistently abort after
37       // webkitprerenderload, rather than racily abort on one side or the
38       // other.
39       window.onload = setTimeout.bind(null, do_xhr);
40     </script>
41   </head>
42   <body>
43     <div id="dynamic">
44       Waiting for XHR response.
45     </div>
46  </body>
47 </html>