tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

match-stub-realms.js (734B)


      1 // Ensure regexp match stub uses the correct realm for the match object and
      2 // the regexp statics.
      3 function test() {
      4    var g1 = newGlobal({sameCompartmentAs: this});
      5    var g2 = newGlobal({sameCompartmentAs: this});
      6    g1.evaluate("function match(s) { return /(.)([\\d]+)/.exec(s); }");
      7    g2.evaluate("function match(s) { return /(.)([\\d]+)/.exec(s); }");
      8    for (var i = 0; i < 25; i++) {
      9        var res1 = g1.match(`A${i}`);
     10        var res2 = g2.match(`B${i}`);
     11        assertEq(objectGlobal(res1), g1);
     12        assertEq(objectGlobal(res2), g2);
     13        assertEq(g1.RegExp.$1, "A");
     14        assertEq(g1.RegExp.$2, String(i));
     15        assertEq(g2.RegExp.$1, "B");
     16        assertEq(g2.RegExp.$2, String(i));
     17    }
     18 }
     19 test();