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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (!IS_CALLABLE(result.resolve) || !IS_CALLABLE(result.reject)) | 119 if (!IS_CALLABLE(result.resolve) || !IS_CALLABLE(result.reject)) |
120 throw %make_type_error(kPromiseNonCallable); | 120 throw %make_type_error(kPromiseNonCallable); |
121 | 121 |
122 return result; | 122 return result; |
123 } | 123 } |
124 | 124 |
125 // ES#sec-promise.reject | 125 // ES#sec-promise.reject |
126 // Promise.reject ( x ) | 126 // Promise.reject ( x ) |
127 function PromiseReject(r) { | 127 function PromiseReject(r) { |
128 if (!IS_RECEIVER(this)) { | 128 if (!IS_RECEIVER(this)) { |
129 throw %make_type_error(kCalledOnNonObject, PromiseResolve); | 129 throw %make_type_error(kCalledOnNonObject, PromiseReject); |
130 } | 130 } |
131 if (this === GlobalPromise) { | 131 if (this === GlobalPromise) { |
132 // Optimized case, avoid extra closure. | 132 // Optimized case, avoid extra closure. |
133 var promise = %promise_create_and_set(kRejected, r); | 133 var promise = %promise_create_and_set(kRejected, r); |
134 // Trigger debug events if the debugger is on, as Promise.reject is | 134 // Trigger debug events if the debugger is on, as Promise.reject is |
135 // equivalent to throwing an exception directly. | 135 // equivalent to throwing an exception directly. |
136 %PromiseRejectEventFromStack(promise, r); | 136 %PromiseRejectEventFromStack(promise, r); |
137 return promise; | 137 return promise; |
138 } else { | 138 } else { |
139 var promiseCapability = NewPromiseCapability(this, true); | 139 var promiseCapability = NewPromiseCapability(this, true); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ]); | 362 ]); |
363 | 363 |
364 utils.Export(function(to) { | 364 utils.Export(function(to) { |
365 to.PromiseCreate = PromiseCreate; | 365 to.PromiseCreate = PromiseCreate; |
366 | 366 |
367 to.CreateInternalPromiseCapability = CreateInternalPromiseCapability; | 367 to.CreateInternalPromiseCapability = CreateInternalPromiseCapability; |
368 to.RejectPromise = RejectPromise; | 368 to.RejectPromise = RejectPromise; |
369 }); | 369 }); |
370 | 370 |
371 }) | 371 }) |
OLD | NEW |