Module: wine Branch: master Commit: 3d04d052cda433f868922e5d5259b104d2cc191d URL: https://gitlab.winehq.org/wine/wine/-/commit/3d04d052cda433f868922e5d5259b10...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Thu Jun 22 16:19:01 2023 +0300
jscript: Properly handle passing undefined value to Number.toPrecision.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/jscript/number.c | 2 +- dlls/jscript/tests/api.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c index a5ab775a5d5..00456daaf53 100644 --- a/dlls/jscript/number.c +++ b/dlls/jscript/number.c @@ -525,7 +525,7 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, jsval_t vthis, WORD flags, if(FAILED(hres)) return hres;
- if(argc) { + if(argc && (ctx->version < 2 || !is_undefined(argv[0]))) { hres = to_int32(ctx, argv[0], &prec); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index d632d889476..fb98946fdc7 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1432,6 +1432,10 @@ tmp = (new Number(1.182e30)).toPrecision(5); ok(tmp == "1.1820e+30", "num(1.182e30)).toPrecision(5) = " + tmp); tmp = (new Number(1.123)).toPrecision(); ok(tmp == "1.123", "num(1.123).toPrecision() = " + tmp); +if(invokeVersion >= 2) { + tmp = (new Number(1.123)).toPrecision(undefined); + ok(tmp == "1.123", "num(1.123).toPrecision(undefined) = " + tmp); +}
ok(Number() === 0, "Number() = " + Number()); ok(Number(false) === 0, "Number(false) = " + Number(false)); @@ -2707,6 +2711,8 @@ testException(function() {Number.prototype.toLocaleString.call(null);}, "E_NOT_N testException(function() {(new Number(3)).toString(1);}, "E_INVALID_CALL_ARG"); testException(function() {(new Number(3)).toFixed(21);}, "E_FRACTION_DIGITS_OUT_OF_RANGE"); testException(function() {(new Number(1)).toPrecision(0);}, "E_PRECISION_OUT_OF_RANGE"); +if(invokeVersion < 2) + testException(function() {(new Number(1)).toPrecision(undefined);}, "E_PRECISION_OUT_OF_RANGE"); testException(function() {not_existing_variable.something();}, "E_UNDEFINED"); testException(function() {date();}, "E_NOT_FUNC"); testException(function() {arr();}, "E_NOT_FUNC");