spec: Check the time when Promise's callback is called

This commit is contained in:
Cheng Zhao 2015-08-07 16:55:16 +08:00
parent 74fa2c809d
commit 3402871741

View file

@ -135,3 +135,32 @@ describe 'chromium feature', ->
else
done('user agent is empty')
websocket = new WebSocket("ws://127.0.0.1:#{port}")
describe 'Promise', ->
it 'resolves correctly in Node.js calls', (done) ->
document.registerElement('x-element', {
prototype: Object.create(HTMLElement.prototype, {
createdCallback: { value: -> }
})
})
setImmediate ->
called = false
Promise.resolve().then ->
done(if called then undefined else new Error('wrong sequnce'))
document.createElement 'x-element'
called = true
it 'resolves correctly in Electron calls', (done) ->
document.registerElement('y-element', {
prototype: Object.create(HTMLElement.prototype, {
createdCallback: { value: -> }
})
})
remote.getGlobal('setImmediate') ->
called = false
Promise.resolve().then ->
done(if called then undefined else new Error('wrong sequnce'))
document.createElement 'y-element'
called = true