From 1dfd76e8e567b872158a3c1079f0f177d20fc71c Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Thu, 10 Aug 2017 00:28:59 -0400 Subject: [PATCH] Merge pull request #10381 from brave/10349 If crashing within first 2min don't lose windows --- app/sessionStoreShutdown.js | 5 ++--- test/unit/app/sessionStoreShutdownTest.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/sessionStoreShutdown.js b/app/sessionStoreShutdown.js index 6643383fb2c..b828b624391 100644 --- a/app/sessionStoreShutdown.js +++ b/app/sessionStoreShutdown.js @@ -188,13 +188,12 @@ app.on('before-quit', (e) => { if (sessionStateSaveInterval !== undefined) { clearInterval(sessionStateSaveInterval) } - initiateSessionStateSave() + module.exports.initiateSessionStateSave() }) const startSessionSaveInterval = () => { // save app state every 5 minutes regardless of update frequency - initiateSessionStateSave() - sessionStateSaveInterval = setInterval(initiateSessionStateSave, appConfig.sessionSaveInterval) + sessionStateSaveInterval = setInterval(module.exports.initiateSessionStateSave, appConfig.sessionSaveInterval) } // User initiated exit using File->Quit diff --git a/test/unit/app/sessionStoreShutdownTest.js b/test/unit/app/sessionStoreShutdownTest.js index e2fde54dd6b..88427a4a67e 100644 --- a/test/unit/app/sessionStoreShutdownTest.js +++ b/test/unit/app/sessionStoreShutdownTest.js @@ -355,4 +355,18 @@ describe('sessionStoreShutdown unit tests', function () { }) }) }) + describe('startSessionSaveInterval', function () { + before(function () { + this.initiateSessionStateSave = sinon.spy(sessionStoreShutdown, 'initiateSessionStateSave') + }) + after(function () { + this.initiateSessionStateSave.restore() + }) + // We only care that initiateSessionStateSave is not called sync. + // Windows will be initialized for the non sync case. + it('does not call initiateSessionStateSave', function () { + sessionStoreShutdown.startSessionSaveInterval() + assert.equal(this.initiateSessionStateSave.notCalled, true) + }) + }) })