Assert error when invoking RegExp source getter on cross-realm RegExp.prototype

RegExp.prototype is not a RegExp, and the algorithm only special-cases
(same-realm) %RegExpPrototype%.
This commit is contained in:
Richard Gibson 2018-10-30 11:27:37 -04:00 committed by Rick Waldron
parent be4c8a5c4e
commit 823af01575
1 changed files with 6 additions and 0 deletions

View File

@ -13,6 +13,8 @@ info: |
---*/
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
var otherRealm = $262.createRealm().global;
var otherRealmRegExpProto = otherRealm.RegExp.prototype;
assert.throws(TypeError, function() {
get.call({});
@ -25,3 +27,7 @@ assert.throws(TypeError, function() {
assert.throws(TypeError, function() {
get.call(arguments);
}, 'arguments object');
assert.throws(TypeError, function() {
get.call(otherRealmRegExpProto);
}, 'cross-realm RegExp.prototype');