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