004-1.html (805B)
1 <!doctype html> 2 004-1 3 <script> 4 var handleBeforeUnload = function() { 5 parent.beforeunload_fired = true; 6 removeListener(); 7 setTimeout(function() { 8 parent.timeout_fired = true; 9 }, 1000); 10 } 11 12 var removeListener = function() { 13 assert_true(window.removeEventListener('beforeunload', handleBeforeUnload, false)); 14 } 15 16 window.addEventListener('beforeunload', handleBeforeUnload, false); 17 18 onload = function() { 19 if (!parent.loaded) { 20 parent.loaded = true; 21 location="004-2.html?" + Math.random(); 22 } 23 } 24 </script> 25 // child frame with no onbeforeunload listener. Should leave the parent as unsalvageable. 26 // Adding the iframe prevents potential implementation bugs where the recursive steps of #prompt-to-unload-a-document 27 // would overwrite the salvageable state of the parent. 28 <iframe></iframe>