Unfortunately couldn't add all the debug checks that I'd want, since we can't assert that is not safe to run script in quite a few places :( MozReview-Commit-ID: 8m3Wm1WntZs