Skip to content

Commit

Permalink
[Fix] Promise: Make sure to shim broken implementations in Chrome 4…
Browse files Browse the repository at this point in the history
…9 Canary.
  • Loading branch information
ljharb committed Nov 23, 2015
1 parent 0f85d9f commit b59ea76
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion es6-shim.js
Expand Up @@ -2418,8 +2418,22 @@
return count === 1;
}());

var BadResolverPromise = function BadResolverPromise(executor) {
var p = new Promise(executor);
executor(3, function () {});
this.then = p.then;
this.constructor = BadResolverPromise;
};
BadResolverPromise.prototype = Promise.prototype;
BadResolverPromise.all = Promise.all;
// Chrome Canary 49 (probably older too) has some implementation bugs
var hasBadResolverPromise = valueOrFalseIfThrows(function () {
return !!BadResolverPromise.all([1, 2]);
});

if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks ||
!promiseRequiresObjectContext || promiseResolveBroken || !getsThenSynchronously) {
!promiseRequiresObjectContext || promiseResolveBroken ||
!getsThenSynchronously || hasBadResolverPromise) {
/*globals Promise: true */
/* eslint-disable no-undef */
Promise = PromiseShim;
Expand Down

0 comments on commit b59ea76

Please sign in to comment.