<!DOCTYPE html>
<html>
<head>
<script>
function runTest() {
    if (window.testRunner && window.eventSender) {
        testRunner.dumpAsText();

        const link = document.getElementById("link");
        const x = link.offsetLeft + link.offsetWidth / 2;
        const y = link.offsetTop + link.offsetHeight / 2;

        eventSender.mouseMoveTo(x, y);
        items = eventSender.contextClick();

        for (var i = 0; i < items.length; i++)
        {
            if (items[i].title.match("Copy Link")) {
                items[i].click();
            }
        }

        const input = document.getElementById("input");
        input.focus();
        document.execCommand("paste");
        const pastedContent = document.createElement('p');
        pastedContent.textContent = input.value;
        document.body.appendChild(pastedContent);
    }
}
</script>
</head>
<body onload="runTest();">
    <a id="link" href='https://en.wikipedia.org/wiki/Gary_Busey/media/File:Texas_Wheelers_cast.JPG' style='background: #000000; display: block; width: 200px; height: 200px;'></a>
    <input id="input"/>
</body>
</html>
