chromium/third_party/blink/web_tests/http/tests/misc/resources/cross-origin-subframe-for-scrolling.html

<!DOCTYPE html>
<div style="height: 300px"></div>

<script>
var port;
var frame_id;

window.onload = (() => {
  if (!window.eventSender || !window.internals) {
  	debug("This test requires window.eventSender.");
  	return;
  }
  internals.settings.setScrollAnimatorEnabled(true);
});

function handleMessage(event) {
  if (event.data.hasOwnProperty('expectScrollBy')) {
    port = event.source;
    frame_id = event.data.frame_id;
  } else if (event.data.hasOwnProperty('clickScrollbar')) {
    port = event.source;
    frame_id = event.data.frame_id;
    console.log('clicking');
    eventSender.mouseMoveTo(window.innerWidth - 5, window.innerWidth - 5);
    eventSender.mouseDown();
    eventSender.mouseUp();
  }
}

window.onscroll = (() => {
  if (port) {
    port.postMessage({scrolled: frame_id, scrollTop: document.documentElement.scrollTop}, "*");
  } else{
    // If parent is performing middle click autoscroll on iframe, send the
    // scrollTop data back to parent.
    parent.postMessage({scrolled: frame_id, scrollTop: document.documentElement.scrollTop}, "*");
  }
});

window.addEventListener("message", handleMessage);
</script>