race condition fix and sanity restoration 

The 'touchend' event was being fired before we could set up our event handler. Instead, I'm adding an event handler earlier that will just set a variable when the event occurs, so we can just check that.

I figured out that insane hack. It's because of this: https://bugzilla.mozilla.org/show_bug.cgi?id=858288. The sandbox that execute_*script runs in has to reset if we switch frames, but there's one case (switch_to_frame()) where we don't do that, and that triggers a bug where we reuse the sandbox of a different frame instead of the one we're currently in. I fixed this by removing the new_sandbox=False part on line 274. It doesn't do anything useful here anyway, other than triggering that bug.

Also, the page load checker wasn't quite right. We have to wait until we're on the right page, and the 'loading' variable is false.