Merge pull request #12377 from atom/ns-stringify-temp-window-state

Stringify/parse temporary window state to avoid nulling out references
This commit is contained in:
Nathan Sobo
2016-08-09 15:20:30 -06:00
committed by GitHub
2 changed files with 21 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
/** @babel */
import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers'
import ApplicationDelegate from '../src/application-delegate'
describe('ApplicationDelegate', function () {
describe('set/getTemporaryWindowState', function () {
it('can serialize object trees containing redundant child object references', async function () {
const applicationDelegate = new ApplicationDelegate()
const childObject = {c: 1}
const sentObject = {a: childObject, b: childObject}
await applicationDelegate.setTemporaryWindowState(sentObject)
const receivedObject = await applicationDelegate.getTemporaryWindowState()
expect(receivedObject).toEqual(sentObject)
})
})
})

View File

@@ -23,10 +23,10 @@ class ApplicationDelegate
ipcRenderer.send("call-window-method", "close")
getTemporaryWindowState: ->
ipcHelpers.call('get-temporary-window-state')
ipcHelpers.call('get-temporary-window-state').then (stateJSON) -> JSON.parse(stateJSON)
setTemporaryWindowState: (state) ->
ipcHelpers.call('set-temporary-window-state', state)
ipcHelpers.call('set-temporary-window-state', JSON.stringify(state))
getWindowSize: ->
[width, height] = remote.getCurrentWindow().getSize()