mirror of https://github.com/tc39/test262.git
Assert iterator protocol for Promise methods
This commit is contained in:
parent
2b5efe135c
commit
c62700c8ef
|
@ -4,8 +4,9 @@
|
|||
/*---
|
||||
description: >
|
||||
Explicit iterator closing in response to error
|
||||
esid: sec-promise.all
|
||||
es6id: 25.4.4.1
|
||||
info: >
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: Promise rejection in response to error
|
||||
esid: sec-promise.all
|
||||
es6id: 25.4.4.1
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
[...]
|
||||
i. Let nextPromise be Invoke(constructor, "resolve", «nextValue»).
|
||||
j. ReturnIfAbrupt(nextPromise ).
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var thrown = new Test262Error();
|
||||
Promise.resolve = function() {
|
||||
throw thrown;
|
||||
};
|
||||
|
||||
Promise.all([1])
|
||||
.then(function() {
|
||||
$ERROR('The promise should not be fulfilled.');
|
||||
}, function(reason) {
|
||||
if (reason !== thrown) {
|
||||
$ERROR('The promise should be rejected with the thrown error object');
|
||||
}
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Error retrieving the constructor's `resolve` method (closing iterator)
|
||||
esid: sec-performpromiseall
|
||||
es6id: 25.4.4.1
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
[...]
|
||||
i. Let nextPromise be Invoke(constructor, "resolve", «nextValue»).
|
||||
j. ReturnIfAbrupt(nextPromise ).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iter = {};
|
||||
var returnCount = 0;
|
||||
iter[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { done: false };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
Object.defineProperty(Promise, 'resolve', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(iter);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Error retrieving the constructor's `resolve` method
|
||||
Error retrieving the constructor's `resolve` method (rejecting promise)
|
||||
esid: sec-performpromiseall
|
||||
es6id: 25.4.4.1
|
||||
info: >
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
|
@ -26,7 +27,7 @@ flags: [async]
|
|||
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(Promise, 'resolve', {
|
||||
get: function() {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when invoking the instance's `then` method (closing iterator)
|
||||
esid: sec-performpromiseall
|
||||
es6id: 25.4.4.1
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
[...]
|
||||
r. Let result be Invoke(nextPromise, "then", «resolveElement,
|
||||
resultCapability.[[Reject]]»).
|
||||
s. ReturnIfAbrupt(result).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var promise = new Promise(function() {});
|
||||
var returnCount = 0;
|
||||
var iter = {};
|
||||
iter[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { done: false, value: promise };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
promise.then = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
Promise.all(iter);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when invoking the instance's `then` method
|
||||
Error thrown when invoking the instance's `then` method (rejecting Promise)
|
||||
esid: sec-performpromiseall
|
||||
es6id: 25.4.4.1
|
||||
info: >
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when accesing the instance's `then` method (closing iterator)
|
||||
esid: sec-performpromiseall
|
||||
es6id: 25.4.4.1
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
[...]
|
||||
r. Let result be Invoke(nextPromise, "then", «resolveElement,
|
||||
resultCapability.[[Reject]]»).
|
||||
s. ReturnIfAbrupt(result).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var promise = new Promise(function() {});
|
||||
var returnCount = 0;
|
||||
var iter = {};
|
||||
iter[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { done: false, value: promise };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Object.defineProperty(promise, 'then', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(iter);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when accessing the instance's `then` method (rejecting Promise)
|
||||
esid: sec-performpromiseall
|
||||
es6id: 25.4.4.1
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
[...]
|
||||
r. Let result be Invoke(nextPromise, "then", «resolveElement,
|
||||
resultCapability.[[Reject]]»).
|
||||
s. ReturnIfAbrupt(result).
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var promise = new Promise(function() {});
|
||||
var error = new Test262Error();
|
||||
|
||||
Object.defineProperty(promise, 'then', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.all
|
||||
es6id: 25.4.4.1
|
||||
description: >
|
||||
Error when accessing an iterator result's `value` property (not closing
|
||||
iterator)
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
[...]
|
||||
e. Let nextValue be IteratorValue(next).
|
||||
f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
|
||||
true.
|
||||
g. ReturnIfAbrupt(nextValue).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iterNextValThrows = {};
|
||||
var returnCount = 0;
|
||||
var poisonedVal = {
|
||||
done: false
|
||||
};
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(poisonedVal, 'value', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
iterNextValThrows[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return poisonedVal;
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Promise.all(iterNextValThrows);
|
||||
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -2,10 +2,12 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Error when accessing an iterator result's `value` property
|
||||
esid: sec-promise.all
|
||||
es6id: 25.4.4.1
|
||||
info: >
|
||||
description: >
|
||||
Error when accessing an iterator result's `value` property (rejecting
|
||||
promise)
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-promise.all
|
||||
es6id: 25.4.4.1
|
||||
description: >
|
||||
Error when advancing the provided iterable (not closing iterator)
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||
|
||||
[...]
|
||||
6. Repeat
|
||||
a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
|
||||
b. If next is an abrupt completion, set iteratorRecord.[[done]] to
|
||||
true.
|
||||
c. ReturnIfAbrupt(next).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iterStepThrows = {};
|
||||
var poisonedDone = {};
|
||||
var returnCount = 0;
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(poisonedDone, 'done', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(poisonedDone, 'value', {
|
||||
get: function() {
|
||||
$ERROR('The `value` property should not be accessed.');
|
||||
}
|
||||
});
|
||||
|
||||
iterStepThrows[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return poisonedDone;
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Promise.all(iterStepThrows);
|
||||
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -2,10 +2,11 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Error when advancing the provided iterable
|
||||
esid: sec-promise.all
|
||||
es6id: 25.4.4.1
|
||||
info: >
|
||||
description: >
|
||||
Error when advancing the provided iterable (rejecting promise)
|
||||
info: |
|
||||
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Explicit iterator closing in response to error from `Promise.resolve`
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
[...]
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||
12. If result is an abrupt completion, then
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator,result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
|
||||
1. Repeat
|
||||
[...]
|
||||
h. Let nextPromise be Invoke(C, "resolve", «nextValue»).
|
||||
i. ReturnIfAbrupt(nextPromise).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iterDoneSpy = {};
|
||||
var returnCount = 0;
|
||||
iterDoneSpy[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { value: null, done: false };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Promise.resolve = function() {
|
||||
throw err;
|
||||
};
|
||||
|
||||
Promise.race(iterDoneSpy);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -2,10 +2,11 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Explicit iterator closing in response to error
|
||||
description: Promise rejection in response to error from `Promise.resolve`
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: >
|
||||
info: |
|
||||
[...]
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||
12. If result is an abrupt completion, then
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
|
@ -19,37 +20,22 @@ info: >
|
|||
[...]
|
||||
h. Let nextPromise be Invoke(C, "resolve", «nextValue»).
|
||||
i. ReturnIfAbrupt(nextPromise).
|
||||
features: [Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var err = new Test262Error();
|
||||
var iterDoneSpy = {};
|
||||
var callCount = 0;
|
||||
var CustomPromise = function(executor) {
|
||||
return new Promise(executor);
|
||||
};
|
||||
iterDoneSpy[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { value: null, done: false };
|
||||
},
|
||||
return: function() {
|
||||
callCount += 1;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
CustomPromise.resolve = function() {
|
||||
throw err;
|
||||
};
|
||||
|
||||
Promise.race.call(CustomPromise, iterDoneSpy)
|
||||
Promise.race.call(CustomPromise, [1])
|
||||
.then(function() {
|
||||
$ERROR('The promise should be rejected.');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, err);
|
||||
$DONE();
|
||||
});
|
||||
|
||||
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Error retrieving the constructor's `resolve` method (iterator closing)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
|
||||
1. Repeat
|
||||
[...]
|
||||
h. Let nextPromise be Invoke(C, "resolve", «nextValue»).
|
||||
i. ReturnIfAbrupt(nextPromise).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iter = {};
|
||||
var returnCount = 0;
|
||||
iter[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { done: false };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
Object.defineProperty(Promise, 'resolve', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
Promise.race(iter);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Error retrieving the constructor's `resolve` method
|
||||
Error retrieving the constructor's `resolve` method (promise rejection)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: >
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
|
@ -25,7 +26,7 @@ flags: [async]
|
|||
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(Promise, 'resolve', {
|
||||
get: function() {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when invoking the instance's `then` method (closing iterator)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
|
||||
1. Repeat
|
||||
[...]
|
||||
j. Let result be Invoke(nextPromise, "then",
|
||||
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||
k. ReturnIfAbrupt(result).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var promise = new Promise(function() {});
|
||||
var iter = {};
|
||||
var returnCount = 0;
|
||||
iter[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { done: false, value: promise };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
promise.then = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
Promise.race(iter);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when invoking the instance's `then` method
|
||||
Error thrown when invoking the instance's `then` method (rejecting promise)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: >
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when accessing the instance's `then` method (closing iterator)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
|
||||
1. Repeat
|
||||
[...]
|
||||
j. Let result be Invoke(nextPromise, "then",
|
||||
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||
k. ReturnIfAbrupt(result).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var promise = new Promise(function() {});
|
||||
var iter = {};
|
||||
var returnCount = 0;
|
||||
iter[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { done: false, value: promise };
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
Object.defineProperty(promise, 'then', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
Promise.race(iter);
|
||||
|
||||
assert.sameValue(returnCount, 1);
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Error thrown when accessing the instance's `then` method (rejecting promise)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
|
||||
1. Repeat
|
||||
[...]
|
||||
j. Let result be Invoke(nextPromise, "then",
|
||||
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||
k. ReturnIfAbrupt(result).
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
var promise = new Promise(function() {});
|
||||
var error = new Test262Error();
|
||||
|
||||
Object.defineProperty(promise, 'then', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
Promise.race([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Error when accessing an iterator result's `value` property (not closing
|
||||
iterator)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator, result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
[...]
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
|
||||
1. Repeat
|
||||
[...]
|
||||
e. Let nextValue be IteratorValue(next).
|
||||
f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
|
||||
true.
|
||||
g. ReturnIfAbrupt(nextValue).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iterNextValThrows = {};
|
||||
var returnCount = 0;
|
||||
var poisonedVal = {
|
||||
done: false
|
||||
};
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(poisonedVal, 'value', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
iterNextValThrows[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return poisonedVal;
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Promise.race(iterNextValThrows);
|
||||
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Error when accessing an iterator result's `value` property
|
||||
Error when accessing an iterator result's `value` property (rejecting
|
||||
promise)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: >
|
||||
info: |
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
12. If result is an abrupt completion,
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Error when advancing the provided iterable (not closing iterator)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: |
|
||||
[...]
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||
12. If result is an abrupt completion, then
|
||||
a. If iteratorRecord.[[done]] is false, let result be
|
||||
IteratorClose(iterator,result).
|
||||
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||
|
||||
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||
1. Repeat
|
||||
a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
|
||||
b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
|
||||
c. ReturnIfAbrupt(next).
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var iterStepThrows = {};
|
||||
var poisonedDone = {};
|
||||
var returnCount = 0;
|
||||
var error = new Test262Error();
|
||||
Object.defineProperty(poisonedDone, 'done', {
|
||||
get: function() {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(poisonedDone, 'value', {
|
||||
get: function() {
|
||||
$ERROR('The `value` property should not be accessed.');
|
||||
}
|
||||
});
|
||||
|
||||
iterStepThrows[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return poisonedDone;
|
||||
},
|
||||
return: function() {
|
||||
returnCount += 1;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Promise.race(iterStepThrows);
|
||||
|
||||
assert.sameValue(returnCount, 0);
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
/*---
|
||||
description: >
|
||||
Error when advancing the provided iterable
|
||||
Error when advancing the provided iterable (rejecting promise)
|
||||
esid: sec-promise.race
|
||||
es6id: 25.4.4.3
|
||||
info: >
|
||||
info: |
|
||||
[...]
|
||||
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||
12. If result is an abrupt completion, then
|
Loading…
Reference in New Issue