chromium/third_party/blink/web_tests/plugins/transformed-events.html

<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="../resources/gesture-util.js"></script>
<style>
  #plugin {
    width: 150px;
    height: 150px;
    touch-action: none;
    background-color: coral;
    transform: rotate(90deg);
  }
</style>
</head>

<body onload="runTest();">
<embed id="plugin" type="application/x-webkit-test-webplugin" accepts-touch="raw" print-event-details="true"></embed>
<script>
jsTestIsAsync = true;

// Without an event handler, the touch events will be dropped before ever
// reaching Blink.
document.getElementById("plugin").addEventListener('touchstart', () => {});

function touchTapAndMove(xPosition, yPosition, xPosition1, yPosition1) {
    if (window.eventSender) {
        eventSender.addTouchPoint(xPosition, yPosition);
        eventSender.touchStart();
        eventSender.updateTouchPoint(0, xPosition1, yPosition1);
        eventSender.touchMove();
        eventSender.releaseTouchPoint(0);
        eventSender.touchEnd();
    }
}

function mouseMoveAndClick(xPosition, yPosition, xPosition1, yPosition1) {
    return new Promise(function(resolve, reject) {
        if (window.chrome && chrome.gpuBenchmarking) {
            chrome.gpuBenchmarking.pointerActionSequence( [
                {source: 'mouse',
                 actions: [
                    { name: 'pointerMove', x: xPosition, y: yPosition },
                    { name: 'pointerDown', x: xPosition, y: yPosition },
                    { name: 'pause', duration: 10 },
                    { name: 'pointerMove', x: xPosition1, y: yPosition1 },
                    { name: 'pointerUp' }
                ]}], resolve);
        } else {
            reject();
        }
    });
}

async function runTest() {
    if (!window.testRunner || !window.eventSender) {
        document.write("This test requires DumpRenderTree.");
    } else {
        testRunner.dumpAsText();

        // Test touch events.
        var positionX = plugin.offsetLeft + plugin.offsetWidth - 10;
        var positionY = plugin.offsetTop + 10;
        touchTapAndMove(positionX, positionY, positionX - 5, positionY + 10);

        // Test mouse events.
        await mouseMoveAndClick(positionX, positionY, positionX - 5, positionY + 10);

        // Test mouse wheel scroll.
        var scroll_position = {x: positionX, y: positionY};
        await wheelTick(1, 0, scroll_position);

        // Test gesture events.
        await touchTapOn(positionX, positionY);
    }
    finishJSTest();
}
</script>
</body>
</html>