Crash fix: Switch to top frame when parent frame is reloaded

Fixes null dereferences when working with nested frames.

This replaces https://github.com/ariya/phantomjs/pull/11984 with a proper solution.