Bug 879341 - Move CheckForDebugMode into the main thread event observer. r=gabor

This gets invoked at the very end of nsThread::ProcessNextEvent(). If the cx stack
is empty here, that means the event loop isn't nested - if it it was, we'd at
least have a null cx on the stack from a higher-level call to OnProcessNextEvent
for the main thread observer.

As such, this seems like a much more reasonable place to make debug mode changes.
Bug 879341 - Use an AutoSafeJSContext in CheckForDebugMode like we should. r=gabor
Bug 879341 - Use an AutoPushJSContext in JSD. r=gabor

We can do this now, since it won't cause infinite recursion.