I struggled with this for a long time. This seems to be a bug in FF, but I noticed that after a new window opens, if I click on it, it will really focus and come back. However, the call to window.focus () did not work on it, so I guessed that this was happening too soon.
So, in the code of the new window, at the bottom of the page, I added
setTimeout(function(){window.focus()},100);
This doesn't sound like a solid practice, but if you need it to work ... 100mSec seems to be the lowest that works on my system.
source share