Fix two bugs with spurious dirtyFlagChange events:
- Document ctor always fires it, even though isDirty stays false whole time
- Calling refreshText() always fires a pair of isDirty->true,->false
  (causing bug #502)

Add unit tests for various cases around Document dirty/undo state
Merge branch 'master' into pflynn/spurious-dirtyflag
reuse test window in Document-test
add check for dangling documents
Merge pull request #4994 from adobe/pflynn/spurious-dirtyflag

Fix bugs with spurious dirtyFlagChange events
Merge branch 'master' of https://github.com/adobe/brackets into larz/panel-consistency
Made the jslint selector change again due to new architecture.