chromium/third_party/blink/web_tests/fast/loader/form-submission-after-beforeunload-cancel.html

<script>
if (window.testRunner) {
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
    testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true);
}

// JavaScript onbeforeunload dialogs require a user gesture.
if (window.eventSender) {
    eventSender.mouseMoveTo(5, 5);
    eventSender.mouseDown();
    eventSender.mouseUp();
}

_confirmationDialogDisplayedOnce = false;

window.onbeforeunload = function() {

    if (window._confirmationDialogDisplayedOnce)
        return "Click 'Leave Page'";

    window.setTimeout(function() {
        if (window.testRunner)
            testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(false);

        window.setTimeout(function() {
            document.getElementById("console").innerHTML = "FAIL";
            if (window.testRunner)
                testRunner.notifyDone();
        }, 1000);

        document.forms[0].submit();
    }, 0);

    window._confirmationDialogDisplayedOnce = true;

    return "Click 'Stay on Page'";
};
</script>

<p>This tests that submitting a form a second time after canceling the first submission in a onbeforeunload handler is allowed. To test manually, follow the instructions in the JavaScript confirmation dialogs.</p>

<div id="console"></div>

<form action="resources/pass-and-notify-done.html" method="POST">
</form>

<script>
document.forms[0].submit();
</script>