b87b501161
* build: run eslint --fix * chore: manually fix all hasOwnProperty errors * chore: manually fix all void 0 vs undefined errors * chore: manually fix all async-in-promise errors * chore: manually fix lexical declaration in case block
42 lines
960 B
JavaScript
42 lines
960 B
JavaScript
const { app, session } = require('electron')
|
|
|
|
app.whenReady().then(async function () {
|
|
const url = 'http://foo.bar'
|
|
const persistentSession = session.fromPartition('persist:ence-test')
|
|
const name = 'test'
|
|
const value = 'true'
|
|
|
|
const set = () => persistentSession.cookies.set({
|
|
url,
|
|
name,
|
|
value,
|
|
expirationDate: Date.now() + 60000
|
|
})
|
|
|
|
const get = () => persistentSession.cookies.get({
|
|
url
|
|
})
|
|
|
|
const maybeRemove = async (pred) => {
|
|
if (pred()) {
|
|
await persistentSession.cookies.remove(url, name)
|
|
}
|
|
}
|
|
|
|
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()
|
|
|
|
app.quit()
|
|
}
|
|
})
|