未验证 提交 a95d76af 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #49034 from Microsoft/chrmarti/promiseinterop

WinJS and ES6 Promises
......@@ -1038,6 +1038,12 @@ _winjs("WinJS/Promise/_StateMachine", ["WinJS/Core/_Global","WinJS/Core/_BaseCor
/// error function.
/// </returns>
/// </signature>
// BEGIN monaco change
if (this.then !== Promise_then) {
this.then(onComplete, onError, onProgress);
return;
}
// END monaco change
return this._state.then(this, onComplete, onError, onProgress);
},
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import * as WinJS from 'vs/base/common/winjs.base';
suite('WinJS and ES6 Promises', function () {
test('Promise.resolve', function () {
let resolveTPromise;
const tPromise = new WinJS.Promise(function (c, e, p) {
resolveTPromise = c;
});
const es6Promise = Promise.resolve(tPromise);
const done = es6Promise.then(function (result) {
assert.equal(result, 'passed');
});
resolveTPromise('passed');
return done;
});
test('new Promise', function () {
let resolveTPromise;
const tPromise = new WinJS.Promise(function (c, e, p) {
resolveTPromise = c;
});
const es6Promise = new Promise(function (c, e) {
c(tPromise);
});
const done = es6Promise.then(function (result) {
assert.equal(result, 'passed');
});
resolveTPromise('passed');
return done;
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册