| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 (function(global, utils, extrasUtils) { | 5 (function(global, utils, extrasUtils) { | 
| 6 | 6 | 
| 7 "use strict"; | 7 "use strict"; | 
| 8 | 8 | 
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); | 
| 10 | 10 | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 143     // equivalent to throwing an exception directly. | 143     // equivalent to throwing an exception directly. | 
| 144     %PromiseRejectEventFromStack(promise, r); | 144     %PromiseRejectEventFromStack(promise, r); | 
| 145     return promise; | 145     return promise; | 
| 146   } else { | 146   } else { | 
| 147     var promiseCapability = NewPromiseCapability(this, true); | 147     var promiseCapability = NewPromiseCapability(this, true); | 
| 148     %_Call(promiseCapability.reject, UNDEFINED, r); | 148     %_Call(promiseCapability.reject, UNDEFINED, r); | 
| 149     return promiseCapability.promise; | 149     return promiseCapability.promise; | 
| 150   } | 150   } | 
| 151 } | 151 } | 
| 152 | 152 | 
| 153 // ES#sec-promise.prototype.catch |  | 
| 154 // Promise.prototype.catch ( onRejected ) |  | 
| 155 function PromiseCatch(onReject) { |  | 
| 156   return this.then(UNDEFINED, onReject); |  | 
| 157 } |  | 
| 158 |  | 
| 159 // Combinators. | 153 // Combinators. | 
| 160 | 154 | 
| 161 // ES#sec-promise.resolve | 155 // ES#sec-promise.resolve | 
| 162 // Promise.resolve ( x ) | 156 // Promise.resolve ( x ) | 
| 163 function PromiseResolve(x) { | 157 function PromiseResolve(x) { | 
| 164   if (!IS_RECEIVER(this)) { | 158   if (!IS_RECEIVER(this)) { | 
| 165     throw %make_type_error(kCalledOnNonObject, PromiseResolve); | 159     throw %make_type_error(kCalledOnNonObject, PromiseResolve); | 
| 166   } | 160   } | 
| 167   if (%is_promise(x) && x.constructor === this) return x; | 161   if (%is_promise(x) && x.constructor === this) return x; | 
| 168 | 162 | 
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 353 | 347 | 
| 354 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ | 348 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ | 
| 355   "reject", PromiseReject, | 349   "reject", PromiseReject, | 
| 356   "all", PromiseAll, | 350   "all", PromiseAll, | 
| 357   "race", PromiseRace, | 351   "race", PromiseRace, | 
| 358   "resolve", PromiseResolve | 352   "resolve", PromiseResolve | 
| 359 ]); | 353 ]); | 
| 360 | 354 | 
| 361 utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies); | 355 utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies); | 
| 362 | 356 | 
| 363 %SetCode(GlobalPromise.prototype.catch, PromiseCatch); |  | 
| 364 |  | 
| 365 %InstallToContext([ | 357 %InstallToContext([ | 
| 366   "promise_catch", GlobalPromise.prototype.catch, |  | 
| 367   "promise_create", PromiseCreate, | 358   "promise_create", PromiseCreate, | 
| 368   "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, | 359   "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, | 
| 369   "promise_reject", DoRejectPromise, | 360   "promise_reject", DoRejectPromise, | 
| 370   // TODO(gsathya): Remove this once we update the promise builtin. | 361   // TODO(gsathya): Remove this once we update the promise builtin. | 
| 371   "promise_internal_reject", RejectPromise, | 362   "promise_internal_reject", RejectPromise, | 
| 372   "promise_debug_get_info", PromiseDebugGetInfo, | 363   "promise_debug_get_info", PromiseDebugGetInfo, | 
| 373   "new_promise_capability", NewPromiseCapability, | 364   "new_promise_capability", NewPromiseCapability, | 
| 374   "internal_promise_capability", CreateInternalPromiseCapability, | 365   "internal_promise_capability", CreateInternalPromiseCapability, | 
| 375   "promise_id_resolve_handler", PromiseIdResolveHandler, | 366   "promise_id_resolve_handler", PromiseIdResolveHandler, | 
| 376   "promise_id_reject_handler", PromiseIdRejectHandler | 367   "promise_id_reject_handler", PromiseIdRejectHandler | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 387 | 378 | 
| 388 utils.Export(function(to) { | 379 utils.Export(function(to) { | 
| 389   to.PromiseCreate = PromiseCreate; | 380   to.PromiseCreate = PromiseCreate; | 
| 390   to.PromiseThen = PromiseThen; | 381   to.PromiseThen = PromiseThen; | 
| 391 | 382 | 
| 392   to.CreateInternalPromiseCapability = CreateInternalPromiseCapability; | 383   to.CreateInternalPromiseCapability = CreateInternalPromiseCapability; | 
| 393   to.RejectPromise = RejectPromise; | 384   to.RejectPromise = RejectPromise; | 
| 394 }); | 385 }); | 
| 395 | 386 | 
| 396 }) | 387 }) | 
| OLD | NEW | 
|---|