In bug 655084, I had simplified the code at ehsan's request in a way that adds hidden assumptions about other code and the lifetime of a Frame. It's more paranoid and safe to revert the the final version of that piece of the patch. See the end of that bug for discussion.
Created attachment 534869 [details] [diff] [review] Revert to older code for safety Is this sufficient, or do we need to block scripts too?
Fix checked in as http://hg.mozilla.org/mozilla-central/rev/b3f26adf6b42