reentrant-RegExp-creation-and-gc-during-new-RegExp-pattern-ToString.js (1188B)
1 // |reftest| skip-if(!xulRuntime.shell) -- needs gc (newGlobal/evaluate are shimmed) 2 /* 3 * Any copyright is dedicated to the Public Domain. 4 * http://creativecommons.org/licenses/publicdomain/ 5 */ 6 7 var gTestfile = 8 "reentrant-RegExp-creation-and-gc-during-new-RegExp-pattern-ToString.js"; 9 //----------------------------------------------------------------------------- 10 var BUGNUMBER = 1253099; 11 var summary = 12 "Don't assert when, in |new RegExp(pat)|, stringifying |pat| creates " + 13 "another RegExp and then performs a GC"; 14 15 print(BUGNUMBER + ": " + summary); 16 17 /************** 18 * BEGIN TEST * 19 **************/ 20 21 // The fresh global object is required to ensure that the outer |new RegExp| 22 // is the first RegExp created in the global (other than RegExp.prototype). 23 newGlobal().evaluate(` 24 var createsRegExpAndCallsGCWhenStringified = 25 { 26 toString: function() { 27 new RegExp("a"); 28 gc(); 29 return "q"; 30 } 31 }; 32 33 assertEq(new RegExp(createsRegExpAndCallsGCWhenStringified).source, "q"); 34 `); 35 36 /******************************************************************************/ 37 38 if (typeof reportCompare === "function") 39 reportCompare(true, true); 40 41 print("Tests complete");