mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 1343363 - Check RegExp wasn't modified in RegExp.p.@@replace global elem-base optimized path. r=till
This commit is contained in:
parent
10b72ec89d
commit
760dd32599
@ -31,7 +31,7 @@ function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
|
||||
var lastIndex = 0;
|
||||
rx.lastIndex = 0;
|
||||
|
||||
#if defined(FUNCTIONAL)
|
||||
#if defined(FUNCTIONAL) || defined(ELEMBASE)
|
||||
// Save the original source and flags, so we can check if the replacer
|
||||
// function recompiled the regexp.
|
||||
var originalSource = UnsafeGetStringFromReservedSlot(rx, REGEXP_SOURCE_SLOT);
|
||||
@ -109,7 +109,7 @@ function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(FUNCTIONAL)
|
||||
#if defined(FUNCTIONAL) || defined(ELEMBASE)
|
||||
// Ensure the current source and flags match the original regexp, the
|
||||
// replaceValue function may have called RegExp#compile.
|
||||
if (UnsafeGetStringFromReservedSlot(rx, REGEXP_SOURCE_SLOT) !== originalSource ||
|
||||
|
22
js/src/tests/ecma_6/RegExp/replace-compile-elembase.js
Normal file
22
js/src/tests/ecma_6/RegExp/replace-compile-elembase.js
Normal file
@ -0,0 +1,22 @@
|
||||
(function() {
|
||||
var rx = /a/g;
|
||||
var b = {
|
||||
get a() {
|
||||
rx.compile("b");
|
||||
return "A";
|
||||
}
|
||||
};
|
||||
|
||||
// Replacer function which is applicable for the elem-base optimization in
|
||||
// RegExp.prototype.@@replace.
|
||||
function replacer(a) {
|
||||
return b[a];
|
||||
}
|
||||
|
||||
var result = rx[Symbol.replace]("aaa", replacer);
|
||||
|
||||
assertEq(result, "AAA");
|
||||
})();
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
Loading…
Reference in New Issue
Block a user