Use separate session for cookies change event test
This commit is contained in:
parent
96e48ac13c
commit
77b35ba7ab
2 changed files with 18 additions and 34 deletions
|
@ -55,7 +55,6 @@ struct Converter<net::CanonicalCookie> {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct Converter<AtomCookieDelegate::ChangeCause> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
|
@ -77,7 +76,6 @@ struct Converter<AtomCookieDelegate::ChangeCause> {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
|
|
@ -180,48 +180,34 @@ describe('session module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('changed events', function () {
|
||||
it('emits an event when a cookie is set', function (done) {
|
||||
session.defaultSession.cookies.on('changed', function cookieChanged(event, cookie, cause, removed) {
|
||||
if (cookie.name !== 'foo') return
|
||||
it('emits a changed event when a cookie is added or removed', function (done) {
|
||||
const {cookies} = session.fromPartition('cookies-changed')
|
||||
|
||||
cookies.once('changed', function (event, cookie, cause, removed) {
|
||||
assert.equal(cookie.name, 'foo')
|
||||
assert.equal(cookie.value, 'bar')
|
||||
assert.equal(cause, 'explicit')
|
||||
assert.equal(removed, false)
|
||||
session.defaultSession.cookies.removeListener('changed', cookieChanged)
|
||||
done()
|
||||
})
|
||||
session.defaultSession.cookies.set({
|
||||
url: url,
|
||||
name: 'foo',
|
||||
value: 'bar'
|
||||
}, function (error) {
|
||||
if (error) return done(error)
|
||||
})
|
||||
})
|
||||
|
||||
it('emits an event when a cookie is removed', function (done) {
|
||||
session.defaultSession.cookies.on('changed', function cookieChanged(event, cookie, cause, removed) {
|
||||
if (cookie.name !== 'foo' || removed == false) return
|
||||
|
||||
cookies.once('changed', function (event, cookie, cause, removed) {
|
||||
assert.equal(cookie.name, 'foo')
|
||||
assert.equal(cookie.value, 'bar')
|
||||
assert.equal(cause, 'overwrite')
|
||||
assert.equal(cause, 'explicit')
|
||||
assert.equal(removed, true)
|
||||
session.defaultSession.cookies.removeListener('changed', cookieChanged)
|
||||
done()
|
||||
})
|
||||
session.defaultSession.cookies.set({
|
||||
|
||||
cookies.remove(url, 'foo', function (error) {
|
||||
if (error) return done(error)
|
||||
})
|
||||
})
|
||||
|
||||
cookies.set({
|
||||
url: url,
|
||||
name: 'foo',
|
||||
value: 'bar'
|
||||
}, function (error) {
|
||||
if (error) return done(error)
|
||||
session.defaultSession.cookies.remove(url, 'foo', function (error) {
|
||||
if (error) return done(error)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue