mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Ensure we never load saved window in specs
This commit is contained in:
@@ -39,6 +39,7 @@ beforeEach ->
|
||||
atom.atomPackageStates = {}
|
||||
atom.loadedPackages = []
|
||||
spyOn(atom, 'saveWindowState')
|
||||
spyOn(atom, 'getSavedWindowState').andReturn(null)
|
||||
$native.setWindowState('')
|
||||
|
||||
# used to reset keymap after each spec
|
||||
|
||||
@@ -198,14 +198,22 @@ _.extend atom,
|
||||
windowState
|
||||
|
||||
getWindowState: (keyPath) ->
|
||||
inMemoryState = $native.getWindowState()
|
||||
inMemoryState = null unless inMemoryState.length > 0
|
||||
windowState = JSON.parse(inMemoryState ? localStorage[window.location.params.pathToOpen] ? '{}')
|
||||
windowState = JSON.parse(@getInMemoryWindowState() ? @getSavedWindowState() ? '{}')
|
||||
if keyPath
|
||||
_.valueForKeyPath(windowState, keyPath)
|
||||
else
|
||||
windowState
|
||||
|
||||
getInMemoryWindowState: ->
|
||||
inMemoryState = $native.getWindowState()
|
||||
if inMemoryState.length > 0
|
||||
inMemoryState
|
||||
else
|
||||
null
|
||||
|
||||
getSavedWindowState: ->
|
||||
localStorage[window.location.params.pathToOpen]
|
||||
|
||||
saveWindowState: ->
|
||||
localStorage[@getPathToOpen()] = JSON.stringify(@getWindowState())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user