OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 <!-- | |
3 This test checks to make sure that a pending prerenders which are canceled | |
4 while pending never start. | |
mmenke
2012/12/17 17:08:18
nit "a pending prerenders which are" -> "pending p
gavinp
2012/12/17 20:34:02
Done.
| |
5 --> | |
6 <link id=thePrerender rel=prerender href="does_not_exist.html" /> | |
7 <head> | |
8 <title>Prerender Page</title> | |
9 | |
10 <script> | |
11 var pageWasPrerendered = false; | |
12 | |
13 var receivedPrerenderStartEvents = Array(); | |
14 var receivedPrerenderStopEvents = Array(); | |
15 | |
16 function MakePrerenderStartHandlerForLink(index) { | |
17 return function() { receivedPrerenderStartEvents[index] = true; }; | |
18 } | |
19 | |
20 function MakePrerenderStopHandlerForLink(index) { | |
21 return function() { receivedPrerenderStopEvents[index] = true; }; | |
22 } | |
23 | |
24 function DidPrerenderPass() { | |
25 pageWasPrerendered = true; | |
26 var link = document.getElementById('thePrerender'); | |
27 if (link) | |
28 link.parentElement.removeChild(link) | |
29 return !receivedPrerenderStartEvents[1] && !receivedPrerenderStopEvents[1]; | |
30 } | |
31 | |
32 // Make sure DidPrerenderPass() was called first. Otherwise, the page was | |
33 // most likely reloaded instead of using the prerendered page. | |
34 function DidDisplayPass() { | |
35 return pageWasPrerendered && !receivedPrerenderStartEvents[1] && | |
36 !receivedPrerenderStopEvents[1]; | |
37 } | |
38 | |
39 var link = document.getElementById('thePrerender'); | |
40 link.addEventListener('webkitprerenderstart', | |
41 MakePrerenderStartHandlerForLink(1), false); | |
42 link.addEventListener('webkitprerenderstop', | |
43 MakePrerenderStopHandlerForLink(1), false); | |
44 </script> | |
45 | |
46 </head> | |
47 <body></body> | |
48 </html> | |
OLD | NEW |