I'm working on a test using Maven and TestNG where I inject a callback on the page which return some events that happen on the page, back to the test. The problem is, sometime during the test I have to do this, right before the page changes (refresh or go to another URL) so first I check when the page is about to change and then I wait for it to load again and inject the callback in the new "refreshed" page.
Unfortunately I can't show any code since it's private but I'm using this approach to check if the page is about to change (adapted to Java).
And I'm using this one to wait for the page to load (@QIKHAN answer).
All this worked fine in Chrome but in Firefox (geckodriver) throws a:
JavaScript error: NS_ERROR_FAILURE
followed by a more detailed error but not so enlightening:
JavaScript error: SecurityError: Permission denied to access property "some_private_property" on cross-origin object
I've found many answers related to this NS_ERROR_FAILURE but none of them solved my problem and even here they say "this is the most general of all the errors". I'm guessing this has to do with the fact that I'm interacting with the page in a moment where the page is changing, but still, it works fine in chrome. As soon as it hits this error the test fails and I'm not even able to catch it with a try catch.
I'm using geckodriver v0.20.1 and selenium v3.11.0.
Some help would be gratefully appreciated.
Update:
As mentioned in the comments, my question it's not the same as the one mentioned here since in my case the test run fine until the moment of page transition, only then I get the error, also the error itself it's not the same.
Another thing that I'm doing it's take a screenshot every time I receive an event from the page and also when the test fails. In the last, the screenshot always come a blank page because the error happens always when the page it's changing to another one. Apparently it doesn't matter what code is being executed in that time but if somehow I interact with the page in that moment, it throws that error.