Bug Tracker

Ticket #6027: bug.html

File bug.html, 1.5 KB (added by menno, 10 years ago)

testcase

Line 
1<!DOCTYPE HTML>
2<html>
3<head>
4    <title>onbeforeunload bug</title>
5           
6    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
7    <script type="text/javascript">
8    jQuery(document).ready(function() {
9        var messages = [];
10
11        function log( message ) {
12            messages.push(message);
13            $('#log').html(messages.join('\n'));
14        }
15       
16        $('#clickme').click(function() {
17            log('clickme clicked');
18        });
19       
20        window.onbeforeunload = function() {
21            return 'really?';
22        }
23    });
24    </script>
25   
26</head>
27<body>
28    <h1>Chrome <code>onbeforeunload</code> bug</h1>
29    <h2>Steps to reproduce</h2>
30    <ol>
31        <li>Click the button a couple of times, notice the log being filled.</li>
32        <li>Reload the page or try to close the window or tab.</li>
33        <li>Choose to "Stay on this page".</li>
34        <li>Click the button again, <strong>notice the log is no longer being filled.</strong></li>
35    </ol>
36   
37
38    <p>
39        <button id="clickme">Click me</button>
40    </p>
41   
42    <pre id="log"></pre>
43   
44    <p>The bug is fixed (as far as I can tell) if the internal jQuery function <code>now()</code> is modified like so:</p>
45    <pre>
46// original:
47function now() {
48    return (new Date).getTime();
49}
50   
51// modified:
52function now() {
53    return (new Date).valueOf();
54}
55</pre>
56
57</body>
58</html>