diff options
Diffstat (limited to 'js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js')
-rw-r--r-- | js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js b/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js new file mode 100644 index 0000000000..5c4f9a8234 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js @@ -0,0 +1,37 @@ +// |reftest| skip -- legacy-regexp is not supported +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regexp.prototype.compile +description: RegExp.prototype.compile throws a TypeError for cross-realm calls +features: [legacy-regexp,cross-realm] +---*/ + +const other = $262.createRealm().global; + +const regexp = new RegExp(""); +const otherRealm_regexp = new other.RegExp(""); + +assert.throws( + TypeError, + function () { + RegExp.prototype.compile.call(otherRealm_regexp); + }, + "`RegExp.prototype.compile.call(otherRealm_regexp)` throws TypeError" +); + +assert.throws( + other.TypeError, + function () { + other.RegExp.prototype.compile.call(regexp); + }, + "`other.RegExp.prototype.compile.call(regexp)` throws TypeError" +); + +assert.sameValue( + otherRealm_regexp.compile(), + otherRealm_regexp, + "`otherRealm_regexp.compile()` is SameValue with `otherRealm_regexp`" +); + +reportCompare(0, 0); |