Fix within_frame with cross domain frames

As per #183 but with a working spec and a better fix.

The spec is properly red green.  I noticed also in the project that I am testing that there were also sporadic fails when pop_frame gets called, this also fixes that, but I couldn't work out how to reproduce that in spec as it seems to be very time sensitive.