Debian Codegraph @

js/src/tests/test262/annexB/built-ins/RegExp/legacy-accessors/lastMatch/this-cross-realm-constructor.js

raw
1 // |reftest| skip -- legacy-regexp is not supported
2 // Copyright (C) 2020 ExE Boss. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: pending
6 description: RegExp.lastMatch throws a TypeError for cross-realm receiver
7 info: |
8 get RegExp.lastMatch
9
10 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpLastMatch]]).
11
12 GetLegacyRegExpStaticProperty( C, thisValue, internalSlotName ).
13
14 1. Assert C is an object that has an internal slot named internalSlotName.
15 2. If SameValue(C, thisValue) is false, throw a TypeError exception.
16 3. ...
17 features: [legacy-regexp,cross-realm,Reflect]
18 ---*/
19
20 const other = $262.createRealm().global;
21
22 assert.throws(
23 TypeError,
24 function () {
25 Reflect.get(RegExp, "lastMatch", other.RegExp);
26 },
27 "RegExp.lastMatch getter throws for cross-realm receiver"
28 );
29
30 assert.throws(
31 TypeError,
32 function () {
33 Reflect.get(RegExp, "$&", other.RegExp);
34 },
35 "RegExp.$& getter throws for cross-realm receiver"
36 );
37
38 reportCompare(0, 0);