From afc66bcc886c63d72132d9fb0027869271e53735 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Mon, 3 May 2021 12:51:46 +0300 Subject: [PATCH] avoid `Promise.resolve` in the main `Promise` feature detection --- packages/core-js/modules/es.promise.js | 2 +- tests/compat/tests.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core-js/modules/es.promise.js b/packages/core-js/modules/es.promise.js index 071c9b0faacf..61a8e2df498d 100644 --- a/packages/core-js/modules/es.promise.js +++ b/packages/core-js/modules/es.promise.js @@ -65,7 +65,7 @@ var FORCED = isForced(PROMISE, function () { // https://github.com/zloirock/core-js/issues/679 if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false; // Detect correctness of subclassing with @@species support - var promise = PromiseConstructor.resolve(1); + var promise = new PromiseConstructor(function (resolve) { resolve(1); }); var FakePromise = function (exec) { exec(function () { /* empty */ }, function () { /* empty */ }); }; diff --git a/tests/compat/tests.js b/tests/compat/tests.js index 70ebb996e124..32b18d13ba99 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -33,15 +33,15 @@ var DESCRIPTORS_SUPPORT = function () { }; var PROMISES_SUPPORT = function () { - var promise = Promise.resolve(1); + var promise = new Promise(function (resolve) { resolve(1); }); var empty = function () { /* empty */ }; var FakePromise = (promise.constructor = {})[Symbol.species] = function (exec) { exec(empty, empty); }; - return (IS_NODE || typeof PromiseRejectionEvent == 'function') - && promise.then(empty) instanceof FakePromise - && V8_VERSION !== 66; + return promise.then(empty) instanceof FakePromise + && V8_VERSION !== 66 + && (IS_NODE || typeof PromiseRejectionEvent == 'function'); }; var SYMBOLS_SUPPORT = function () {