2018-11-29 18:51:13 +00:00
|
|
|
const { app, session } = require('electron')
|
|
|
|
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(async function () {
|
2018-11-29 18:51:13 +00:00
|
|
|
const url = 'http://foo.bar'
|
|
|
|
const persistentSession = session.fromPartition('persist:ence-test')
|
2019-01-25 18:11:35 +00:00
|
|
|
const name = 'test'
|
|
|
|
const value = 'true'
|
2018-11-29 18:51:13 +00:00
|
|
|
|
2019-01-25 18:11:35 +00:00
|
|
|
const set = () => persistentSession.cookies.set({
|
|
|
|
url,
|
|
|
|
name,
|
|
|
|
value,
|
|
|
|
expirationDate: Date.now() + 60000
|
|
|
|
})
|
2018-11-29 18:51:13 +00:00
|
|
|
|
2019-01-25 18:11:35 +00:00
|
|
|
const get = () => persistentSession.cookies.get({
|
|
|
|
url
|
|
|
|
})
|
2018-11-29 18:51:13 +00:00
|
|
|
|
2020-03-20 15:12:18 +00:00
|
|
|
const maybeRemove = async (pred) => {
|
|
|
|
if (pred()) {
|
|
|
|
await persistentSession.cookies.remove(url, name)
|
2019-01-25 18:11:35 +00:00
|
|
|
}
|
2020-03-20 15:12:18 +00:00
|
|
|
}
|
2018-11-29 18:51:13 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
await maybeRemove(() => process.env.PHASE === 'one')
|
|
|
|
const one = await get()
|
|
|
|
await set()
|
|
|
|
const two = await get()
|
|
|
|
await maybeRemove(() => process.env.PHASE === 'two')
|
|
|
|
const three = await get()
|
|
|
|
|
|
|
|
process.stdout.write(`${one.length}${two.length}${three.length}`)
|
|
|
|
} catch (e) {
|
|
|
|
process.stdout.write('ERROR')
|
|
|
|
} finally {
|
|
|
|
process.stdout.end()
|
|
|
|
|
2019-12-13 09:57:02 +00:00
|
|
|
app.quit()
|
2018-11-29 18:51:13 +00:00
|
|
|
}
|
|
|
|
})
|