From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/object.c | 6 ++++-- dlls/mshtml/tests/documentmode.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c index 836b49e684c..353b22b528a 100644 --- a/dlls/jscript/object.c +++ b/dlls/jscript/object.c @@ -146,8 +146,10 @@ static HRESULT Object_valueOf(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsi
TRACE("\n");
- if(is_null_disp(vthis)) { - if(r) *r = jsval_null_disp(); + if(is_null(vthis)) { + if(!ctx->html_mode || ctx->version >= SCRIPTLANGUAGEVERSION_ES5_1) + return JS_E_OBJECT_EXPECTED; + if(r) *r = vthis; return S_OK; }
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index faabc7a3475..a930e216b5a 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3264,6 +3264,24 @@ sync_test("nullDisp", function() { r = (nullDisp instanceof Object); ok(r === false, "nullDisp instance of Object");
+ try { + r = Object.prototype.valueOf.call(null); + ok(v < 10, "expected exception calling valueOf on null"); + ok(r === null, "valueOf null != null"); + }catch(e) { + ok(v >= 10, "did not expect exception calling valueOf on null"); + ok(e.number === 0xa138f - 0x80000000, "valueOf on null threw " + e.number); + } + + try { + r = Object.prototype.valueOf.call(nullDisp); + ok(v < 10, "expected exception calling valueOf on nullDisp"); + ok(r === nullDisp, "valueOf on nullDisp != nullDisp"); + }catch(e) { + ok(v >= 10, "did not expect exception calling valueOf on nullDisp"); + ok(e.number === 0xa138f - 0x80000000, "valueOf on nullDisp threw " + e.number); + } + if(v >= 8) { r = JSON.stringify.call(null, nullDisp); ok(r === "null", "JSON.stringify(nullDisp) returned " + r);