Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/escape/cross-realm.js

raw
1 // |reftest| shell-option(--enable-regexp-escape) skip-if(!RegExp.escape||!xulRuntime.shell) -- RegExp.escape is not enabled unconditionally, requires shell-options
2 // Copyright 2024 Leo Balter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-regexp.escape
7 description: escape called with a RegExp object from another realm
8 features: [RegExp.escape, cross-realm]
9 ---*/
10
11 const str = "oi+hello";
12 const other = $262.createRealm().global;
13
14 assert.sameValue(typeof other.RegExp.escape, "function", "other.RegExp.escape is a function");
15
16 const res = other.RegExp.escape.call(RegExp, str);
17
18 assert.sameValue(res, RegExp.escape(str), "cross-realm escape works correctly");
19
20 reportCompare(0, 0);