From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 49ed4790d94..2f722c9eccc 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -1134,13 +1134,9 @@ static const dispex_static_data_vtbl_t function_dispex_vtbl = { .invoke = function_invoke };
-static const tid_t function_iface_tids[] = {0}; - static dispex_static_data_t function_dispex = { - "Function", - &function_dispex_vtbl, - NULL_tid, - function_iface_tids + .name = "Function", + .vtbl = &function_dispex_vtbl, };
static func_disp_t *create_func_disp(DispatchEx *obj, func_info_t *info)
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 67 ++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 2f722c9eccc..5cb51ccda2d 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -894,6 +894,39 @@ static HRESULT get_disp_prop(IDispatchEx *dispex, const WCHAR *name, LCID lcid, return hres; }
+static HRESULT format_func_disp_string(const WCHAR *name, IServiceProvider *caller, VARIANT *res) +{ + unsigned name_len; + WCHAR *ptr; + BSTR str; + + static const WCHAR func_prefixW[] = + {'\n','f','u','n','c','t','i','o','n',' '}; + static const WCHAR func_suffixW[] = + {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'}; + + /* FIXME: This probably should be more generic. Also we should try to get IID_IActiveScriptSite and SID_GetCaller. */ + if(!caller) + return E_ACCESSDENIED; + + name_len = wcslen(name); + ptr = str = SysAllocStringLen(NULL, name_len + ARRAY_SIZE(func_prefixW) + ARRAY_SIZE(func_suffixW)); + if(!str) + return E_OUTOFMEMORY; + + memcpy(ptr, func_prefixW, sizeof(func_prefixW)); + ptr += ARRAY_SIZE(func_prefixW); + + memcpy(ptr, name, name_len * sizeof(WCHAR)); + ptr += name_len; + + memcpy(ptr, func_suffixW, sizeof(func_suffixW)); + + V_VT(res) = VT_BSTR; + V_BSTR(res) = str; + return S_OK; +} + static HRESULT function_apply(func_disp_t *func, DISPPARAMS *dp, LCID lcid, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { IWineJSDispatchHost *this_iface; @@ -1037,37 +1070,9 @@ static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR return E_UNEXPECTED; hres = dispex_call_builtin(This->obj, This->info->id, params, res, ei, caller); break; - case DISPATCH_PROPERTYGET: { - unsigned name_len; - WCHAR *ptr; - BSTR str; - - static const WCHAR func_prefixW[] = - {'\n','f','u','n','c','t','i','o','n',' '}; - static const WCHAR func_suffixW[] = - {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'}; - - /* FIXME: This probably should be more generic. Also we should try to get IID_IActiveScriptSite and SID_GetCaller. */ - if(!caller) - return E_ACCESSDENIED; - - name_len = SysStringLen(This->info->name); - ptr = str = SysAllocStringLen(NULL, name_len + ARRAY_SIZE(func_prefixW) + ARRAY_SIZE(func_suffixW)); - if(!str) - return E_OUTOFMEMORY; - - memcpy(ptr, func_prefixW, sizeof(func_prefixW)); - ptr += ARRAY_SIZE(func_prefixW); - - memcpy(ptr, This->info->name, name_len*sizeof(WCHAR)); - ptr += name_len; - - memcpy(ptr, func_suffixW, sizeof(func_suffixW)); - - V_VT(res) = VT_BSTR; - V_BSTR(res) = str; - return S_OK; - } + case DISPATCH_PROPERTYGET: + hres = format_func_disp_string(This->info->name, caller, res); + break; default: FIXME("Unimplemented flags %x\n", flags); hres = E_NOTIMPL;
From: Gabriel Ivăncescu gabrielopcode@gmail.com
They are actual stubs even on native (but avoid throwing when retrieving them, even if unused).
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 62 +++++++++++++++++++++++++++++++ dlls/mshtml/tests/documentmode.js | 34 +++++++++++++++++ 2 files changed, 96 insertions(+)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 5cb51ccda2d..f1cbc0a186e 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -98,6 +98,11 @@ typedef struct { func_info_t *info; } func_disp_t;
+typedef struct { + DispatchEx dispex; + const WCHAR *name; +} stub_func_disp_t; + typedef struct { func_disp_t *func_obj; VARIANT val; @@ -927,6 +932,51 @@ static HRESULT format_func_disp_string(const WCHAR *name, IServiceProvider *call return S_OK; }
+static inline stub_func_disp_t *stub_func_disp_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, stub_func_disp_t, dispex); +} + +static void stub_function_destructor(DispatchEx *dispex) +{ + stub_func_disp_t *This = stub_func_disp_from_DispatchEx(dispex); + free(This); +} + +static HRESULT stub_function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, + VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + stub_func_disp_t *This = stub_func_disp_from_DispatchEx(dispex); + HRESULT hres; + + switch(flags) { + case DISPATCH_METHOD|DISPATCH_PROPERTYGET: + if(!res) + return E_INVALIDARG; + /* fall through */ + case DISPATCH_METHOD: + return MSHTML_E_INVALID_PROPERTY; + case DISPATCH_PROPERTYGET: + hres = format_func_disp_string(This->name, caller, res); + break; + default: + FIXME("Unimplemented flags %x\n", flags); + hres = E_NOTIMPL; + } + + return hres; +} + +static const dispex_static_data_vtbl_t stub_function_dispex_vtbl = { + .destructor = stub_function_destructor, + .value = stub_function_value +}; + +static dispex_static_data_t stub_function_dispex = { + .name = "Function", + .vtbl = &stub_function_dispex_vtbl, +}; + static HRESULT function_apply(func_disp_t *func, DISPPARAMS *dp, LCID lcid, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { IWineJSDispatchHost *this_iface; @@ -1124,6 +1174,18 @@ static HRESULT function_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD fl /* fall through */ case DISPATCH_METHOD: return function_props[idx].invoke(This, params, lcid, res, ei, caller); + case DISPATCH_PROPERTYGET: { + stub_func_disp_t *disp = calloc(1, sizeof(stub_func_disp_t)); + + if(!disp) + return E_OUTOFMEMORY; + disp->name = function_props[idx].name; + init_dispatch_with_owner(&disp->dispex, &stub_function_dispex, This->obj); + + V_VT(res) = VT_DISPATCH; + V_DISPATCH(res) = (IDispatch*)&disp->dispex.IWineJSDispatchHost_iface; + break; + } default: return MSHTML_E_INVALID_PROPERTY; } diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index f967b36e562..20188f459dd 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -364,6 +364,8 @@ sync_test("builtin_obj", function() { if(v < 9) { ok(!(window instanceof Object), "window instance of Object"); ok(!(document instanceof Object), "document instance of Object"); + ok(!(f.apply instanceof Function), "f.apply instance of Function"); + ok(!(f.call instanceof Function), "f.call instance of Function"); ok(!("arguments" in f), "arguments in f"); ok(!("length" in f), "length in f"); e = 0; @@ -419,6 +421,38 @@ sync_test("builtin_obj", function() { elem1.click.apply(elem2, { length: -1 }); ok(false, "exception expected"); }catch(ex) {} + + if(v < 9) { + ok(!("call" in f.call), "call in f.call"); + ok(!("apply" in f.call), "apply in f.call"); + ok(!("call" in f.apply), "call in f.apply"); + ok(!("apply" in f.apply), "apply in f.apply"); + ok(f.call+"" === "\nfunction call() {\n [native code]\n}\n", "f.call = " + f.call); + ok(f.apply+"" === "\nfunction apply() {\n [native code]\n}\n", "f.apply = " + f.apply); + ok(external.getVT(f.call) === "VT_DISPATCH", "f.call not VT_DISPATCH"); + ok(external.getVT(f.apply) === "VT_DISPATCH", "f.apply not VT_DISPATCH"); + + ok(f.apply !== f.apply, "f.apply == f.apply"); + f = f.apply; + ok(!("arguments" in f), "arguments in f.apply"); + ok(!("length" in f), "length in f.apply"); + ok(!("call" in f), "call in f.apply"); + ok(!("apply" in f), "apply in f.apply"); + e = 0; + try { + f.toString(); + }catch(ex) { + e = ex.number; + } + ok(e === 0xa01b6 - 0x80000000, "[f.apply.toString] e = " + e); + e = 0; + try { + f(document, ["style"]); + }catch(ex) { + e = ex.number; + } + ok(e === 0xa01b6 - 0x80000000, "[f.apply() indirect] e = " + e); + } });
sync_test("elem_props", function() {
From: Gabriel Ivăncescu gabrielopcode@gmail.com
It is a prop, not a method.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/enumerator.c | 2 +- dlls/mshtml/tests/documentmode.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/enumerator.c b/dlls/jscript/enumerator.c index 203bfa8b8e0..c4aed168466 100644 --- a/dlls/jscript/enumerator.c +++ b/dlls/jscript/enumerator.c @@ -240,7 +240,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re /* Try to get a IEnumVARIANT by _NewEnum */ VariantInit(&varresult); hres = IDispatch_Invoke(obj, DISPID_NEWENUM, &IID_NULL, LOCALE_NEUTRAL, - DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL); + DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); if (FAILED(hres)) { WARN("Enumerator: no DISPID_NEWENUM.\n"); diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 20188f459dd..13dd172fec1 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -452,6 +452,13 @@ sync_test("builtin_obj", function() { e = ex.number; } ok(e === 0xa01b6 - 0x80000000, "[f.apply() indirect] e = " + e); + + var enumerator = new Enumerator(document.getElementsByTagName("br")); + enumerator.moveNext(); + var enum_elem = enumerator.item(); + ok(enum_elem === elem2, "enum_elem = " + enum_elem); + enumerator.moveNext(); + ok(enumerator.atEnd(), "enumerator not at end"); } });
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/error.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index a3388ee9a27..482932e2c1b 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -407,6 +407,8 @@ void handle_dispatch_exception(script_ctx_t *ctx, EXCEPINFO *ei) TRACE("%08lx %s %s\n", ei->scode, debugstr_w(ei->bstrSource), debugstr_w(ei->bstrDescription));
reset_ei(ctx->ei); + if(ei->pfnDeferredFillIn) + ei->pfnDeferredFillIn(ei); ctx->ei->error = (SUCCEEDED(ei->scode) || ei->scode == DISP_E_EXCEPTION) ? E_FAIL : ei->scode; if(ei->bstrSource) ctx->ei->source = jsstr_alloc_len(ei->bstrSource, SysStringLen(ei->bstrSource));
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/documentmode.js | 45 +++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.js | 2 ++ dlls/mshtml/tests/events.c | 23 +++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 13dd172fec1..d54cf5ca955 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -379,6 +379,21 @@ sync_test("builtin_obj", function() { window.toString.call(null); ok(false, "expected exception calling window.toString with null context"); }catch(ex) {} + }else { + ok(window instanceof Object, "window not instance of Object"); + ok(document instanceof Object, "document not instance of Object"); + ok(Object.isExtensible(window), "window is not extensible"); + ok(Object.isExtensible(document), "document is not extensible"); + + ok(f.toString() === "\nfunction createElement() {\n [native code]\n}\n", "f.toString() = " + f.toString()); + ok(Object.getPrototypeOf(f) === Function.prototype, "unexpected document.createElement prototype"); + ok(Object.getPrototypeOf(f.apply) === Function.prototype, "unexpected f.apply prototype"); + ok(Object.getPrototypeOf(f.call) === Function.prototype, "unexpected f.call prototype"); + + e = window.toString.call(null); + ok(e === "[object Window]", "window.toString with null context = " + e); + e = window.toString.call(external.nullDisp); + ok(e === "[object Window]", "window.toString with nullDisp context = " + e); }
e = 0; @@ -422,6 +437,15 @@ sync_test("builtin_obj", function() { ok(false, "exception expected"); }catch(ex) {}
+ e = 0; + try { + new f(); + }catch(ex) { + e = ex.number; + } + todo_wine_if(v < 9). + ok(e === (v < 9 ? 0xa01b6 : 0x0ffff) - 0x80000000, "[new f()] e = " + e); + if(v < 9) { ok(!("call" in f.call), "call in f.call"); ok(!("apply" in f.call), "apply in f.call"); @@ -459,6 +483,24 @@ sync_test("builtin_obj", function() { ok(enum_elem === elem2, "enum_elem = " + enum_elem); enumerator.moveNext(); ok(enumerator.atEnd(), "enumerator not at end"); + }else { + elem = f.call.call(f, document, "div"); + f = f.bind(document); + elem = f.apply(null, ["style"]); + document.body.appendChild(elem); + + try { + var enumerator = new Enumerator(document.getElementsByTagName("style")); + }catch(ex) { + e = ex.number; + } + todo_wine. + ok(e === 0xa01c3 - 0x80000000, "[style Enumerator] e = " + e); + + f.apply = 0; + f.call = function() { }; + ok(f.apply === 0, "changed f.apply = ", f.apply); + ok(f.call instanceof Function, "changed f.call not instance of Function"); } });
@@ -2175,11 +2217,10 @@ sync_test("elem_attr", function() { var func = elem.setAttribute; try { func("testattr", arr); - todo_wine_if(v >= 9). ok(v < 9, "expected exception setting testattr via func"); }catch(ex) { ok(v >= 9, "did not expect exception setting testattr via func"); - elem.setAttribute("testattr", arr); + func.call(elem, "testattr", arr); } r = elem.getAttribute("testattr"); ok(r === (v < 8 ? arr : (v < 10 ? "arrval" : "42")), "testattr after setAttribute (as func) = " + r); diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index b26280e00d6..628ed3d9703 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -572,6 +572,7 @@ sync_test("storage", function() {
sessionStorage.setItem("foobar", 42); ok("foobar" in sessionStorage, "foobar not in sessionStorage"); + ok(Object.prototype.hasOwnProperty.call(sessionStorage, "foobar"), "foobar not prop of sessionStorage"); item = sessionStorage.getItem("foobar"); ok(item === "42", "'foobar' item = " + item); item = sessionStorage["foobar"]; @@ -582,6 +583,7 @@ sync_test("storage", function() {
sessionStorage["barfoo"] = true; ok("barfoo" in sessionStorage, "barfoo not in sessionStorage"); + ok(Object.prototype.hasOwnProperty.call(sessionStorage, "barfoo"), "barfoo not prop of sessionStorage"); item = sessionStorage["barfoo"]; ok(item === "true", "[barfoo] item = " + item); item = sessionStorage.getItem("barfoo"); diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index 69488001fb2..6950c1e2a08 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -1602,8 +1602,10 @@ EVENT_HANDLER_FUNC_OBJ(onmessage); static HRESULT WINAPI onvisibilitychange(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) { + DISPPARAMS dp = {0}; IDispatchEx *dispex; HRESULT hres; + VARIANT res; BSTR bstr;
CHECK_EXPECT(visibilitychange); @@ -1614,10 +1616,15 @@ static HRESULT WINAPI onvisibilitychange(IDispatchEx *iface, DISPID id, LCID lci
bstr = SysAllocString(L"toString"); hres = IDispatchEx_GetDispID(dispex, bstr, 0, &id); - todo_wine ok(hres == S_OK, "GetDispID("toString") failed: %08lx\n", hres); SysFreeString(bstr);
+ hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_FUNC, &dp, &res, NULL, NULL); + ok(hres == S_OK, "InvokeEx("toString") failed: %08lx\n", hres); + ok(V_VT(&res) == VT_BSTR, "V_VT("toString") = %d\n", V_VT(&res)); + ok(!wcscmp(V_BSTR(&res), L"[object Event]"), "toString = %s\n", wine_dbgstr_w(V_BSTR(&res))); + VariantClear(&res); + return S_OK; }
@@ -4652,8 +4659,10 @@ static void test_storage_event(DISPPARAMS *params, BOOL doc_onstorage) IHTMLEventObj *event_obj; IDOMStorageEvent *event; IDispatchEx *dispex; + DISPPARAMS dp = {0}; IDispatch *disp; HRESULT hres; + VARIANT res; unsigned i; DISPID id; BSTR bstr; @@ -4669,6 +4678,18 @@ static void test_storage_event(DISPPARAMS *params, BOOL doc_onstorage) hres = IDispatch_QueryInterface(V_DISPATCH(¶ms->rgvarg[1]), &IID_IDispatchEx, (void**)&dispex); ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx: %08lx\n", hres);
+ bstr = SysAllocString(L"toString"); + hres = IDispatchEx_GetDispID(dispex, bstr, 0, &id); + ok_(__FILE__,line)(hres == S_OK, "GetDispID("toString") failed: %08lx\n", hres); + SysFreeString(bstr); + + hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_FUNC, &dp, &res, NULL, NULL); + ok_(__FILE__,line)(hres == S_OK, "InvokeEx("toString") failed: %08lx\n", hres); + ok_(__FILE__,line)(V_VT(&res) == VT_BSTR, "V_VT("toString") = %d\n", V_VT(&res)); + ok_(__FILE__,line)(!wcscmp(V_BSTR(&res), doc_onstorage ? L"[object MSEventObj]" : L"[object StorageEvent]"), + "toString = %s\n", wine_dbgstr_w(V_BSTR(&res))); + VariantClear(&res); + hres = IDispatchEx_QueryInterface(dispex, &IID_IDOMStorageEvent, (void**)&event); if(doc_onstorage) { static const WCHAR *props[] = { L"key", L"oldValue", L"newValue", L"storageArea" };
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 4 ++++ dlls/mshtml/tests/documentmode.js | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index f1cbc0a186e..20f924230fe 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -950,6 +950,8 @@ static HRESULT stub_function_value(DispatchEx *dispex, LCID lcid, WORD flags, DI HRESULT hres;
switch(flags) { + case DISPATCH_CONSTRUCT: + return MSHTML_E_INVALID_PROPERTY; case DISPATCH_METHOD|DISPATCH_PROPERTYGET: if(!res) return E_INVALIDARG; @@ -1111,6 +1113,8 @@ static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR HRESULT hres;
switch(flags) { + case DISPATCH_CONSTRUCT: + return MSHTML_E_INVALID_PROPERTY; case DISPATCH_METHOD|DISPATCH_PROPERTYGET: if(!res) return E_INVALIDARG; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index d54cf5ca955..37525dd2634 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -443,7 +443,6 @@ sync_test("builtin_obj", function() { }catch(ex) { e = ex.number; } - todo_wine_if(v < 9). ok(e === (v < 9 ? 0xa01b6 : 0x0ffff) - 0x80000000, "[new f()] e = " + e);
if(v < 9) {
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/enumerator.c | 4 ++-- dlls/jscript/error.c | 1 + dlls/jscript/jscript.h | 1 + dlls/jscript/jscript.rc | 1 + dlls/jscript/resource.h | 1 + dlls/mshtml/tests/documentmode.js | 1 - 6 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/enumerator.c b/dlls/jscript/enumerator.c index c4aed168466..983b7f4addf 100644 --- a/dlls/jscript/enumerator.c +++ b/dlls/jscript/enumerator.c @@ -244,7 +244,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re if (FAILED(hres)) { WARN("Enumerator: no DISPID_NEWENUM.\n"); - return E_INVALIDARG; + return JS_E_OBJECT_NOT_COLLECTION; }
if ((V_VT(&varresult) == VT_DISPATCH) || (V_VT(&varresult) == VT_UNKNOWN)) @@ -255,7 +255,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re else { FIXME("Enumerator: NewEnum unexpected type of varresult (%d).\n", V_VT(&varresult)); - hres = E_INVALIDARG; + hres = JS_E_OBJECT_NOT_COLLECTION; } VariantClear(&varresult); if (FAILED(hres)) diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index 482932e2c1b..3ff40a1e1e7 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -477,6 +477,7 @@ jsdisp_t *create_builtin_error(script_ctx_t *ctx) case JS_E_INVALID_PROPERTY: case JS_E_INVALID_ACTION: case JS_E_MISSING_ARG: + case JS_E_OBJECT_NOT_COLLECTION: case JS_E_FUNCTION_EXPECTED: case JS_E_DATE_EXPECTED: case JS_E_NUMBER_EXPECTED: diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index b413b4d1ae9..3d3d0f8a6c9 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -530,6 +530,7 @@ static inline HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, jsval_ #define JS_E_INVALID_PROPERTY MAKE_JSERROR(IDS_NO_PROPERTY) #define JS_E_INVALID_ACTION MAKE_JSERROR(IDS_UNSUPPORTED_ACTION) #define JS_E_MISSING_ARG MAKE_JSERROR(IDS_ARG_NOT_OPT) +#define JS_E_OBJECT_NOT_COLLECTION MAKE_JSERROR(IDS_OBJECT_NOT_COLLECTION) #define JS_E_SYNTAX MAKE_JSERROR(IDS_SYNTAX_ERROR) #define JS_E_MISSING_SEMICOLON MAKE_JSERROR(IDS_SEMICOLON) #define JS_E_MISSING_LBRACKET MAKE_JSERROR(IDS_LBRACKET) diff --git a/dlls/jscript/jscript.rc b/dlls/jscript/jscript.rc index cbdfde507b7..438aaad4c35 100644 --- a/dlls/jscript/jscript.rc +++ b/dlls/jscript/jscript.rc @@ -33,6 +33,7 @@ STRINGTABLE IDS_NO_PROPERTY "Object doesn't support this property or method" IDS_UNSUPPORTED_ACTION "Object doesn't support this action" IDS_ARG_NOT_OPT "Argument not optional" + IDS_OBJECT_NOT_COLLECTION "Object not a collection" IDS_SYNTAX_ERROR "Syntax error" IDS_SEMICOLON "Expected ';'" IDS_LBRACKET "Expected '('" diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h index 801e940b95e..640cc01cff9 100644 --- a/dlls/jscript/resource.h +++ b/dlls/jscript/resource.h @@ -31,6 +31,7 @@ #define IDS_NO_PROPERTY 0x01B6 #define IDS_UNSUPPORTED_ACTION 0x01BD #define IDS_ARG_NOT_OPT 0x01c1 +#define IDS_OBJECT_NOT_COLLECTION 0x01c3 #define IDS_SYNTAX_ERROR 0x03EA #define IDS_SEMICOLON 0x03EC #define IDS_LBRACKET 0x03ED diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 37525dd2634..39f12037379 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -493,7 +493,6 @@ sync_test("builtin_obj", function() { }catch(ex) { e = ex.number; } - todo_wine. ok(e === 0xa01c3 - 0x80000000, "[style Enumerator] e = " + e);
f.apply = 0;
Jacek Caban (@jacek) commented about dlls/jscript/enumerator.c:
/* Try to get a IEnumVARIANT by _NewEnum */ VariantInit(&varresult); hres = IDispatch_Invoke(obj, DISPID_NEWENUM, &IID_NULL, LOCALE_NEUTRAL,
DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
Please add a test to `testObj_Invoke`.
Jacek Caban (@jacek) commented about dlls/jscript/error.c:
TRACE("%08lx %s %s\n", ei->scode, debugstr_w(ei->bstrSource), debugstr_w(ei->bstrDescription)); reset_ei(ctx->ei);
- if(ei->pfnDeferredFillIn)
ei->pfnDeferredFillIn(ei);
Can we have a test for this?
Jacek Caban (@jacek) commented about dlls/mshtml/tests/documentmode.js:
window.toString.call(null); ok(false, "expected exception calling window.toString with null context"); }catch(ex) {}
- }else {
ok(window instanceof Object, "window not instance of Object");
ok(document instanceof Object, "document not instance of Object");
It's not wrong, but note that we have more precise tests in "prototypes" test.
Jacek Caban (@jacek) commented about dlls/mshtml/tests/documentmode.js:
window.toString.call(null); ok(false, "expected exception calling window.toString with null context"); }catch(ex) {}
- }else {
ok(window instanceof Object, "window not instance of Object");
ok(document instanceof Object, "document not instance of Object");
ok(Object.isExtensible(window), "window is not extensible");
ok(Object.isExtensible(document), "document is not extensible");
ok(f.toString() === "\nfunction createElement() {\n [native code]\n}\n", "f.toString() = " + f.toString());
ok(Object.getPrototypeOf(f) === Function.prototype, "unexpected document.createElement prototype");
ok(Object.getPrototypeOf(f.apply) === Function.prototype, "unexpected f.apply prototype");
ok(Object.getPrototypeOf(f.call) === Function.prototype, "unexpected f.call prototype");
We have some of that in "builtin_func". You essentially test `Function.prototype.call`'s prototype, which is not specific to builtin functions anymore. It really comes down to `!f.hasOwnProperty("apply")`.
Yeah, I kept them for symmetry with pre IE9 modes in this test, and some quick behavior comparisons. I'll reduce them.