Commit 4fd955ae authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Treat NULL disps as actual null values in html mode.

parent 3485f162
...@@ -386,7 +386,7 @@ static IDispatch *get_this(DISPPARAMS *dp) ...@@ -386,7 +386,7 @@ static IDispatch *get_this(DISPPARAMS *dp)
return NULL; return NULL;
} }
static HRESULT convert_params(const DISPPARAMS *dp, jsval_t *buf, unsigned *argc, jsval_t **ret) static HRESULT convert_params(script_ctx_t *ctx, const DISPPARAMS *dp, jsval_t *buf, unsigned *argc, jsval_t **ret)
{ {
jsval_t *argv; jsval_t *argv;
unsigned cnt; unsigned cnt;
...@@ -404,7 +404,7 @@ static HRESULT convert_params(const DISPPARAMS *dp, jsval_t *buf, unsigned *argc ...@@ -404,7 +404,7 @@ static HRESULT convert_params(const DISPPARAMS *dp, jsval_t *buf, unsigned *argc
} }
for(i = 0; i < cnt; i++) { for(i = 0; i < cnt; i++) {
hres = variant_to_jsval(dp->rgvarg+dp->cArgs-i-1, argv+i); hres = variant_to_jsval(ctx, dp->rgvarg+dp->cArgs-i-1, argv+i);
if(FAILED(hres)) { if(FAILED(hres)) {
while(i--) while(i--)
jsval_release(argv[i]); jsval_release(argv[i]);
...@@ -1593,7 +1593,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -1593,7 +1593,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
jsval_t *argv, buf[6], r; jsval_t *argv, buf[6], r;
unsigned argc; unsigned argc;
hres = convert_params(pdp, buf, &argc, &argv); hres = convert_params(This->ctx, pdp, buf, &argc, &argv);
if(FAILED(hres)) if(FAILED(hres))
break; break;
...@@ -1649,7 +1649,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -1649,7 +1649,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
break; break;
} }
hres = variant_to_jsval(pdp->rgvarg+i, &val); hres = variant_to_jsval(This->ctx, pdp->rgvarg+i, &val);
if(FAILED(hres)) if(FAILED(hres))
break; break;
...@@ -2141,7 +2141,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns ...@@ -2141,7 +2141,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
heap_free(dp.rgvarg); heap_free(dp.rgvarg);
if(SUCCEEDED(hres) && ret) if(SUCCEEDED(hres) && ret)
hres = variant_to_jsval(&retv, ret); hres = variant_to_jsval(ctx, &retv, ret);
VariantClear(&retv); VariantClear(&retv);
return hres; return hres;
} }
...@@ -2209,7 +2209,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W ...@@ -2209,7 +2209,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
if(!r) if(!r)
return S_OK; return S_OK;
hres = variant_to_jsval(&retv, r); hres = variant_to_jsval(ctx, &retv, r);
VariantClear(&retv); VariantClear(&retv);
return hres; return hres;
} }
...@@ -2385,7 +2385,7 @@ HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val ...@@ -2385,7 +2385,7 @@ HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val
V_VT(&var) = VT_EMPTY; V_VT(&var) = VT_EMPTY;
hres = disp_invoke(ctx, disp, id, INVOKE_PROPERTYGET, &dp, &var); hres = disp_invoke(ctx, disp, id, INVOKE_PROPERTYGET, &dp, &var);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = variant_to_jsval(&var, val); hres = variant_to_jsval(ctx, &var, val);
VariantClear(&var); VariantClear(&var);
} }
return hres; return hres;
......
...@@ -44,7 +44,7 @@ static inline EnumeratorInstance *enumerator_this(jsval_t vthis) ...@@ -44,7 +44,7 @@ static inline EnumeratorInstance *enumerator_this(jsval_t vthis)
return (jsdisp && is_class(jsdisp, JSCLASS_ENUMERATOR)) ? enumerator_from_jsdisp(jsdisp) : NULL; return (jsdisp && is_class(jsdisp, JSCLASS_ENUMERATOR)) ? enumerator_from_jsdisp(jsdisp) : NULL;
} }
static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This) static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This, script_ctx_t *ctx)
{ {
HRESULT hres; HRESULT hres;
VARIANT nextitem; VARIANT nextitem;
...@@ -60,7 +60,7 @@ static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This) ...@@ -60,7 +60,7 @@ static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This)
hres = IEnumVARIANT_Next(This->enumvar, 1, &nextitem, NULL); hres = IEnumVARIANT_Next(This->enumvar, 1, &nextitem, NULL);
if (hres == S_OK) if (hres == S_OK)
{ {
hres = variant_to_jsval(&nextitem, &This->item); hres = variant_to_jsval(ctx, &nextitem, &This->item);
VariantClear(&nextitem); VariantClear(&nextitem);
if (FAILED(hres)) if (FAILED(hres))
{ {
...@@ -134,7 +134,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, jsval_t vthis, WORD flags ...@@ -134,7 +134,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, jsval_t vthis, WORD flags
return hres; return hres;
This->atend = FALSE; This->atend = FALSE;
hres = enumvar_get_next_item(This); hres = enumvar_get_next_item(This, ctx);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
...@@ -157,7 +157,7 @@ static HRESULT Enumerator_moveNext(script_ctx_t *ctx, jsval_t vthis, WORD flags, ...@@ -157,7 +157,7 @@ static HRESULT Enumerator_moveNext(script_ctx_t *ctx, jsval_t vthis, WORD flags,
if (This->enumvar) if (This->enumvar)
{ {
hres = enumvar_get_next_item(This); hres = enumvar_get_next_item(This, ctx);
if (FAILED(hres)) if (FAILED(hres))
return hres; return hres;
} }
...@@ -272,7 +272,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re ...@@ -272,7 +272,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re
enumerator->enumvar = enumvar; enumerator->enumvar = enumvar;
enumerator->atend = !enumvar; enumerator->atend = !enumvar;
hres = enumvar_get_next_item(enumerator); hres = enumvar_get_next_item(enumerator, ctx);
if (FAILED(hres)) if (FAILED(hres))
{ {
jsdisp_release(&enumerator->dispex); jsdisp_release(&enumerator->dispex);
......
...@@ -244,7 +244,7 @@ HRESULT jsval_copy(jsval_t v, jsval_t *r) ...@@ -244,7 +244,7 @@ HRESULT jsval_copy(jsval_t v, jsval_t *r)
return E_FAIL; return E_FAIL;
} }
HRESULT variant_to_jsval(VARIANT *var, jsval_t *r) HRESULT variant_to_jsval(script_ctx_t *ctx, VARIANT *var, jsval_t *r)
{ {
if(V_VT(var) == (VT_VARIANT|VT_BYREF)) if(V_VT(var) == (VT_VARIANT|VT_BYREF))
var = V_VARIANTREF(var); var = V_VARIANTREF(var);
...@@ -281,7 +281,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r) ...@@ -281,7 +281,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
} }
case VT_DISPATCH: { case VT_DISPATCH: {
if(!V_DISPATCH(var)) { if(!V_DISPATCH(var)) {
*r = jsval_null_disp(); *r = ctx->html_mode ? jsval_null() : jsval_null_disp();
return S_OK; return S_OK;
} }
IDispatch_AddRef(V_DISPATCH(var)); IDispatch_AddRef(V_DISPATCH(var));
...@@ -333,7 +333,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r) ...@@ -333,7 +333,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
return S_OK; return S_OK;
} }
}else { }else {
*r = jsval_null_disp(); *r = ctx->html_mode ? jsval_null() : jsval_null_disp();
return S_OK; return S_OK;
} }
/* fall through */ /* fall through */
...@@ -882,7 +882,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY ...@@ -882,7 +882,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
jsval_t val; jsval_t val;
HRESULT hres; HRESULT hres;
hres = variant_to_jsval(src, &val); hres = variant_to_jsval(ctx, src, &val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
......
...@@ -250,7 +250,7 @@ static inline BOOL get_bool(jsval_t v) ...@@ -250,7 +250,7 @@ static inline BOOL get_bool(jsval_t v)
return __JSVAL_BOOL(v); return __JSVAL_BOOL(v);
} }
HRESULT variant_to_jsval(VARIANT*,jsval_t*) DECLSPEC_HIDDEN; HRESULT variant_to_jsval(script_ctx_t*,VARIANT*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsval_to_variant(jsval_t,VARIANT*) DECLSPEC_HIDDEN; HRESULT jsval_to_variant(jsval_t,VARIANT*) DECLSPEC_HIDDEN;
void jsval_release(jsval_t) DECLSPEC_HIDDEN; void jsval_release(jsval_t) DECLSPEC_HIDDEN;
HRESULT jsval_copy(jsval_t,jsval_t*) DECLSPEC_HIDDEN; HRESULT jsval_copy(jsval_t,jsval_t*) DECLSPEC_HIDDEN;
......
...@@ -93,7 +93,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns ...@@ -93,7 +93,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns
return hres; return hres;
if(r) { if(r) {
hres = variant_to_jsval(&out, r); hres = variant_to_jsval(ctx, &out, r);
VariantClear(&out); VariantClear(&out);
} }
return hres; return hres;
...@@ -163,7 +163,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns ...@@ -163,7 +163,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns
} }
for(i=0; i<size; i++) { for(i=0; i<size; i++) {
hres = variant_to_jsval(v, &val); hres = variant_to_jsval(ctx, v, &val);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(array, i, val); hres = jsdisp_propput_idx(array, i, val);
jsval_release(val); jsval_release(val);
......
...@@ -1325,7 +1325,6 @@ sync_test("builtins_diffs", function() { ...@@ -1325,7 +1325,6 @@ sync_test("builtins_diffs", function() {
sync_test("nullDisp", function() { sync_test("nullDisp", function() {
var v = document.documentMode, nullDisp = external.nullDisp, r; var v = document.documentMode, nullDisp = external.nullDisp, r;
todo_wine.
ok(external.getVT(nullDisp) === "VT_NULL", "getVT(nullDisp) is not VT_NULL"); ok(external.getVT(nullDisp) === "VT_NULL", "getVT(nullDisp) is not VT_NULL");
ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp)); ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
ok(nullDisp === nullDisp, "nullDisp !== nullDisp"); ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
...@@ -1342,10 +1341,11 @@ sync_test("nullDisp", function() { ...@@ -1342,10 +1341,11 @@ sync_test("nullDisp", function() {
ok(r === "[object Object]", "Object(nullDisp).toString() = " + r); ok(r === "[object Object]", "Object(nullDisp).toString() = " + r);
ok(Object(nullDisp) != nullDisp, "Object(nullDisp) == nullDisp"); ok(Object(nullDisp) != nullDisp, "Object(nullDisp) == nullDisp");
ok(new Object(nullDisp) != nullDisp, "new Object(nullDisp) == nullDisp"); ok(new Object(nullDisp) != nullDisp, "new Object(nullDisp) == nullDisp");
r = (nullDisp instanceof Object);
ok(r === false, "nullDisp instance of Object");
if(v >= 8) { if(v >= 8) {
r = JSON.stringify.call(null, nullDisp); r = JSON.stringify.call(null, nullDisp);
todo_wine.
ok(r === "null", "JSON.stringify(nullDisp) returned " + r); ok(r === "null", "JSON.stringify(nullDisp) returned " + r);
} }
...@@ -1360,14 +1360,12 @@ sync_test("nullDisp", function() { ...@@ -1360,14 +1360,12 @@ sync_test("nullDisp", function() {
Function.prototype.apply.call(nullDisp, Object, []); Function.prototype.apply.call(nullDisp, Object, []);
ok(false, "expected exception calling Function.apply on nullDisp"); ok(false, "expected exception calling Function.apply on nullDisp");
}catch(e) { }catch(e) {
todo_wine.
ok(e.number === 0xa138a - 0x80000000, "Function.apply on nullDisp threw " + e.number); ok(e.number === 0xa138a - 0x80000000, "Function.apply on nullDisp threw " + e.number);
} }
try { try {
Function.prototype.call.call(nullDisp, Object); Function.prototype.call.call(nullDisp, Object);
ok(false, "expected exception calling Function.call on nullDisp"); ok(false, "expected exception calling Function.call on nullDisp");
}catch(e) { }catch(e) {
todo_wine.
ok(e.number === 0xa138a - 0x80000000, "Function.call on nullDisp threw " + e.number); ok(e.number === 0xa138a - 0x80000000, "Function.call on nullDisp threw " + e.number);
} }
...@@ -1375,7 +1373,6 @@ sync_test("nullDisp", function() { ...@@ -1375,7 +1373,6 @@ sync_test("nullDisp", function() {
new nullDisp; new nullDisp;
ok(false, "expected exception for new nullDisp"); ok(false, "expected exception for new nullDisp");
}catch(e) { }catch(e) {
todo_wine.
ok(e.number === 0xa138f - 0x80000000, "new nullDisp threw " + e.number); ok(e.number === 0xa138f - 0x80000000, "new nullDisp threw " + e.number);
} }
}); });
......
...@@ -1362,6 +1362,7 @@ sync_test("isFrozen", function() { ...@@ -1362,6 +1362,7 @@ sync_test("isFrozen", function() {
}); });
sync_test("builtin_context", function() { sync_test("builtin_context", function() {
var nullDisp = external.nullDisp;
var tests = [ var tests = [
[ "Array.map", JS_E_OBJECT_EXPECTED, function(ctx) { Array.prototype.map.call(ctx, function(a, b) {}); } ], [ "Array.map", JS_E_OBJECT_EXPECTED, function(ctx) { Array.prototype.map.call(ctx, function(a, b) {}); } ],
[ "Array.sort", JS_E_OBJECT_EXPECTED, function(ctx) { Array.prototype.sort.call(ctx); } ], [ "Array.sort", JS_E_OBJECT_EXPECTED, function(ctx) { Array.prototype.sort.call(ctx); } ],
...@@ -1400,6 +1401,13 @@ sync_test("builtin_context", function() { ...@@ -1400,6 +1401,13 @@ sync_test("builtin_context", function() {
var n = ex.number >>> 0; var n = ex.number >>> 0;
ok(n === tests[i][1], tests[i][0] + " with undefined context exception code = " + n); ok(n === tests[i][1], tests[i][0] + " with undefined context exception code = " + n);
} }
try {
tests[i][2](nullDisp);
ok(false, "expected exception calling " + tests[i][0] + " with nullDisp context");
}catch(ex) {
var n = ex.number >>> 0;
ok(n === tests[i][1], tests[i][0] + " with nullDisp context exception code = " + n);
}
} }
var obj = (function() { return this; }).call(null); var obj = (function() { return this; }).call(null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment