Fix: AggregateError/newtarget-proto-fallback. Closes gh-2515 (#2518)

This commit is contained in:
Rick Waldron 2020-03-10 21:08:07 -04:00 committed by GitHub
parent 800870cbb8
commit 36882a28e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 12 deletions

View File

@ -30,33 +30,29 @@ info: |
features: [AggregateError, Symbol]
---*/
var custom = { x: 42 };
var ctor = function() {};
Object.setPrototypeOf(ctor, custom);
var values = [
const values = [
undefined,
null,
42,
false,
true,
Symbol(),
'string'
'string',
AggregateError.prototype,
];
const NewTarget = new Function();
for (const value of values) {
const newt = new Proxy(ctor, {
const NewTargetProxy = new Proxy(NewTarget, {
get(t, p) {
if (p === 'prototype') {
return value;
}
return t[p];
}
});
const obj = Reflect.construct(AggregateError, [[]], newt);
assert.sameValue(Object.getPrototypeOf(obj), custom);
assert.sameValue(obj.x, 42);
const error = Reflect.construct(AggregateError, [[]], NewTargetProxy);
assert.sameValue(Object.getPrototypeOf(error), AggregateError.prototype);
}