summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js
blob: 5c4f9a82340e42c1dcc6a336cf49ff77962b1ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);