<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<span id="span">
<p id="description"></p>
<div id="console"></div>

<script>
    description("This tests that vm entry to a JS function with arity mismatch doesn't crash (bug 136305).");

    if (window.testRunner)
        testRunner.waitUntilDone();

    window.jsTestIsAsync = true;

    function marsaglia(m_z, m_w, n) {
        var result;
        for (var i = 0; i < n; ++i) {
        }
    }

    var result = 0;
    for (var i = 0; i < 100; ++i)
        result += marsaglia(i, i + 1, 1000000);

    document.getElementById("span").addEventListener("readystatechange", marsaglia);

    var dispatch_fn = function() {
        evt = document.createEvent("Event");
        evt.initEvent("readystatechange", false, false);
        document.getElementById("span").dispatchEvent(evt);
    }

    window.setInterval(dispatch_fn, 0);
    window.setTimeout('finishJSTest()', 1);
</script>

<script src="../resources/js-test-post.js"></script>
</body>
</html>
