Fix ShadowRealm.prototype.evaluate wraps value in the builtin function realm

This commit is contained in:
legendecas 2021-10-29 14:27:11 +08:00 committed by Rick Waldron
parent 4cb032dc32
commit 37e2c66420
1 changed files with 3 additions and 2 deletions

View File

@ -33,6 +33,7 @@ assert.sameValue(
var other = $262.createRealm().global;
var OtherShadowRealm = other.ShadowRealm;
var OtherFunctionPrototype = other.Function.prototype;
var realm = Reflect.construct(OtherShadowRealm, []);
@ -40,5 +41,5 @@ var checkArgWrapperFn = realm.evaluate('(x) => { return Object.getPrototypeOf(x)
assert.sameValue(checkArgWrapperFn(() => {}), true, 'callable arguments passed into WrappedFunction should be wrapped in target realm');
var fn = realm.evaluate('() => { return () => { return 1 } }');
assert.sameValue(Object.getPrototypeOf(fn), Function.prototype, 'WrappedFunction should be derived from the caller realm');
assert.sameValue(Object.getPrototypeOf(fn()), Function.prototype, 'callable results from WrappedFunction should be wrapped in caller realm');
assert.sameValue(Object.getPrototypeOf(fn), OtherFunctionPrototype, 'WrappedFunction should be derived from the caller realm');
assert.sameValue(Object.getPrototypeOf(fn()), OtherFunctionPrototype, 'callable results from WrappedFunction should be wrapped in caller realm');