mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1135560 - Number.{parseInt, parseFloat} should be the same functions as global ones. r=till
This commit is contained in:
parent
202ee444c6
commit
5e6372e540
@ -459,8 +459,6 @@ js::num_parseInt(JSContext *cx, unsigned argc, Value *vp)
|
||||
static const JSFunctionSpec number_functions[] = {
|
||||
JS_SELF_HOSTED_FN(js_isNaN_str, "Global_isNaN", 1,0),
|
||||
JS_SELF_HOSTED_FN(js_isFinite_str, "Global_isFinite", 1,0),
|
||||
JS_FN(js_parseFloat_str, num_parseFloat, 1,0),
|
||||
JS_FN(js_parseInt_str, num_parseInt, 2,0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
@ -1029,8 +1027,6 @@ static const JSFunctionSpec number_static_methods[] = {
|
||||
JS_FN("isInteger", Number_isInteger, 1, 0),
|
||||
JS_SELF_HOSTED_FN("isNaN", "Number_isNaN", 1,0),
|
||||
JS_SELF_HOSTED_FN("isSafeInteger", "Number_isSafeInteger", 1,0),
|
||||
JS_FN("parseFloat", num_parseFloat, 1, 0),
|
||||
JS_FN("parseInt", num_parseInt, 2, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
@ -1201,6 +1197,24 @@ js_InitNumberClass(JSContext *cx, HandleObject obj)
|
||||
if (!JS_DefineFunctions(cx, global, number_functions))
|
||||
return nullptr;
|
||||
|
||||
/* Number.parseInt should be the same function object as global parseInt. */
|
||||
RootedId parseIntId(cx, NameToId(cx->names().parseInt));
|
||||
JSFunction *parseInt = DefineFunction(cx, global, parseIntId, num_parseInt, 2, 0);
|
||||
if(!parseInt)
|
||||
return nullptr;
|
||||
RootedValue parseIntValue(cx, ObjectValue(*parseInt));
|
||||
if(!DefineProperty(cx, ctor, parseIntId, parseIntValue, nullptr, nullptr, 0))
|
||||
return nullptr;
|
||||
|
||||
/* Number.parseFloat should be the same function object as global parseFloat. */
|
||||
RootedId parseFloatId(cx, NameToId(cx->names().parseFloat));
|
||||
JSFunction *parseFloat = DefineFunction(cx, global, parseFloatId, num_parseFloat, 1, 0);
|
||||
if(!parseFloat)
|
||||
return nullptr;
|
||||
RootedValue parseFloatValue(cx, ObjectValue(*parseFloat));
|
||||
if(!DefineProperty(cx, ctor, parseFloatId, parseFloatValue, nullptr, nullptr, 0))
|
||||
return nullptr;
|
||||
|
||||
RootedValue valueNaN(cx, cx->runtime()->NaNValue);
|
||||
RootedValue valueInfinity(cx, cx->runtime()->positiveInfinityValue);
|
||||
|
||||
|
@ -18,6 +18,9 @@ assertEq(Number.parseFloat("infinity"), NaN);
|
||||
assertEq(Number.parseFloat("nan"), NaN);
|
||||
assertEq(Number.parseFloat("NaN"), NaN);
|
||||
|
||||
/* Number.parseFloat should be the same function object as global parseFloat. */
|
||||
assertEq(Number.parseFloat, parseFloat);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
||||
|
@ -161,6 +161,8 @@ assertEq(Number.parseInt("A", 17), 10);
|
||||
assertEq(Number.parseInt("0A", 17), 10);
|
||||
assertEq(Number.parseInt("00A", 17), 10);
|
||||
|
||||
/* Number.parseInt should be the same function object as global parseInt. */
|
||||
assertEq(Number.parseInt, parseInt);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user