This commit is contained in:
legendecas 2021-10-08 14:18:12 +08:00 committed by Rick Waldron
parent fc3878f0a4
commit e9cea2125c
2 changed files with 9 additions and 4 deletions

View File

@ -14,14 +14,19 @@ assert.sameValue(
);
var other = $262.createRealm().global;
var OtherTypeError = other.eval('TypeError');
var OtherShadowRealm = other.eval('ShadowRealm');
var OtherTypeError = other.TypeError;
var OtherSyntaxError = other.SyntaxError;
var OtherShadowRealm = other.ShadowRealm;
var realm = Reflect.construct(OtherShadowRealm, []);
assert.throws(OtherTypeError, () => realm.evaluate('globalThis'), 'throws a TypeError if return value can not be wrapped');
assert.throws(OtherTypeError, () => realm.evaluate('throw new Error()'), 'throws a TypeError if completion is abrupt');
assert.throws(OtherTypeError, () => realm.evaluate(1), 'throws a TypeError if sourceText is not a string');
assert.throws(OtherSyntaxError, () => realm.evaluate('...'), 'throws a SyntaxError if the sourceText is not valid');
const bogus = {};
assert.throws(OtherTypeError, function() {
realm.evaluate.call(bogus, '');
realm.evaluate.call(bogus, 'This is invalid code and should not be evaluated');
}, 'throws a TypeError if this is not a ShadowRealm object');

View File

@ -17,5 +17,5 @@ const r = new ShadowRealm();
const bogus = {};
assert.throws(TypeError, function() {
r.evaluate.call(bogus, '');
r.evaluate.call(bogus, 'This is invalid code and should not be evaluated');
}, 'throws a TypeError if this is not a ShadowRealm object');