Why does a JavScript .submit() call trigger the forms onsubmit event?

I have this form:

<?php
    if (!empty($_POST)) {
        header('Content-Type: text/plain');
        print_r($_POST);
        exit;
    }
?>

<!DOCTYPE html>
<html>
<body>

    <script>            
            setTimeout(function ()
            {
                document.forms[0].submit();
            }, 2000);
    </script>

    <form action="modaldialog-form-submit.html" method="post" id="myForm" onsubmit="alert('Why am I not seeing this alert when the form is submitted by JavaScript?');" >
        <input type="text" name="myText" value="Some text..." /><br />
        <textarea name="myTextarea">A text area</textarea><br />
        
        <input type="radio" value="1" name="myRadio" checked />Radio1<br />
        <input type="radio" value="22" name="myRadio" />Radio2<br />
        <input type="radio" value="333" name="myRadio" />Radio3<br />
        
        <select name="mySelect">
            <option value="first">First</option>
            <option value="second">Second</option>
            <option value="third">Third</option>
        </select>
        <p />
        <input type="submit" />
    </form>
    
</body>
</html>

When you click the submit button the onsubmit event is fired and you see the alert. But when the document.forms[0].submit() method is called it does not fire the onsubmit event.

Why is that?