<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</script>
</head>
<body>
<embed name="plg" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100></embed>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=11517">bug 11517</a>:
Flash clicks/interactivity not working properly.</p>
<div id=console></div>
<script>
    window.jsTestIsAsync = true;

    plg.windowedPlugin = false;
    plg.eventLoggingEnabled = true;

    // Our test plug-in logs events through window.console. Override it with a custom
    // implementation that counts the number of messages - due to the nature of IPC, it's
    // difficult to predict when events get handled.
    const expectedMessageCount = 5;
    var messageCount = 0;
    window.console = {
        log: function(message) {
            if (messageCount == expectedMessageCount) {
                alert("Message unexpectedly leaked from preceding test, plugins/mouse-events.html: " + message);
                return;
            }

            debug(message);

            if (++messageCount == expectedMessageCount)
                finishJSTest();
        }
    };

    if (!window.testRunner) {
        document.write("To test manually, please install WebKit test plug-in, and verify that mouse events get logged.");
    } else {
        eventSender.mouseMoveTo(0,0);
        eventSender.mouseMoveTo(20,20);
        eventSender.mouseDown();
        eventSender.mouseUp();
        eventSender.mouseMoveTo(30,30);
        eventSender.mouseDown();
        eventSender.mouseMoveTo(40,30);
        eventSender.mouseUp();
        eventSender.mouseMoveTo(0,0);
    }
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
