Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: src/js/promise.js

Issue 2596553002: [promises] Move Promise.prototype.catch to TF (Closed)
Patch Set: revert changes to test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698