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

Side by Side Diff: src/promise.js

Issue 194403002: PromiseCoerce should ignore primitive values. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Replacing (typeof x === 'object') with IS_SPEC_OBJECT(x). Created 6 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return x === that ? onReject(MakeTypeError('promise_cyclic', [x])) : 210 return x === that ? onReject(MakeTypeError('promise_cyclic', [x])) :
211 IsPromise(x) ? x.then(onResolve, onReject) : onResolve(x); 211 IsPromise(x) ? x.then(onResolve, onReject) : onResolve(x);
212 }, 212 },
213 onReject 213 onReject
214 ); 214 );
215 } 215 }
216 216
217 PromiseCoerce.table = new $WeakMap; 217 PromiseCoerce.table = new $WeakMap;
218 218
219 function PromiseCoerce(constructor, x) { 219 function PromiseCoerce(constructor, x) {
220 if (!(IsPromise(x) || IS_NULL_OR_UNDEFINED(x))) { 220 if (!IsPromise(x) && IS_SPEC_OBJECT(x)) {
221 var then = x.then; 221 var then = x.then;
222 if (typeof then === 'function') { 222 if (typeof then === 'function') {
223 if (PromiseCoerce.table.has(x)) { 223 if (PromiseCoerce.table.has(x)) {
224 return PromiseCoerce.table.get(x); 224 return PromiseCoerce.table.get(x);
225 } else { 225 } else {
226 var deferred = %_CallFunction(constructor, PromiseDeferred); 226 var deferred = %_CallFunction(constructor, PromiseDeferred);
227 PromiseCoerce.table.set(x, deferred.promise); 227 PromiseCoerce.table.set(x, deferred.promise);
228 try { 228 try {
229 %_CallFunction(x, deferred.resolve, deferred.reject, then); 229 %_CallFunction(x, deferred.resolve, deferred.reject, then);
230 } catch(e) { 230 } catch(e) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 "cast", PromiseCast 299 "cast", PromiseCast
300 ]); 300 ]);
301 InstallFunctions($Promise.prototype, DONT_ENUM, [ 301 InstallFunctions($Promise.prototype, DONT_ENUM, [
302 "chain", PromiseChain, 302 "chain", PromiseChain,
303 "then", PromiseThen, 303 "then", PromiseThen,
304 "catch", PromiseCatch 304 "catch", PromiseCatch
305 ]); 305 ]);
306 } 306 }
307 307
308 SetUpPromise(); 308 SetUpPromise();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698