I dont know why this is so hard and there doesnt seem to be anything out there to do it already, that I could find.
All I want to do is open my web app in two (tabs/windows/iframes/whatever), but a different version in each. Then, when I interact with one version of the app it would send those mouse events to other version so I can see in real time how the responsiveness is different (if at all). Communicating from one tab to the other is no issue, I have that working, but when I try to dispatch the event in the second tab nothing happens no matter what I try.
Currently on the "slave" tab I have something like this:
window.addEventListener("message", (event) => {
if (event.data.clientX && event.data.clientY) {
let d = event.data;
document.dispatchEvent(new MouseEvent('click', {
bubbles: true,
cancelable: true,
clientX: d.clientX,
clientY: d.clientY,
detail: d.detail,
screenX: d.screenX,
screenY: d.screenY,
button: d.button,
ctrlKey : d.ctrlKey,
altKey : d.altKey,
shiftKey : d.shiftKey,
metaKey : d.metaKey
}));
}
}, false);
I've tried it with just clientX/Y and then added these others but still no go. Everything seems to work its just that nothing happens with these dispatched events.
What am I missing? or is there already a tool to do this so I dont have to build something?