From 3402871741e5b4517664fc479f6e483c9d2d1a42 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 7 Aug 2015 16:55:16 +0800 Subject: [PATCH] spec: Check the time when Promise's callback is called --- spec/chromium-spec.coffee | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index 32fd5bed6742..704e5bbcac74 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -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