| <script> |
| var waitingForClose = true; |
| window.addEventListener('beforeunload', function() { |
| if (waitingForClose) |
| alert("FAIL"); |
| }, false); |
| |
| window.onload = function() { |
| // There's no real way to know whether the iframe's attempt to close us |
| // actually failed because it would succeed asynchronously and there is no |
| // failure event. The best we can do is wait around for a while. The one |
| // saving grace is that this test is deterministic when it passes. |
| window.setTimeout(function() { |
| waitingForClose = false; |
| opener.done(); |
| }, 100); |
| } |
| </script> |
| <iframe sandbox="allow-scripts" src="close-top.html"></iframe> |