Reviewed by Ojan Vafai. Bugzilla JavaScript changes by Adam Barth.