diff --git a/closure/goog/async/run.js b/closure/goog/async/run.js index 18a09df8f2..b649971e5d 100644 --- a/closure/goog/async/run.js +++ b/closure/goog/async/run.js @@ -23,7 +23,7 @@ goog.require('goog.async.throwException'); * assuming either the native, or polyfill version will be used. Does still * permit tests to use forceNextTick. */ -goog.ASSUME_NATIVE_PROMISE = goog.define('goog.ASSUME_NATIVE_PROMISE', false); +goog.ASSUME_NATIVE_PROMISE = true; /** * Fires the provided callback just before the current callstack unwinds, or as @@ -52,21 +52,10 @@ goog.async.run = function(callback, opt_context) { * @private */ goog.async.run.initializeRunner_ = function() { - if (goog.ASSUME_NATIVE_PROMISE || - (goog.global.Promise && goog.global.Promise.resolve)) { - // Use goog.global.Promise instead of just Promise because the relevant - // externs may be missing, and don't alias it because this could confuse the - // compiler into thinking the polyfill is required when it should be treated - // as optional. - var promise = goog.global.Promise.resolve(undefined); + var promise = Promise.resolve(undefined); goog.async.run.schedule_ = function() { promise.then(goog.async.run.processWorkQueue); }; - } else { - goog.async.run.schedule_ = function() { - goog.async.nextTick(goog.async.run.processWorkQueue); - }; - } }; diff --git a/closure/goog/timer/timer.js b/closure/goog/timer/timer.js index 1baf6a2f72..792aced51a 100644 --- a/closure/goog/timer/timer.js +++ b/closure/goog/timer/timer.js @@ -21,7 +21,6 @@ goog.provide('goog.Timer'); -goog.require('goog.Promise'); goog.require('goog.events.EventTarget'); @@ -301,23 +300,22 @@ goog.Timer.clear = function(timerId) { /** * @param {number} delay Milliseconds to wait. - * @param {(RESULT|goog.Thenable|Thenable)=} opt_result The value + * @param {(RESULT|Thenable)=} opt_result The value * with which the promise will be resolved. - * @return {!goog.Promise} A promise that will be resolved after + * @return {!Promise} A promise that will be resolved after * the specified delay, unless it is canceled first. * @template RESULT */ goog.Timer.promise = function(delay, opt_result) { var timerKey = null; - return new goog - .Promise(function(resolve, reject) { + return new Promise(function(resolve, reject) { timerKey = goog.Timer.callOnce(function() { resolve(opt_result); }, delay); if (timerKey == goog.Timer.INVALID_TIMEOUT_ID_) { reject(new Error('Failed to schedule timer.')); } }) - .thenCatch(function(error) { + .catch(function(error) { // Clear the timer. The most likely reason is "cancel" signal. goog.Timer.clear(timerKey); throw error;