The issue has been reproduced here:
https://github.com/jsnanigans/hammerhead_testcafe_error
Speculation: A iframe is focused, the iframe sends a message to the main window, the main window closes the iframe before testcafe can focus the main window.
A Iframe is opened where the user enters some data and clicks on submit, then the iframe is redirected with 307 to where some javascript sends a postMessage to our host window which closes the iframe. After the iframe is closed and this error occurs something in the redux dispatch or in the react core breaks and the state is not updated/the app is not re-rendered.
After some debugging we found that it might have something to do with hammerhead.js internals and some focus method.
Important things to note here are that this happens if the iframe has a src (like in this example) or has no src attribute (like in our application)
error is thrown and prevents react from rendering
the main window is focused in testcafe and continues as usual
The issue has been reproduced here:
https://github.com/jsnanigans/hammerhead_testcafe_error
testcafe -c 1 chrome tests/Sample.ts --skip-js-errorsHello @jsnanigans ,
Thank you for submitting the issue. I've managed to reproduce it. We will research it and update this thread as soon as we have any results.
I've researched this issue and created a simplified example. The problem occurs when the focus method is called on some element from a removed iframe.
<body>
<script>
var iframe = document.createElement('iframe');
iframe.addEventListener('load', function () {
var body = iframe.contentDocument.body;
document.body.removeChild(iframe);
body.focus();
});
document.body.appendChild(iframe);
</script>
VM2693 hammerhead.js:23480 Uncaught TypeError: window.location.toString is not a function
at getLocation (VM2693 hammerhead.js:23480)
at get (VM2693 hammerhead.js:23508)
at Object.getParsed (VM2693 hammerhead.js:23523)
at Function._wrapMessage (VM2693 hammerhead.js:13646)
at MessageSandbox.sendServiceMsg (VM2693 hammerhead.js:13766)
at ActiveWindowTracker.makeCurrentWindowActive (VM2693 hammerhead.js:11772)
at raiseFocusEvent (VM2693 hammerhead.js:12664)
at FocusBlurSandbox.focus (VM2693 hammerhead.js:12730)
at HTMLBodyElement.focus (VM2693 hammerhead.js:13011)
at HTMLIFrameElement.<anonymous> (iframe-focus.html:10)
Most helpful comment
Hello @jsnanigans ,
Thank you for submitting the issue. I've managed to reproduce it. We will research it and update this thread as soon as we have any results.