OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <meta http-equiv="expires" content="0"> |
| 3 <script src="prerender_events_common.js"></script> |
| 4 <script> |
| 5 function GetCookie(cookieName) { |
| 6 var re = RegExp(cookieName + '=([^;]*)'); |
| 7 var result = re.exec(document.cookie); |
| 8 if (result) |
| 9 return result[1]; |
| 10 return ""; |
| 11 } |
| 12 |
| 13 function SetCookie(cookieName, cookieValue) { |
| 14 var exp = "Tue, 31 Dec 2030 23:59:59 GMT"; |
| 15 if (cookieValue == "") |
| 16 exp = "Thu, 01 Jan 1970 00:00:00 GMT"; |
| 17 document.cookie = cookieName + "=" + cookieValue + "; expires=" + exp; |
| 18 } |
| 19 |
| 20 function DidPrerenderPass() { |
| 21 // If the prerender did not set a value, everything's fine. |
| 22 if (ExtractGetParameterBadlyAndInsecurely('set', 0) == 0) |
| 23 return true; |
| 24 |
| 25 // If the prerender set a cookie, querying it again should yield the same |
| 26 // value that was set during the request. |
| 27 var cookieName = ExtractGetParameterBadlyAndInsecurely('key', ""); |
| 28 var cookieValue = ExtractGetParameterBadlyAndInsecurely('value', ""); |
| 29 return GetCookie(cookieName) == cookieValue; |
| 30 } |
| 31 |
| 32 if (ExtractGetParameterBadlyAndInsecurely('set', 0) != 0) { |
| 33 var cookieName = ExtractGetParameterBadlyAndInsecurely('key', ""); |
| 34 var cookieValue = ExtractGetParameterBadlyAndInsecurely('value', ""); |
| 35 SetCookie(cookieName, cookieValue); |
| 36 } |
| 37 |
| 38 document.write(document.cookie); |
| 39 |
| 40 </script> |
| 41 <body></body></html> |
OLD | NEW |