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