Fix the this argument passed to string replace callbacks.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg@inf.u-szeged.hu
This commit is contained in:
Zoltan Herczeg
2015-08-11 04:07:34 -07:00
parent c6b4510c9a
commit f2c846d960
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -72,6 +72,24 @@ catch (e)
assert ("\ud801\udc00".replace("\ud801", "#") === "#\udc00");
assert ("\ud801\udc00".replace("\udc00", "#") === "\ud801#");
var global = this;
function case1()
{
assert(this === global);
return "y";
}
function case2()
{
"use strict";
assert(this === undefined);
return "y";
}
assert ("x".replace("x", case1) === "y");
assert ("x".replace("x", case2) === "y");
var regexp = /r/g;
Object.defineProperty(regexp, "lastIndex", {