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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 230 } |
231 | 231 |
232 var result = {promise: UNDEFINED, resolve: UNDEFINED, reject: UNDEFINED }; | 232 var result = {promise: UNDEFINED, resolve: UNDEFINED, reject: UNDEFINED }; |
233 result.promise = new C((resolve, reject) => { | 233 result.promise = new C((resolve, reject) => { |
234 if (!IS_UNDEFINED(result.resolve) || !IS_UNDEFINED(result.reject)) | 234 if (!IS_UNDEFINED(result.resolve) || !IS_UNDEFINED(result.reject)) |
235 throw MakeTypeError(kPromiseExecutorAlreadyInvoked); | 235 throw MakeTypeError(kPromiseExecutorAlreadyInvoked); |
236 result.resolve = resolve; | 236 result.resolve = resolve; |
237 result.reject = reject; | 237 result.reject = reject; |
238 }); | 238 }); |
239 | 239 |
240 if (!IS_CALLABLE(result.resolve)) | |
241 throw MakeTypeError(kCalledNonCallable, "promiseCapability.[[Resolve]]"); | |
242 if (!IS_CALLABLE(result.reject)) | |
243 throw MakeTypeError(kCalledNonCallable, "promiseCapability.[[Reject]]"); | |
244 | |
245 return result; | 240 return result; |
246 } | 241 } |
247 | 242 |
248 function PromiseDeferred() { | 243 function PromiseDeferred() { |
249 %IncrementUseCounter(kPromiseDefer); | 244 %IncrementUseCounter(kPromiseDefer); |
250 return NewPromiseCapability(this); | 245 return NewPromiseCapability(this); |
251 } | 246 } |
252 | 247 |
253 function PromiseResolved(x) { | 248 function PromiseResolved(x) { |
254 %IncrementUseCounter(kPromiseAccept); | 249 %IncrementUseCounter(kPromiseAccept); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( | 470 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( |
476 fn => %FunctionRemovePrototype(fn)); | 471 fn => %FunctionRemovePrototype(fn)); |
477 | 472 |
478 utils.Export(function(to) { | 473 utils.Export(function(to) { |
479 to.PromiseChain = PromiseChain; | 474 to.PromiseChain = PromiseChain; |
480 to.PromiseDeferred = PromiseDeferred; | 475 to.PromiseDeferred = PromiseDeferred; |
481 to.PromiseResolved = PromiseResolved; | 476 to.PromiseResolved = PromiseResolved; |
482 }); | 477 }); |
483 | 478 |
484 }) | 479 }) |
OLD | NEW |