chromium/third_party/blink/web_tests/fast/dom/inert/inert-inlines.html

<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<a inert id="a" href="javascript:void(0)">Click me</a>
<button inert id="button">Click me</button>
<div inert id="div" style="background-color: blue; width: 50px; height: 50px">Click meeee</div>
<span inert id="span">Click me</span>
<script>
function clickOn(element)
{
    return new Promise(function(resolve, reject) {
        if (!window.eventSender)
            reject();

        var absoluteTop = 0;
        var absoluteLeft = 0;
        for (var parentNode = element; parentNode; parentNode = parentNode.offsetParent) {
            absoluteLeft += parentNode.offsetLeft;
            absoluteTop += parentNode.offsetTop;
        }

        var x = absoluteLeft + element.offsetWidth / 2;
        var y = absoluteTop + element.offsetHeight / 2;
        var pointerActions = [{
            source: "mouse",
            actions: [
                { name: "pointerMove", x: x, y: y },
                { name: "pointerDown", x: x, y: x },
                { name: "pointerUp" },
                { name: "pointerMove", x: 0, y: 0}
            ]
        }];
        chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
    });
}

function eventFiredOnInertElement(e) {
    e.target.style.background = 'red';
    inertElementFiredOn = true;
}

inertElements = ['a', 'button', 'div', 'span']
inertElements.forEach(function(id) {
    element = document.getElementById(id);
    element.addEventListener('click', eventFiredOnInertElement);
    element.addEventListener('mousemove', eventFiredOnInertElement);
});

document.addEventListener('click', function(e) {
    document.firedOn = true;
});

promise_test(async () => {
    for (let id of inertElements) {
        var element = document.getElementById(id);
        inertElementFiredOn = false;
        document.firedOn = false;
        await clickOn(element);
        assert_false(inertElementFiredOn, 'no event should be fired on ' + id);
        assert_true(document.firedOn, 'event should be fired on document instead of ' + id);
    }
}, 'Tests that inert inlines do not receive mouse events. ' +
   'To test manually, click on all the "Click me"s. The test ' +
   'fails if you see red.');

</script>
</body>
</html>