OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. |
| 5 --> |
| 6 <html> |
| 7 <head> |
| 8 <title>unload_sleep_before_cookie</title> |
| 9 <script> |
| 10 function sleep_ms(ms) { |
| 11 var start_ms = Number(new Date()); |
| 12 var remaining_ms = ms; |
| 13 while (remaining_ms > 0) { |
| 14 remaining_ms = ms - (Number(new Date()) - start_ms); |
| 15 } |
| 16 } |
| 17 addEventListener("unload", function() { |
| 18 sleep_ms(200); |
| 19 |
| 20 var expires = new Date(); |
| 21 expires.setMinutes(expires.getMinutes() + 1); |
| 22 document.cookie = "unloaded=ohyeah;path=/;expires=" + expires.toUTCString(); |
| 23 console.log("set the cookie"); |
| 24 }, false); |
| 25 </script> |
| 26 </head> |
| 27 <body></body> |
| 28 </html> |
OLD | NEW |