chromium/third_party/blink/web_tests/external/wpt/html/browsers/browsing-the-web/unloading-documents/prompt/004-1.html

<!doctype html>
004-1
<script>
var handleBeforeUnload = function() {
  parent.beforeunload_fired = true;
  removeListener();
  setTimeout(function() {
    parent.timeout_fired = true;
  }, 1000);
}

var removeListener = function() {
  assert_true(window.removeEventListener('beforeunload', handleBeforeUnload, false));
}

window.addEventListener('beforeunload', handleBeforeUnload, false);

onload = function() {
  if (!parent.loaded) {
    parent.loaded = true;
    location="004-2.html?" + Math.random();
  }
}
</script>
// child frame with no onbeforeunload listener. Should leave the parent as unsalvageable.
// Adding the iframe prevents potential implementation bugs where the the recursive steps of #prompt-to-unload-a-document
// would overwrite the salvageable state of the parent.
<iframe></iframe>