chromium/third_party/blink/web_tests/fast/loader/resources/iframe-with-beforeunload.html

<!DOCTYPE html>
<html>
<head>
    <script>
        window.onbeforeunload = function() {
            return "This is beforeunload from an iframe.";
        };

        // JavaScript onbeforeunload dialogs require a user gesture.
        if (window.eventSender) {
            eventSender.mouseMoveTo(window.frameElement.offsetLeft + 5,
                                    window.frameElement.offsetTop + 5);
            eventSender.mouseDown();
            eventSender.mouseUp();
        }
    </script>
</body>
    <p>This is an iframe with a beforeunload handler.</p>
</body>
</html>