Test cross-realm use of RegExp source getter in both directions

This commit is contained in:
Richard Gibson 2018-10-30 14:04:19 -04:00 committed by Rick Waldron
parent 823af01575
commit 9e0410814a
1 changed files with 8 additions and 3 deletions

View File

@ -13,8 +13,9 @@ info: |
---*/
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
var otherRealm = $262.createRealm().global;
var otherRealmRegExpProto = otherRealm.RegExp.prototype;
var other = $262.createRealm().global;
var otherRegExpProto = other.RegExp.prototype;
var otherRegExpGetter = Object.getOwnPropertyDescriptor(otherRegExpProto, 'source').get;
assert.throws(TypeError, function() {
get.call({});
@ -29,5 +30,9 @@ assert.throws(TypeError, function() {
}, 'arguments object');
assert.throws(TypeError, function() {
get.call(otherRealmRegExpProto);
get.call(otherRegExpProto);
}, 'cross-realm RegExp.prototype');
assert.throws(other.TypeError, function() {
otherRegExpGetter.call(RegExp.prototype);
}, 'cross-realm RegExp.prototype getter method against primary realm RegExp.prototype');