chromium/third_party/blink/web_tests/accessibility/click-event.html

<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>

<div id="wrapper1">
    <button id="button1">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button1");
    axButton.addNotificationListener(t.step_func(function(notification) {
        t.done();
        if (notification == 'Clicked') {
            t.done();
        }
    }));

    var button = document.getElementById("button1");
    button.click();
}, "clicking a button via javascript sends an accessible click event");
</script>

<div id="wrapper2">
    <button id="button2">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button2");
    axButton.addNotificationListener(t.step_func(function(notification) {
        if (notification == 'Clicked') {
            t.done();
        }
    }));

    eventSender.mouseMoveTo(axButton.x + 10, axButton.y + 10);
    eventSender.mouseDown();
    eventSender.mouseUp();
}, "clicking a button via mouse events sends an accessible click event");
</script>

<div id="wrapper3">
    <button id="button3">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button3");
    axButton.addNotificationListener(t.step_func(function(notification) {
        if (notification == 'Clicked') {
            t.done();
        }
    }));

    var button = document.getElementById("button3");
    button.focus();
    eventSender.keyDown("\r");
}, "clicking a button via the keyboard sends an accessible click event");
</script>

<div id="wrapper4">
    <button id="button4">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button4");
    axButton.addNotificationListener(t.step_func(function(notification) {
        if (notification == 'Clicked') {
            t.done();
        }
    }));

    axButton.press();
}, "clicking a button via accessibility sends an accessible click event");
</script>

<div id="wrapper5">
    <button id="button5">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button5");
    axButton.addNotificationListener(t.step_func(function(notification) {
        if (notification == 'Clicked') {
            assert_unreached("There shouldn't be a Clicked notification.");
        }
    }));

    let x = axButton.x;
    let y = axButton.y;
    eventSender.dragMode = true;
    eventSender.mouseMoveTo(x + 10, y + 10);
    eventSender.mouseDown();
    eventSender.leapForward(100);
    eventSender.mouseMoveTo(x + 10, y + 100);
    eventSender.mouseUp();

    // Make the test pass after a short delay. The test passes if the
    // accessible click event does not fire.
    window.setTimeout(t.step_func(function() {
        t.done();
    }, 200));
}, "dragging the mouse off a button does not send an accessible click event");
</script>
<div id="wrapper6">
    <button id="button6">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button6");
    axButton.addNotificationListener(t.step_func(function(notification) {
        if (notification == 'Clicked') {
            assert_unreached("There shouldn't be a Clicked notification.");
        }
    }));

    let x = axButton.x;
    let y = axButton.y;
    eventSender.dragMode = true;
    eventSender.mouseMoveTo(x + 10, y + 100);
    eventSender.mouseDown();
    eventSender.leapForward(100);
    eventSender.mouseMoveTo(x + 10, y + 10);
    eventSender.mouseUp();

    // Make the test pass after a short delay. The test passes if the
    // accessible click event does not fire.
    window.setTimeout(t.step_func(function() {
        t.done();
    }, 0));
}, "dragging the mouse onto a button does not send an accessible click event");
</script>

<div id="wrapper7">
    <button id="button7">Button</button>
</div>

<script>
async_test(function(t)
{
    var axButton = accessibilityController.accessibleElementById("button7");
    axButton.addNotificationListener(t.step_func(function(notification) {
        if (notification == 'Clicked') {
            t.done();
        }
    }));

    let x = axButton.x;
    let y = axButton.y;
    eventSender.gestureTap(x + 10, y + 10);
}, "tapping on a button with a touch event sends an accessible click event");
</script>