diff --git a/rostests/winetests/mshtml/activex.c b/rostests/winetests/mshtml/activex.c index e26a8600cd6..0620c6f075c 100644 --- a/rostests/winetests/mshtml/activex.c +++ b/rostests/winetests/mshtml/activex.c @@ -2702,12 +2702,6 @@ static BOOL check_ie(void) IHTMLDocument5 *doc; HRESULT hres; - static const WCHAR xW[] = {'x',0}; - static const WCHAR yW[] = {'y',0}; - - if(!lstrcmpW(xW, yW)) - return FALSE; - hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IHTMLDocument5, (void**)&doc); if(FAILED(hres)) diff --git a/rostests/winetests/mshtml/dom.c b/rostests/winetests/mshtml/dom.c index c9531188fc9..33fc3ba7dd6 100644 --- a/rostests/winetests/mshtml/dom.c +++ b/rostests/winetests/mshtml/dom.c @@ -56,7 +56,7 @@ static const char elem_test_str[] = "" "" "" - "
td1 texttd2 text
" + "
td1 texttd2 text
" "" "" "" @@ -1142,6 +1142,17 @@ static void _test_elem_offset(unsigned line, IUnknown *unk, const char *parent_t IHTMLElement_Release(elem); } +#define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b) +static void _test_elem_source_index(unsigned line, IHTMLElement *elem, int index) +{ + LONG l = 0xdeadbeef; + HRESULT hres; + + hres = IHTMLElement_get_sourceIndex(elem, &l); + ok_(__FILE__,line)(hres == S_OK, "get_sourceIndex failed: %08x\n", hres); + ok_(__FILE__,line)(l == index, "sourceIndex = %d, expected %d\n", l, index); +} + #define get_doc_node(d) _get_doc_node(__LINE__,d) static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc) { @@ -1741,6 +1752,8 @@ static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *do IHTMLWindow2_Release(window); ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres); + test_disp((IUnknown*)factory, &IID_IHTMLOptionElementFactory, "[object]"); + V_VT(&text) = VT_BSTR; V_BSTR(&text) = a2bstr(txt); V_VT(&value) = VT_BSTR; @@ -2103,14 +2116,37 @@ static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t IHTMLElement_Release(elem); } +#define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b) +static IHTMLElement *_get_elem_col_item_idx(unsigned line, IHTMLElementCollection *col, int i) +{ + VARIANT name, index; + IHTMLElement *elem; + IDispatch *disp; + HRESULT hres; + + V_VT(&index) = VT_EMPTY; + V_VT(&name) = VT_I4; + V_I4(&name) = i; + hres = IHTMLElementCollection_item(col, name, index, &disp); + ok_(__FILE__,line)(hres == S_OK, "item failed: %08x\n", hres); + ok_(__FILE__,line)(disp != NULL, "disp == NULL\n"); + + elem = _get_elem_iface(line, (IUnknown*)disp); + IDispatch_Release(disp); + return elem; +} + #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l) static void _test_elem_collection(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen) { IHTMLElementCollection *col; + IEnumVARIANT *enum_var; + IUnknown *enum_unk; + ULONG fetched; LONG len; DWORD i; - VARIANT name, index; + VARIANT name, index, v, vs[5]; IDispatch *disp, *disp2; HRESULT hres; @@ -2128,6 +2164,13 @@ static void _test_elem_collection(unsigned line, IUnknown *unk, V_VT(&index) = VT_EMPTY; + hres = IHTMLElementCollection_get__newEnum(col, &enum_unk); + ok_(__FILE__,line)(hres == S_OK, "_newEnum failed: %08x\n", hres); + + hres = IUnknown_QueryInterface(enum_unk, &IID_IEnumVARIANT, (void**)&enum_var); + IUnknown_Release(enum_unk); + ok_(__FILE__,line)(hres == S_OK, "Could not get IEnumVARIANT iface: %08x\n", hres); + for(i=0; i 2 ? len-2 : 0); + ok_(__FILE__,line)(hres == S_OK, "Skip failed: %08x\n", hres); + + memset(vs, 0, sizeof(vs)); + fetched = 0; + hres = IEnumVARIANT_Next(enum_var, sizeof(vs)/sizeof(*vs), vs, &fetched); + ok_(__FILE__,line)(hres == S_FALSE, "Next failed: %08x\n", hres); + ok_(__FILE__,line)(fetched == (len > 2 ? 2 : len), "fetched = %d\n", fetched); + if(len) { + ok_(__FILE__,line)(V_VT(vs) == VT_DISPATCH && V_DISPATCH(vs), "V_VT(vs[0]) = %d\n", V_VT(vs)); + IDispatch_Release(V_DISPATCH(vs)); + } + if(len > 1) { + ok_(__FILE__,line)(V_VT(vs+1) == VT_DISPATCH && V_DISPATCH(vs+1), "V_VT(vs[1]) = %d\n", V_VT(vs+1)); + IDispatch_Release(V_DISPATCH(vs+1)); + } + + hres = IEnumVARIANT_Reset(enum_var); + ok_(__FILE__,line)(hres == S_OK, "Reset failed: %08x\n", hres); + + hres = IEnumVARIANT_Skip(enum_var, len+1); + ok_(__FILE__,line)(hres == S_FALSE, "Skip failed: %08x\n", hres); + + IEnumVARIANT_Release(enum_var); + V_VT(&name) = VT_I4; V_I4(&name) = len; disp = (void*)0xdeadbeef; @@ -2226,20 +2321,8 @@ static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t ty HeapFree(GetProcessHeap(), 0, types); - if(ret) { - IDispatch *disp; - VARIANT v; - - V_VT(&v) = VT_I4; - V_I4(&v) = 0; - disp = NULL; - hres = IHTMLElementCollection_item(col, v, v, &disp); - ok(hres == S_OK, "item failed: %08x\n", hres); - ok(disp != NULL, "disp == NULL\n"); - *ret = _get_elem_iface(line, (IUnknown*)disp); - IDispatch_Release(disp); - } - + if(ret) + *ret = get_elem_col_item_idx(col, 0); IHTMLElementCollection_Release(col); } @@ -2497,6 +2580,24 @@ static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, _test_elem3_get_disabled(line, (IUnknown*)select, exb); } +static void test_select_remove(IHTMLSelectElement *select) +{ + HRESULT hres; + + hres = IHTMLSelectElement_remove(select, 3); + ok(hres == S_OK, "remove failed: %08x, expected S_OK\n", hres); + test_select_length(select, 2); + + hres = IHTMLSelectElement_remove(select, -1); + todo_wine + ok(hres == E_INVALIDARG, "remove failed: %08x, expected E_INVALIDARG\n", hres); + test_select_length(select, 2); + + hres = IHTMLSelectElement_remove(select, 0); + ok(hres == S_OK, "remove failed:%08x\n", hres); + test_select_length(select, 1); +} + #define test_text_length(u,l) _test_text_length(__LINE__,u,l) static void _test_text_length(unsigned line, IUnknown *unk, LONG l) { @@ -2701,6 +2802,24 @@ static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt) _test_img_alt(line, unk, alt); } +#define test_img_align(u,a) _test_img_align(__LINE__,u,a) +static void _test_img_align(unsigned line, IUnknown *unk, const char *align) +{ + IHTMLImgElement *img = _get_img_iface(line, unk); + BSTR tmp; + HRESULT hres; + + tmp = a2bstr(align); + hres = IHTMLImgElement_put_align(img, tmp); + ok_(__FILE__,line) (hres == S_OK, "put_align failed: %08x\n", hres); + SysFreeString(tmp); + + hres = IHTMLImgElement_get_align(img, &tmp); + ok_(__FILE__,line) (hres == S_OK, "put_align failed: %08x\n", hres); + ok_(__FILE__,line) (!strcmp_wa(tmp, align), "Expect %s, got %s\n", align, wine_dbgstr_w(tmp)); + SysFreeString(tmp); +} + #define test_img_name(u, c) _test_img_name(__LINE__,u, c) static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue) { @@ -2728,6 +2847,25 @@ static void _test_img_complete(unsigned line, IHTMLElement *elem, VARIANT_BOOL e IHTMLImgElement_Release(img); } +#define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c) +static void _test_img_isMap(unsigned line, IUnknown *unk, VARIANT_BOOL v) +{ + IHTMLImgElement *img = _get_img_iface(line, unk); + VARIANT_BOOL b = 100; + HRESULT hres; + + hres = IHTMLImgElement_put_isMap(img, v); + ok_(__FILE__,line) (hres == S_OK, "put_isMap failed: %08x\n", hres); + + hres = IHTMLImgElement_get_isMap(img, &b); + ok_(__FILE__,line) (hres == S_OK, "get_isMap failed: %08x\n", hres); + ok_(__FILE__,line) (b == v, "isMap = %x, expected %x\n", b, v); + + hres = IHTMLImgElement_get_isMap(img, NULL); + ok_(__FILE__,line) (hres == E_INVALIDARG, "ret = %08x, expected E_INVALIDARG\n", hres); + IHTMLImgElement_Release(img); +} + static void test_dynamic_properties(IHTMLElement *elem) { static const WCHAR attr1W[] = {'a','t','t','r','1',0}; @@ -2950,6 +3088,65 @@ static void _test_attr_specified(unsigned line, IHTMLDOMAttribute *attr, VARIANT ok_(__FILE__,line)(specified == expected, "specified = %x, expected %x\n", specified, expected); } +#define test_elem_id(e,i) _test_elem_id(__LINE__,e,i) +static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid) +{ + IHTMLElement *elem = _get_elem_iface(line, unk); + BSTR id = (void*)0xdeadbeef; + HRESULT hres; + + hres = IHTMLElement_get_id(elem, &id); + IHTMLElement_Release(elem); + ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres); + + if(exid) + ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id)); + else + ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id)); + + SysFreeString(id); +} + +#define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i) +static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id) +{ + IHTMLElement *elem = _get_elem_iface(line, unk); + BSTR tmp = a2bstr(new_id); + HRESULT hres; + + hres = IHTMLElement_put_id(elem, tmp); + IHTMLElement_Release(elem); + SysFreeString(tmp); + ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres); + + _test_elem_id(line, unk, new_id); +} + +static void test_contenteditable(IUnknown *unk) +{ + IHTMLElement3 *elem3 = get_elem3_iface(unk); + HRESULT hres; + BSTR str, strDefault; + + hres = IHTMLElement3_get_contentEditable(elem3, &strDefault); + ok(hres == S_OK, "get_contentEditable failed: 0x%08x\n", hres); + + str = a2bstr("true"); + hres = IHTMLElement3_put_contentEditable(elem3, str); + ok(hres == S_OK, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str), hres); + SysFreeString(str); + hres = IHTMLElement3_get_contentEditable(elem3, &str); + ok(hres == S_OK, "get_contentEditable failed: 0x%08x\n", hres); + ok(!strcmp_wa(str, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str), "true"); + + /* Restore origin contentEditable */ + hres = IHTMLElement3_put_contentEditable(elem3, strDefault); + ok(hres == S_OK, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault), hres); + SysFreeString(strDefault); + + IHTMLElement3_Release(elem3); +} + #define test_input_type(i,t) _test_input_type(__LINE__,i,t) static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype) { @@ -3102,6 +3299,45 @@ static void _test_input_value(unsigned line, IUnknown *unk, const char *exval) IHTMLInputElement_Release(input); } +#define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t) +static void _test_input_get_form(unsigned line, IUnknown *unk, const char *id) +{ + IHTMLInputElement *input; + IHTMLFormElement *form; + IHTMLElement *elem; + HRESULT hres; + + ok_(__FILE__,line) (unk != NULL, "unk is NULL!\n"); + hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input); + ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres); + ok_(__FILE__,line) (input != NULL, "input == NULL\n"); + if(FAILED(hres) || input == NULL) + return; + + hres = IHTMLInputElement_get_form(input, &form); + ok_(__FILE__, line) (hres == S_OK, "get_form failed: %08x\n", hres); + ok_(__FILE__, line) (form != NULL, "form == NULL\n"); + if(FAILED(hres) || form == NULL){ + IHTMLInputElement_Release(input); + return; + } + + hres = IHTMLFormElement_QueryInterface(form, &IID_IHTMLElement, (void **)&elem); + ok_(__FILE__, line) (hres == S_OK, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres); + ok_(__FILE__, line) (elem != NULL, "elem == NULL\n"); + if(FAILED(hres) || elem == NULL){ + IHTMLInputElement_Release(input); + IHTMLFormElement_Release(form); + return; + } + + _test_elem_id(line, (IUnknown*)elem, id); + + IHTMLInputElement_Release(input); + IHTMLFormElement_Release(form); + IHTMLElement_Release(elem); +} + #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v) static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val) { @@ -3195,6 +3431,43 @@ static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const c _test_input_src(line, input, src); } +#define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r) +static void _test_input_set_size(unsigned line, IHTMLInputElement *input, LONG size, HRESULT exret) +{ + HRESULT hres; + + hres = IHTMLInputElement_put_size(input, size); + ok_(__FILE__,line) (hres == exret, "Expect ret = %08x, got: %08x\n", exret, hres); +} + +#define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s) +static void _test_input_get_size(unsigned line, IHTMLInputElement *input, LONG exsize) +{ + HRESULT hres; + LONG size; + + hres = IHTMLInputElement_get_size(input, &size); + ok_(__FILE__,line) (hres == S_OK, "get_size failed: %08x\n", hres); + ok_(__FILE__,line) (size == exsize, "Expect %d, got %d\n", exsize, size); + + hres = IHTMLInputElement_get_size(input, NULL); + ok_(__FILE__,line) (hres == E_INVALIDARG, "Expect ret E_INVALIDARG, got: %08x\n", hres); +} + +#define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b) +static void _test_input_readOnly(unsigned line, IHTMLInputElement *input, VARIANT_BOOL v) +{ + HRESULT hres; + VARIANT_BOOL b = 100; + + hres = IHTMLInputElement_put_readOnly(input, v); + ok_(__FILE__,line)(hres == S_OK, "put readOnly failed: %08x\n", hres); + + hres = IHTMLInputElement_get_readOnly(input, &b); + ok_(__FILE__,line)(hres == S_OK, "get readOnly failed: %08x\n", hres); + ok_(__FILE__,line)(v == b, "Expect %x, got %x\n", v, b); +} + #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c) static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass) { @@ -3355,40 +3628,6 @@ static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class _test_elem_class(line, unk, class); } -#define test_elem_id(e,i) _test_elem_id(__LINE__,e,i) -static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid) -{ - IHTMLElement *elem = _get_elem_iface(line, unk); - BSTR id = (void*)0xdeadbeef; - HRESULT hres; - - hres = IHTMLElement_get_id(elem, &id); - IHTMLElement_Release(elem); - ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres); - - if(exid) - ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id)); - else - ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id)); - - SysFreeString(id); -} - -#define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i) -static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id) -{ - IHTMLElement *elem = _get_elem_iface(line, unk); - BSTR tmp = a2bstr(new_id); - HRESULT hres; - - hres = IHTMLElement_put_id(elem, tmp); - IHTMLElement_Release(elem); - SysFreeString(tmp); - ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres); - - _test_elem_id(line, unk, new_id); -} - #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t) static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle) { @@ -3657,6 +3896,38 @@ static void _test_form_elements(unsigned line, IUnknown *unk) IHTMLFormElement_Release(form); } +#define test_form_reset(a) _test_form_reset(__LINE__,a) +static void _test_form_reset(unsigned line, IUnknown *unk) +{ + IHTMLFormElement *form = _get_form_iface(line, unk); + HRESULT hres; + + hres = IHTMLFormElement_reset(form); + ok_(__FILE__,line)(hres == S_OK, "reset failed: %08x\n", hres); + + IHTMLFormElement_Release(form); +} + +static void test_form_target(IUnknown *unk) +{ + IHTMLFormElement *form = get_form_iface(unk); + HRESULT hres; + BSTR str; + static const char target[] = "_blank"; + + str = a2bstr(target); + hres = IHTMLFormElement_put_target(form, str); + ok(hres == S_OK, "put_target(%s) failed: %08x\n", target, hres); + SysFreeString(str); + + hres = IHTMLFormElement_get_target(form, &str); + ok(hres == S_OK, "get_target failed: %08x\n", hres); + ok(!strcmp_wa(str, target), "Expected %s, got %s\n", target, wine_dbgstr_w(str)); + SysFreeString(str); + + IHTMLFormElement_Release(form); +} + #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b) static void _test_meta_name(unsigned line, IUnknown *unk, const char *exname) { @@ -3664,7 +3935,6 @@ static void _test_meta_name(unsigned line, IUnknown *unk, const char *exname) BSTR name = NULL; HRESULT hres; - meta = _get_metaelem_iface(line, unk); hres = IHTMLMetaElement_get_name(meta, &name); ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres); @@ -3680,7 +3950,6 @@ static void _test_meta_content(unsigned line, IUnknown *unk, const char *exconte BSTR content = NULL; HRESULT hres; - meta = _get_metaelem_iface(line, unk); hres = IHTMLMetaElement_get_content(meta, &content); ok_(__FILE__,line)(hres == S_OK, "get_content failed: %08x\n", hres); @@ -3696,7 +3965,6 @@ static void _test_meta_httpequiv(unsigned line, IUnknown *unk, const char *exval BSTR val = NULL; HRESULT hres; - meta = _get_metaelem_iface(line, unk); hres = IHTMLMetaElement_get_httpEquiv(meta, &val); ok_(__FILE__,line)(hres == S_OK, "get_httpEquiv failed: %08x\n", hres); @@ -3705,6 +3973,59 @@ static void _test_meta_httpequiv(unsigned line, IUnknown *unk, const char *exval IHTMLMetaElement_Release(meta); } +#define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b) +static void _test_meta_charset(unsigned line, IUnknown *unk, const char *exval) +{ + IHTMLMetaElement *meta; + BSTR val = NULL; + HRESULT hres; + + meta = _get_metaelem_iface(line, unk); + hres = IHTMLMetaElement_get_charset(meta, &val); + ok_(__FILE__,line)(hres == S_OK, "get_charset failed: %08x\n", hres); + if(exval) + ok_(__FILE__,line)(!strcmp_wa(val, exval), "charset = %s, expected %s\n", wine_dbgstr_w(val), exval); + else + ok_(__FILE__,line)(!val, "charset = %s, expected NULL\n", wine_dbgstr_w(val)); + SysFreeString(val); + IHTMLMetaElement_Release(meta); +} + +#define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b) +static void _set_meta_charset(unsigned line, IUnknown *unk, const char *vala) +{ + BSTR val = a2bstr(vala); + IHTMLMetaElement *meta; + HRESULT hres; + + meta = _get_metaelem_iface(line, unk); + hres = IHTMLMetaElement_put_charset(meta, val); + ok_(__FILE__,line)(hres == S_OK, "put_charset failed: %08x\n", hres); + SysFreeString(val); + IHTMLMetaElement_Release(meta); + + _test_meta_charset(line, unk, vala); +} + +#define test_link_media(a,b) _test_link_media(__LINE__,a,b) +static void _test_link_media(unsigned line, IHTMLElement *elem, const char *exval) +{ + IHTMLLinkElement *link = _get_link_iface(line, (IUnknown*)elem); + HRESULT hres; + BSTR str; + + str = a2bstr(exval); + hres = IHTMLLinkElement_put_media(link, str); + ok_(__FILE__,line)(hres == S_OK, "put_media(%s) failed: %08x\n", exval, hres); + SysFreeString(str); + + hres = IHTMLLinkElement_get_media(link, &str); + ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres); + ok_(__FILE__,line)(!strcmp_wa(str, exval), "got %s, expected %s\n", wine_dbgstr_w(str), exval); + SysFreeString(str); + IHTMLLinkElement_Release(link); +} + #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b) static void _test_link_disabled(unsigned line, IHTMLElement *elem, VARIANT_BOOL v) { @@ -3762,6 +4083,37 @@ static void _link_put_rel(unsigned line, IHTMLElement *elem, const char *v) _test_link_rel(line, elem, v); } +#define test_link_rev(a,b) _test_link_rev(__LINE__,a,b) +static void _test_link_rev(unsigned line, IHTMLElement *elem, const char *v) +{ + IHTMLLinkElement *link = _get_link_iface(line, (IUnknown*)elem); + BSTR rev; + HRESULT hres; + + hres = IHTMLLinkElement_get_rev(link, &rev); + ok_(__FILE__,line)(hres == S_OK, "get_rev failed: %08x\n", hres); + if(v) + ok_(__FILE__,line)(!strcmp_wa(rev, v), "rev = %s, expected %s\n", wine_dbgstr_w(rev), v); + else + ok_(__FILE__,line)(!rev, "rev = %s, expected NULL\n", wine_dbgstr_w(rev)); + + IHTMLLinkElement_Release(link); +} + +#define link_put_rev(a,b) _link_put_rev(__LINE__,a,b) +static void _link_put_rev(unsigned line, IHTMLElement *elem, const char *v) +{ + IHTMLLinkElement *link = _get_link_iface(line, (IUnknown*)elem); + BSTR str = a2bstr(v); + HRESULT hres; + + hres = IHTMLLinkElement_put_rev(link, str); + ok_(__FILE__,line)(hres == S_OK, "put_disabled failed: %08x\n", hres); + SysFreeString(str); + IHTMLLinkElement_Release(link); + _test_link_rev(line, elem, v); +} + #define test_link_type(a,b) _test_link_type(__LINE__,a,b) static void _test_link_type(unsigned line, IHTMLElement *elem, const char *v) { @@ -3884,10 +4236,19 @@ static void _get_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT HRESULT hres; hres = IHTMLDOMAttribute_get_nodeValue(attr, v); - ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres); + ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x\n", hres); ok_(__FILE__,line) (V_VT(v) == vt, "vt=%d, expected %d\n", V_VT(v), vt); } +#define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b) +static void _put_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT v) +{ + HRESULT hres; + + hres = IHTMLDOMAttribute_put_nodeValue(attr, v); + ok_(__FILE__,line) (hres == S_OK, "put_nodeValue failed: %08x\n", hres); +} + #define get_window_doc(e) _get_window_doc(__LINE__,e) static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window) { @@ -4237,6 +4598,7 @@ static void test_select_elem(IHTMLSelectElement *select) test_select_multiple(select, VARIANT_FALSE); test_select_set_multiple(select, VARIANT_TRUE); + test_select_remove(select); } static void test_form_item(IHTMLElement *elem) @@ -4890,6 +5252,25 @@ static void _test_language_string(unsigned line, const WCHAR *lang, LCID lcid) } } +#define test_table_length(t,l) _test_table_length(__LINE__,t,l) +static void _test_table_length(unsigned line, IHTMLTable *table, LONG expect) +{ + IHTMLElementCollection *col; + HRESULT hres; + LONG len; + + hres = IHTMLTable_get_rows(table, &col); + ok_(__FILE__,line)(hres == S_OK, "get_rows failed: %08x\n", hres); + ok_(__FILE__,line)(col != NULL, "col = NULL\n"); + if (hres != S_OK || col == NULL) + return; + hres = IHTMLElementCollection_get_length(col, &len); + ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres); + ok_(__FILE__,line)(len == expect, "Expect %d, got %d\n", expect, len); + + IHTMLElementCollection_Release(col); +} + static void test_navigator(IHTMLDocument2 *doc) { IHTMLWindow2 *window; @@ -5116,10 +5497,17 @@ static void test_doc_elem(IHTMLDocument2 *doc) IHTMLElement *elem; IHTMLDocument3 *doc3; HRESULT hres; + BSTR bstr; hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3); ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres); + hres = IHTMLDocument2_toString(doc, &bstr); + ok(hres == S_OK, "toString failed: %08x\n", hres); + ok(!strcmp_wa(bstr, "[object]"), + "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + hres = IHTMLDocument3_get_documentElement(doc3, &elem); IHTMLDocument3_Release(doc3); ok(hres == S_OK, "get_documentElement failed: %08x\n", hres); @@ -5239,7 +5627,7 @@ static void test_body_funs(IHTMLBodyElement *body) hres = IHTMLBodyElement_get_bgColor(body, &vbg); ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); - ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); VariantClear(&vbg); @@ -5368,6 +5756,33 @@ static void test_window(IHTMLDocument2 *doc) IHTMLWindow2_Release(window); } +static void test_dom_implementation(IHTMLDocument2 *doc) +{ + IHTMLDocument5 *doc5 = get_htmldoc5_iface((IUnknown*)doc); + IHTMLDOMImplementation *dom_implementation; + VARIANT_BOOL b; + VARIANT v; + BSTR str; + HRESULT hres; + + hres = IHTMLDocument5_get_implementation(doc5, &dom_implementation); + IHTMLDocument5_Release(doc5); + ok(hres == S_OK, "get_implementation failed: %08x\n", hres); + ok(dom_implementation != NULL, "dom_implementation == NULL\n"); + + str = a2bstr("test"); + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("1.0"); + b = 100; + hres = IHTMLDOMImplementation_hasFeature(dom_implementation, str, v, &b); + SysFreeString(str); + VariantClear(&v); + ok(hres == S_OK, "hasFeature failed: %08x\n", hres); + ok(!b, "hasFeature returned %x\n", b); + + IHTMLDOMImplementation_Release(dom_implementation); +} + static void test_defaults(IHTMLDocument2 *doc) { IHTMLStyleSheetsCollection *stylesheetcol; @@ -5502,6 +5917,7 @@ static void test_defaults(IHTMLDocument2 *doc) test_default_selection(doc); test_doc_title(doc, ""); + test_dom_implementation(doc); } #define test_button_name(a,b) _test_button_name(__LINE__,a,b) @@ -5571,6 +5987,57 @@ static void test_button_elem(IHTMLElement *elem) set_button_name(elem, "button name"); } +#define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i) +static void _test_tr_possess(unsigned line, IHTMLElement *elem, + IHTMLTableRow *row, LONG len, const char *id) +{ + IHTMLElementCollection *col; + IDispatch *disp; + HRESULT hres; + LONG lval; + VARIANT var; + + hres = IHTMLTableRow_get_cells(row, &col); + ok_(__FILE__, line)(hres == S_OK, "get_cells failed: %08x\n", hres); + ok_(__FILE__, line)(col != NULL, "get_cells returned NULL\n"); + + hres = IHTMLElementCollection_get_length(col, &lval); + ok_(__FILE__, line)(hres == S_OK, "get length failed: %08x\n", hres); + ok_(__FILE__, line)(lval == len, "expected len = %d, got %d\n", len, lval); + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = a2bstr(id); + hres = IHTMLElementCollection_tags(col, var, &disp); + ok_(__FILE__, line)(hres == S_OK, "search by tags(%s) failed: %08x\n", id, hres); + ok_(__FILE__, line)(disp != NULL, "disp == NULL\n"); + + VariantClear(&var); + IDispatch_Release(disp); + IHTMLElementCollection_Release(col); +} + +static void test_tr_modify(IHTMLElement *elem, IHTMLTableRow *row) +{ + HRESULT hres; + IDispatch *disp; + IHTMLTableCell *cell; + + hres = IHTMLTableRow_deleteCell(row, 0); + ok(hres == S_OK, "deleteCell failed: %08x\n", hres); + test_tr_possess(elem, row, 1, "td2"); + + hres = IHTMLTableRow_insertCell(row, 0, &disp); + ok(hres == S_OK, "insertCell failed: %08x\n", hres); + ok(disp != NULL, "disp == NULL\n"); + hres = IDispatch_QueryInterface(disp, &IID_IHTMLTableCell, (void **)&cell); + ok(hres == S_OK, "Could not get IID_IHTMLTableCell interface: %08x\n", hres); + ok(cell != NULL, "cell == NULL\n"); + if (SUCCEEDED(hres)) + IHTMLTableCell_Release(cell); + test_tr_possess(elem, row, 2, "td2"); + IDispatch_Release(disp); +} + static void test_tr_elem(IHTMLElement *elem) { IHTMLElementCollection *col; @@ -5642,7 +6109,7 @@ static void test_tr_elem(IHTMLElement *elem) hres = IHTMLTableRow_get_bgColor(row, &vbg); ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); - ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); VariantClear(&vbg); @@ -5654,7 +6121,7 @@ static void test_tr_elem(IHTMLElement *elem) hres = IHTMLTableRow_get_bgColor(row, &vbg); ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); - ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); VariantClear(&vbg); @@ -5663,9 +6130,80 @@ static void test_tr_elem(IHTMLElement *elem) ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); VariantClear(&vDefaultbg); + test_tr_modify(elem, row); + IHTMLTableRow_Release(row); } +static void test_td_elem(IHTMLElement *elem) +{ + IHTMLTableCell *cell; + HRESULT hres; + LONG lval; + BSTR str; + VARIANT vbg, vDefaultbg; + + hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableCell, (void**)&cell); + ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres); + if(FAILED(hres)) + return; + + lval = 0xdeadbeef; + hres = IHTMLTableCell_get_cellIndex(cell, &lval); + ok(hres == S_OK, "get cellIndex failed: %08x\n", hres); + ok(lval == 1, "Expected 1, got %d\n", lval); + + str = a2bstr("left"); + hres = IHTMLTableCell_put_align(cell, str); + ok(hres == S_OK, "put_align failed: %08x\n", hres); + SysFreeString(str); + + str = NULL; + hres = IHTMLTableCell_get_align(cell, &str); + ok(hres == S_OK, "get_align failed: %08x\n", hres); + ok(str != NULL, "str is NULL\n"); + if (str != NULL && hres == S_OK) { + ok(!strcmp_wa(str, "left"), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + } + + hres = IHTMLTableCell_get_bgColor(cell, &vDefaultbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n"); + ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg))); + + V_VT(&vbg) = VT_BSTR; + V_BSTR(&vbg) = a2bstr("red"); + hres = IHTMLTableCell_put_bgColor(cell, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLTableCell_get_bgColor(cell, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + + V_VT(&vbg) = VT_I4; + V_I4(&vbg) = 0xff0000; + hres = IHTMLTableCell_put_bgColor(cell, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLTableCell_get_bgColor(cell, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + + /* Restore Originial */ + hres = IHTMLTableCell_put_bgColor(cell, vDefaultbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vDefaultbg); + + IHTMLTableCell_Release(cell); +} + static void test_label_elem(IHTMLElement *elem) { IHTMLLabelElement *label; @@ -5721,10 +6259,45 @@ static void _test_table_cell_spacing(unsigned line, IHTMLTable *table, const cha VariantClear(&v); } +static void test_table_modify(IHTMLTable *table) +{ + IDispatch *disp; + IHTMLTableRow *row; + HRESULT hres; + LONG index; + + test_table_length(table, 2); + + hres = IHTMLTable_insertRow(table, 0, &disp); + ok(hres == S_OK, "insertRow failed: %08x\n", hres); + ok(disp != NULL, "disp == NULL\n"); + test_table_length(table, 3); + if (hres != S_OK || disp == NULL) + return; + + hres = IDispatch_QueryInterface(disp, &IID_IHTMLTableRow, (void**)&row); + IDispatch_Release(disp); + + ok(hres == S_OK, "QueryInterface failed: %08x\n", hres); + ok(row != NULL, "row == NULL\n"); + + index = 0xdeadbeef; + hres = IHTMLTableRow_get_rowIndex(row, &index); + ok(hres == S_OK, "get_rowIndex failed: %08x\n", hres); + ok(index == 0, "index = %d, expected 0\n", index); + + IHTMLTableRow_Release(row); + + hres = IHTMLTable_deleteRow(table, 0); + ok(hres == S_OK, "deleteRow failed: %08x\n", hres); + test_table_length(table, 2); +} + static void test_table_elem(IHTMLElement *elem) { IHTMLElementCollection *col; IHTMLTable *table; + IHTMLTable3 *table3; IHTMLDOMNode *node; VARIANT v; HRESULT hres; @@ -5740,6 +6313,11 @@ static void test_table_elem(IHTMLElement *elem) if(FAILED(hres)) return; + hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable3, (void**)&table3); + ok(hres == S_OK, "Could not get IHTMLTable3 iface: %08x\n", hres); + if(FAILED(hres)) + return; + col = NULL; hres = IHTMLTable_get_rows(table, &col); ok(hres == S_OK, "get_rows failed: %08x\n", hres); @@ -5808,7 +6386,7 @@ static void test_table_elem(IHTMLElement *elem) hres = IHTMLTable_get_bgColor(table, &vbg); ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); - ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); VariantClear(&vbg); @@ -5820,7 +6398,7 @@ static void test_table_elem(IHTMLElement *elem) hres = IHTMLTable_get_bgColor(table, &vbg); ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); - ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); VariantClear(&vbg); @@ -5829,6 +6407,76 @@ static void test_table_elem(IHTMLElement *elem) ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); VariantClear(&vDefaultbg); + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("11"); + hres = IHTMLTable_put_width(table, v); + ok(hres == S_OK, "put_width = %08x\n", hres); + VariantClear(&v); + IHTMLTable_get_width(table, &v); + ok(hres == S_OK, "get_width = %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("11.9"); + hres = IHTMLTable_put_width(table, v); + ok(hres == S_OK, "put_width = %08x\n", hres); + VariantClear(&v); + IHTMLTable_get_width(table, &v); + ok(hres == S_OK, "get_width = %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("40.2%"); + hres = IHTMLTable_put_width(table, v); + ok(hres == S_OK, "put_width = %08x\n", hres); + VariantClear(&v); + IHTMLTable_get_width(table, &v); + ok(hres == S_OK, "get_width = %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_I4; + V_I4(&v) = 11; + hres = IHTMLTable_put_width(table, v); + ok(hres == S_OK, "put_width = %08x\n", hres); + IHTMLTable_get_width(table, &v); + ok(hres == S_OK, "get_width = %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_R8; + V_R8(&v) = 11.9; + hres = IHTMLTable_put_width(table, v); + ok(hres == S_OK, "put_width = %08x\n", hres); + IHTMLTable_get_width(table, &v); + ok(hres == S_OK, "get_width = %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + + bstr = a2bstr("box"); + hres = IHTMLTable_put_frame(table, bstr); + ok(hres == S_OK, "put_frame = %08x\n", hres); + SysFreeString(bstr); + hres = IHTMLTable_get_frame(table, &bstr); + ok(hres == S_OK, "get_frame = %08x\n", hres); + ok(!strcmp_wa(bstr, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + test_table_modify(table); + bstr = a2bstr("summary"); + hres = IHTMLTable3_put_summary(table3, bstr); + ok(hres == S_OK, "put_summary = %08x\n", hres); + SysFreeString(bstr); + + hres = IHTMLTable3_get_summary(table3, &bstr); + ok(hres == S_OK, "get_summary = %08x\n", hres); + ok(!strcmp_wa(bstr, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + IHTMLTable3_Release(table3); IHTMLTable_Release(table); } @@ -6087,6 +6735,8 @@ static void test_stylesheet(IDispatch *disp) hres = IHTMLStyleSheet_get_rules(stylesheet, &col); ok(hres == S_OK, "get_rules failed: %08x\n", hres); ok(col != NULL, "col == NULL\n"); + + test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetRulesCollection, &IID_IHTMLStyleSheetRulesCollection, "[object]"); IHTMLStyleSheetRulesCollection_Release(col); href = (void*)0xdeadbeef; @@ -6180,7 +6830,55 @@ static void test_child_col_disp(IHTMLDOMChildrenCollection *col) IDispatchEx_Release(dispex); } +static void test_enum_children(IUnknown *unk, unsigned len) +{ + IEnumVARIANT *enum_var; + ULONG i, fetched; + VARIANT v; + HRESULT hres; + hres = IUnknown_QueryInterface(unk, &IID_IEnumVARIANT, (void**)&enum_var); + ok(hres == S_OK, "Could not get IEnumVARIANT iface: %08x\n", hres); + + for(i=0; i 2 ? len-2 : 0); + ok(hres == S_OK, "Skip failed: %08x\n", hres); + + hres = IEnumVARIANT_Reset(enum_var); + ok(hres == S_OK, "Reset failed: %08x\n", hres); + + hres = IEnumVARIANT_Skip(enum_var, len+1); + ok(hres == S_FALSE, "Skip failed: %08x\n", hres); + + IEnumVARIANT_Release(enum_var); +} static void test_elems(IHTMLDocument2 *doc) { @@ -6239,6 +6937,15 @@ static void test_elems(IHTMLDocument2 *doc) ok(hres == S_OK, "get_all failed: %08x\n", hres); test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0])); test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0])); + + elem = get_elem_col_item_idx(col, 0); + test_elem_source_index(elem, 0); + IHTMLElement_Release(elem); + + elem = get_elem_col_item_idx(col, 3); + test_elem_source_index(elem, 3); + IHTMLElement_Release(elem); + IHTMLElementCollection_Release(col); hres = IHTMLDocument2_get_images(doc, &collection); @@ -6337,10 +7044,12 @@ static void test_elems(IHTMLDocument2 *doc) test_elem_contains(elem, elem3, VARIANT_FALSE); test_elem_contains(elem, elem2, VARIANT_FALSE); test_elem_contains(elem, elem, VARIANT_TRUE); + test_elem_contains(elem, NULL, VARIANT_FALSE); IHTMLElement_Release(elem2); elem2 = test_elem_get_parent((IUnknown*)elem3); ok(elem2 == NULL, "elem2 != NULL\n"); + test_elem_source_index(elem3, 0); IHTMLElement_Release(elem3); test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2, NULL); @@ -6405,8 +7114,10 @@ static void test_elems(IHTMLDocument2 *doc) ok(hres == S_OK, "get_type failed: %08x\n", hres); ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type)); - hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript")); + type = a2bstr("text/javascript"); + hres = IHTMLScriptElement_put_type (script, type); ok(hres == S_OK, "put_type failed: %08x\n", hres); + SysFreeString(type); hres = IHTMLScriptElement_get_type(script, &type); ok(hres == S_OK, "get_type failed: %08x\n", hres); ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type)); @@ -6482,12 +7193,24 @@ static void test_elems(IHTMLDocument2 *doc) test_input_src(input, NULL); test_input_set_src(input, "about:blank"); + test_input_set_size(input, 15, S_OK); + test_input_get_size(input, 15); + test_input_set_size(input, -100, CTL_E_INVALIDPROPERTYVALUE); + test_input_get_size(input, 15); + test_input_set_size(input, 0, CTL_E_INVALIDPROPERTYVALUE); + test_input_get_size(input, 15); + + test_input_readOnly(input, VARIANT_TRUE); + test_input_readOnly(input, VARIANT_FALSE); + IHTMLInputElement_Release(input); IHTMLElement_Release(elem); } elem = get_elem_by_id(doc, "imgid", TRUE); if(elem) { + test_img_align((IUnknown*)elem, "left"); + test_img_name((IUnknown*)elem, "WineImg"); test_img_src((IUnknown*)elem, "", NULL); test_img_set_src((IUnknown*)elem, "about:blank"); test_img_src((IUnknown*)elem, "about:blank", NULL); @@ -6495,6 +7218,8 @@ static void test_elems(IHTMLDocument2 *doc) test_img_set_alt((IUnknown*)elem, "alt test"); test_img_name((IUnknown*)elem, "WineImg"); test_img_complete(elem, VARIANT_FALSE); + test_img_isMap((IUnknown*)elem, VARIANT_TRUE); + test_img_isMap((IUnknown*)elem, VARIANT_FALSE); IHTMLElement_Release(elem); } @@ -6502,6 +7227,7 @@ static void test_elems(IHTMLDocument2 *doc) if(elem) { test_dynamic_properties(elem); test_attr_collection(elem); + test_contenteditable((IUnknown*)elem); IHTMLElement_Release(elem); } @@ -6528,6 +7254,13 @@ static void test_elems(IHTMLDocument2 *doc) IHTMLElement_Release(elem); } + elem = get_doc_elem_by_id(doc, "td2"); + ok(elem != NULL, "elem == NULL\n"); + if(elem) { + test_td_elem(elem); + IHTMLElement_Release(elem); + } + elem = get_doc_elem_by_id(doc, "row2"); ok(elem != NULL, "elem == NULL\n"); if(elem) { @@ -6609,6 +7342,8 @@ static void test_elems(IHTMLDocument2 *doc) test_meta_name((IUnknown*)elem, "meta name"); test_meta_content((IUnknown*)elem, "text/html; charset=utf-8"); test_meta_httpequiv((IUnknown*)elem, "Content-Type"); + test_meta_charset((IUnknown*)elem, NULL); + set_meta_charset((IUnknown*)elem, "utf-8"); IHTMLElement_Release(elem); } @@ -6640,6 +7375,7 @@ static void test_elems(IHTMLDocument2 *doc) child_col = get_child_nodes((IUnknown*)elem); ok(child_col != NULL, "child_coll == NULL\n"); if(child_col) { + IUnknown *enum_unk; LONG length = 0; test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]"); @@ -6691,6 +7427,13 @@ static void test_elems(IHTMLDocument2 *doc) test_child_col_disp(child_col); + hres = IHTMLDOMChildrenCollection_get__newEnum(child_col, &enum_unk); + ok(hres == S_OK, "get__newEnum failed: %08x\n", hres); + + test_enum_children(enum_unk, length); + + IUnknown_Release(enum_unk); + IHTMLDOMChildrenCollection_Release(child_col); } @@ -6814,12 +7557,31 @@ static void test_attr(IHTMLElement *elem) ok(!strcmp_wa(V_BSTR(&v), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("divid2"); + put_attr_node_value(attr, v); + + get_attr_node_value(attr, &v, VT_BSTR); + ok(!strcmp_wa(V_BSTR(&v), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + IHTMLDOMAttribute_Release(attr); attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE); get_attr_node_value(attr, &v, VT_BSTR); ok(!V_BSTR(&v), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("newvalue"); + put_attr_node_value(attr, v); + VariantClear(&v); + + attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE); + get_attr_node_value(attr, &v, VT_BSTR); + ok(!strcmp_wa(V_BSTR(&v), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + test_attr_specified(attr, VARIANT_TRUE); IHTMLDOMAttribute_Release(attr); @@ -6830,6 +7592,14 @@ static void test_attr(IHTMLElement *elem) get_attr_node_value(attr, &v, VT_I4); ok(V_I4(&v) == 100, "V_I4(v) = %d\n", V_I4(&v)); test_attr_specified(attr, VARIANT_TRUE); + + V_VT(&v) = VT_I4; + V_I4(&v) = 150; + put_attr_node_value(attr, v); + + get_attr_node_value(attr, &v, VT_I4); + ok(V_I4(&v) == 150, "V_I4(v) = %d\n", V_I4(&v)); + IHTMLDOMAttribute_Release(attr); attr = get_elem_attr_node((IUnknown*)elem, "tabIndex", TRUE); @@ -6925,10 +7695,13 @@ static void test_elems2(IHTMLDocument2 *doc) if(elem) { test_link_disabled(elem, VARIANT_FALSE); test_link_rel(elem, "stylesheet"); + test_link_rev(elem, NULL); test_link_type(elem, "text/css"); test_link_href(elem, "about:blank"); + test_link_media(elem, "all"); link_put_disabled(elem, VARIANT_TRUE); link_put_rel(elem, "prev"); + link_put_rev(elem, "next"); link_put_type(elem, "text/plain"); link_put_href(elem, "about:prev"); IHTMLElement_Release(elem); @@ -6974,7 +7747,7 @@ static void test_elems2(IHTMLDocument2 *doc) test_insert_adjacent_elems(doc, div); test_elem_set_innerhtml((IUnknown*)div, - "
"); + "
"); elem = get_elem_by_id(doc, "form", TRUE); if(elem) { test_form_length((IUnknown*)elem, 2); @@ -6993,6 +7766,12 @@ static void test_elems2(IHTMLDocument2 *doc) test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png"); test_form_encoding((IUnknown*)elem, "multipart/form-data"); test_form_elements((IUnknown*)elem); + test_form_reset((IUnknown*)elem); + test_form_target((IUnknown*)elem); + IHTMLElement_Release(elem); + + elem = get_elem_by_id(doc, "inputid", TRUE); + test_input_get_form((IUnknown*)elem, "form"); IHTMLElement_Release(elem); } @@ -7023,6 +7802,7 @@ static void test_create_elems(IHTMLDocument2 *doc) ok(type == 1, "type=%d\n", type); test_ifaces((IUnknown*)elem, elem_iids); test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]"); + test_elem_source_index(elem, -1); body = doc_get_body(doc); test_node_has_child((IUnknown*)body, VARIANT_FALSE); @@ -7619,7 +8399,9 @@ static void test_docfrag(IHTMLDocument2 *doc) ok(location == (void*)0xdeadbeef, "location changed\n"); br = test_create_elem(doc, "BR"); + test_elem_source_index(br, -1); test_node_append_child((IUnknown*)frag, (IUnknown*)br); + test_elem_source_index(br, 0); IHTMLElement_Release(br); div = get_elem_by_id(doc, "divid", TRUE); diff --git a/rostests/winetests/mshtml/events.c b/rostests/winetests/mshtml/events.c index f8f833b2d6b..6e883e2a801 100644 --- a/rostests/winetests/mshtml/events.c +++ b/rostests/winetests/mshtml/events.c @@ -88,7 +88,6 @@ DEFINE_EXPECT(iframe_onload); static HWND container_hwnd = NULL; static IHTMLWindow2 *window; static IOleDocumentView *view; -static BOOL xy_todo; static BOOL is_ie9plus; typedef struct { @@ -1638,8 +1637,6 @@ static void test_onclick(IHTMLDocument2 *doc) CHECK_CALLED(invoke_onclick); } - xy_todo = TRUE; - SET_EXPECT(div_onclick); SET_EXPECT(div_onclick_attached); SET_EXPECT(body_onclick); @@ -1847,7 +1844,7 @@ static void test_imgload(IHTMLDocument2 *doc) ok(V_DISPATCH(&v) == (IDispatch*)&img_onerror_obj, "V_DISPATCH(onerror) != onerrorFunc\n"); VariantClear(&v); - str = a2bstr("http://www.winehq.org/images/winehq_logo_text.png"); + str = a2bstr("https://www.winehq.org/images/winehq_logo_text.png"); hres = IHTMLImgElement_put_src(img, str); ok(hres == S_OK, "put_src failed: %08x\n", hres); SysFreeString(str); @@ -2757,7 +2754,6 @@ static void run_test(const char *str, testfunc_t test) MSG msg; HRESULT hres; - xy_todo = FALSE; doc = create_document(); if (!doc) return; diff --git a/rostests/winetests/mshtml/events.html b/rostests/winetests/mshtml/events.html index bf8a21f8bd8..d4e26441223 100644 --- a/rostests/winetests/mshtml/events.html +++ b/rostests/winetests/mshtml/events.html @@ -114,14 +114,16 @@ function test_handler_this() { ok(calls == "div2,div2*,div1,div1*,body,body*", "calls = " + calls); } -function runTests(t) { +window.onload = function() { try { ok(cnt == 1, "cnt=" + cnt + " exception during loading?"); - ok(t === window, "t !== window"); + ok(this === window, "this !== window"); ok(typeof(window.onload) === "function", "typeof(window.onload) = " + typeof(window.onload)); ok(document.body.onload === window.onload, "document.body.onload !== window.onload"); + ok(img_onload_called, "img.onload not called before window.onload"); + test_scriptfor(); ondataavailable_test(); test_handler_this(); @@ -132,8 +134,18 @@ function runTests(t) { external.reportSuccess(); } + - +
+ diff --git a/rostests/winetests/mshtml/exectest.html b/rostests/winetests/mshtml/exectest.html index ca06e3c3a2a..6bf5e8e5f1a 100644 --- a/rostests/winetests/mshtml/exectest.html +++ b/rostests/winetests/mshtml/exectest.html @@ -55,7 +55,7 @@ try { testPutSrc(); testPutText(); }catch(e) { - ok(false, "Got an exception"); + ok(false, "Got an exception " + e.message); } function testPutSrc2() { @@ -123,7 +123,7 @@ document.body.onload = function() { testPutSrc2(); testPutText2(); }catch(e) { - ok(false, "got an exception"); + ok(false, "got an exception " + e.message); } external.reportSuccess(); diff --git a/rostests/winetests/mshtml/htmldoc.c b/rostests/winetests/mshtml/htmldoc.c index ffa22343980..16ac4a556aa 100644 --- a/rostests/winetests/mshtml/htmldoc.c +++ b/rostests/winetests/mshtml/htmldoc.c @@ -978,6 +978,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D case 3000029: case 3000030: case 3000031: + case 3000032: /* TODO */ return S_OK; } @@ -2855,6 +2856,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID test_readyState(NULL); return S_OK; case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY: + case OLECMDID_PAGEAVAILABLE: case 6058: return E_FAIL; /* FIXME */ default: @@ -2864,7 +2866,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID } if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) { - if(nCmdID != 63 && (!is_refresh || nCmdID != 37)) + if(nCmdID != 63 && nCmdID != 178 && (!is_refresh || nCmdID != 37)) test_readyState(NULL); ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt); @@ -2976,13 +2978,16 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID case 83: case 102: + case 133: case 134: /* TODO */ case 135: case 136: /* TODO */ + case 137: case 139: /* TODO */ case 143: /* TODO */ case 144: /* TODO */ case 178: + case 179: return E_NOTIMPL; default: @@ -3162,7 +3167,9 @@ static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REF ok(puArgErr != NULL, "puArgErr == NULL\n"); ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult)); ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags); - test_readyState(NULL); + + if(dispIdMember != DISPID_AMBIENT_SILENT && dispIdMember != DISPID_AMBIENT_OFFLINEIFNOTCONNECTED) + test_readyState(NULL); switch(dispIdMember) { case DISPID_AMBIENT_USERMODE: @@ -3290,13 +3297,15 @@ static HRESULT WINAPI TravelLog_QueryInterface(ITravelLog *iface, REFIID riid, v { static const IID IID_IIETravelLog2 = {0xb67cefd2,0xe3f1,0x478a,{0x9b,0xfa,0xd8,0x93,0x70,0x37,0x5e,0x94}}; static const IID IID_unk_travellog = {0x6afc8b7f,0xbc17,0x4a95,{0x90,0x2f,0x6f,0x5c,0xb5,0x54,0xc3,0xd8}}; + static const IID IID_unk_travellog2 = {0xf6d02767,0x9c80,0x428d,{0xb9,0x74,0x3f,0x17,0x29,0x45,0x3f,0xdb}}; if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_ITravelLog, riid)) { *ppv = iface; return S_OK; } - if(!IsEqualGUID(&IID_IIETravelLog2, riid) && !IsEqualGUID(&IID_unk_travellog, riid)) + if(!IsEqualGUID(&IID_IIETravelLog2, riid) && !IsEqualGUID(&IID_unk_travellog, riid) + && !IsEqualGUID(&IID_unk_travellog2, riid)) ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid)); *ppv = NULL; @@ -3430,7 +3439,7 @@ static HRESULT WINAPI DocObjectService_FireBeforeNavigate2(IDocObjectService *i ok(!pDispatch, "pDispatch = %p\n", pDispatch); ok(!strcmp_wa(lpszUrl, nav_url), "lpszUrl = %s, expected %s\n", wine_dbgstr_w(lpszUrl), nav_url); - ok(dwFlags == 0x40 || !dwFlags || dwFlags == 0x50, "dwFlags = %x\n", dwFlags); + ok(dwFlags == 0x140 /* IE11*/ || dwFlags == 0x40 || !dwFlags || dwFlags == 0x50, "dwFlags = %x\n", dwFlags); ok(!lpszFrameName, "lpszFrameName = %s\n", wine_dbgstr_w(lpszFrameName)); if(!testing_submit) { ok(!pPostData, "pPostData = %p\n", pPostData); @@ -5291,7 +5300,7 @@ static void test_doscroll(IUnknown *unk) switch(load_state) { case LD_DOLOAD: case LD_NO: - if(!nav_url) + if(!nav_url && !editmode) ok(!elem, "elem != NULL\n"); default: break; @@ -5453,8 +5462,29 @@ static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID ri hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, NULL); ok(hres == S_OK, "Advise failed: %08x\n", hres); } else if(IsEqualGUID(&IID_IDispatch, riid)) { + IEnumConnections *enum_conn; + CONNECTDATA conn_data; + ULONG fetched; + hres = IConnectionPoint_Advise(cp, (IUnknown*)&EventDispatch, &cookie); ok(hres == S_OK, "Advise failed: %08x\n", hres); + + hres = IConnectionPoint_EnumConnections(cp, &enum_conn); + ok(hres == S_OK, "EnumConnections failed: %08x\n", hres); + + fetched = 0; + hres = IEnumConnections_Next(enum_conn, 1, &conn_data, &fetched); + ok(hres == S_OK, "Next failed: %08x\n", hres); + ok(conn_data.pUnk == (IUnknown*)&EventDispatch, "conn_data.pUnk == EventDispatch\n"); + ok(conn_data.dwCookie == cookie, "conn_data.dwCookie != cookie\n"); + IUnknown_Release(conn_data.pUnk); + + fetched = 0xdeadbeef; + hres = IEnumConnections_Next(enum_conn, 1, &conn_data, &fetched); + ok(hres == S_FALSE, "Next failed: %08x\n", hres); + ok(!fetched, "fetched = %d\n", fetched); + + IEnumConnections_Release(enum_conn); } IConnectionPoint_Release(cp); @@ -5722,6 +5752,8 @@ static void test_download(DWORD flags) SET_EXPECT(NavigateWithBindCtx); SET_EXPECT(Exec_Explorer_38); /* todo_wine */ } + if(editmode || is_refresh) + SET_EXPECT(Exec_ShellDocView_138); expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */ while(!*b && GetMessageW(&msg, NULL, 0, 0)) { @@ -5844,6 +5876,8 @@ static void test_download(DWORD flags) CHECK_CALLED(NavigateWithBindCtx); todo_wine CHECK_NOT_CALLED(Exec_Explorer_38); } + if(editmode || is_refresh) + CLEAR_CALLED(Exec_ShellDocView_138); /* IE11 */ if(!is_extern) load_state = LD_COMPLETE; @@ -5949,7 +5983,7 @@ static void test_put_href(IHTMLDocument2 *doc, BOOL use_replace, const char *hre CHECK_CALLED(TranslateUrl); if(support_wbapp) { CHECK_CALLED(FireBeforeNavigate2); - CHECK_CALLED(Exec_ShellDocView_67); + CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */ if(!is_hash) { CHECK_CALLED(Invoke_AMBIENT_SILENT); CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); @@ -6015,7 +6049,7 @@ static void test_put_href(IHTMLDocument2 *doc, BOOL use_replace, const char *hre ok(hres == S_OK, "SuperNavigate failed: %08x\n", hres); CHECK_CALLED(TranslateUrl); - CHECK_CALLED(Exec_ShellDocView_67); + CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */ CHECK_CALLED(Invoke_AMBIENT_SILENT); CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); CHECK_CALLED(Exec_ShellDocView_63); @@ -6086,8 +6120,8 @@ static void test_load_history(IHTMLDocument2 *doc) hres = IPersistHistory_LoadHistory(per_hist, history_stream, NULL); ok(hres == S_OK, "LoadHistory failed: %08x\n", hres); - CHECK_CALLED_BROKEN(Exec_ShellDocView_138); - CHECK_CALLED(Exec_ShellDocView_67); + CLEAR_CALLED(Exec_ShellDocView_138); /* Not called by IE11 */ + CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */ CHECK_CALLED(FireBeforeNavigate2); CHECK_CALLED(Invoke_AMBIENT_SILENT); CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); @@ -7810,11 +7844,11 @@ static void test_submit(void) CHECK_CALLED(TranslateUrl); CHECK_CALLED(FireBeforeNavigate2); - CHECK_CALLED(Exec_ShellDocView_67); + CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */ CHECK_CALLED(Invoke_AMBIENT_SILENT); CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); CHECK_CALLED(Exec_ShellDocView_63); - todo_wine CHECK_CALLED(Exec_ShellDocView_84); + CLEAR_CALLED(Exec_ShellDocView_84); /* Not called by IE11 */ CHECK_CALLED(CreateInstance); CHECK_CALLED(Start); CHECK_CALLED(Protocol_Read); diff --git a/rostests/winetests/mshtml/jstest.html b/rostests/winetests/mshtml/jstest.html index bfa98c08f0f..78611965842 100644 --- a/rostests/winetests/mshtml/jstest.html +++ b/rostests/winetests/mshtml/jstest.html @@ -165,6 +165,9 @@ function test_override_functions() { var tmp = div.addBehavior(); ok(tmp === "test", "div.addBehavior() = " + tmp); + + tmp = String(div.attachEvent); + ok(tmp == "\nfunction attachEvent() {\n [native code]\n}\n", "String(div.attachEvent) = " + tmp); } function test_forin() { @@ -245,7 +248,7 @@ function runTest() { try { runTests(); }catch(e) { - ok(false, "got exception"); + ok(false, "got exception " + e.message); } external.reportSuccess(); diff --git a/rostests/winetests/mshtml/nav_test.html b/rostests/winetests/mshtml/nav_test.html index d106dfc2412..bc629a4b22b 100644 --- a/rostests/winetests/mshtml/nav_test.html +++ b/rostests/winetests/mshtml/nav_test.html @@ -18,6 +18,7 @@ function nav_back_test() { } iframe.onload = function() { + iframe.onload = null; var href = iframe.contentWindow.location.href; ok(/.*blank2.html/.test(href), "Unexpected href " + href); next_test(); @@ -27,8 +28,24 @@ function nav_back_test() { subframe.src = "blank.html"; } +function window_navigate_test() { + external.trace("Runnint window.navigate() tests..."); + + var iframe = document.getElementById("testframe"); + + iframe.onload = function() { + iframe.onlod = null; + var href = iframe.contentWindow.location.href; + ok(href === "about:blank", "Unexpected href " + href); + next_test(); + } + + iframe.contentWindow.navigate("about:blank"); +} + var tests = [ nav_back_test, + window_navigate_test, function() { external.reportSuccess(); } ]; diff --git a/rostests/winetests/mshtml/script.c b/rostests/winetests/mshtml/script.c index 7337942259a..dd68d02fa49 100644 --- a/rostests/winetests/mshtml/script.c +++ b/rostests/winetests/mshtml/script.c @@ -132,6 +132,8 @@ DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr); DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller); DEFINE_EXPECT(external_success); DEFINE_EXPECT(QS_VariantConversion); +DEFINE_EXPECT(QS_IActiveScriptSite); +DEFINE_EXPECT(QS_GetCaller); DEFINE_EXPECT(ChangeType); #define TESTSCRIPT_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80746}" @@ -162,6 +164,9 @@ static HRESULT ax_getopt_hres = S_OK, ax_setopt_dispex_hres = S_OK; static HRESULT ax_setopt_disp_caller_hres = S_OK, ax_setopt_disp_data_hres = S_OK; static BOOL skip_loadobject_tests; +static IActiveScriptSite *site; +static SCRIPTSTATE state; + static int strcmp_wa(LPCWSTR strw, const char *stra) { CHAR buf[512]; @@ -332,6 +337,19 @@ static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFG return S_OK; } + if(IsEqualGUID(guidService, &IID_IActiveScriptSite)) { + CHECK_EXPECT(QS_IActiveScriptSite); + ok(IsEqualGUID(riid, &IID_IOleCommandTarget), "uenxpected riid %s\n", wine_dbgstr_guid(riid)); + return IActiveScriptSite_QueryInterface(site, riid, ppv); + } + + if(IsEqualGUID(guidService, &SID_GetCaller)) { + CHECK_EXPECT(QS_GetCaller); + ok(IsEqualGUID(riid, &IID_IServiceProvider), "uenxpected riid %s\n", wine_dbgstr_guid(riid)); + *ppv = NULL; + return E_NOINTERFACE; + } + ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService)); return E_NOINTERFACE; } @@ -1280,9 +1298,6 @@ static void load_doc(IHTMLDocument2 *doc, const char *str) IHTMLElement_Release(body); } -static IActiveScriptSite *site; -static SCRIPTSTATE state; - static HRESULT WINAPI ObjectSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv) { *ppv = NULL; @@ -1902,6 +1917,22 @@ static void test_func(IDispatchEx *obj) hres = dispex_propput(obj, id, 0, &var, NULL); ok(hres == E_NOTIMPL, "InvokeEx failed: %08x\n", hres); + hres = dispex_propget(dispex, DISPID_VALUE, &var, NULL); + ok(hres == E_ACCESSDENIED, "InvokeEx returned: %08x, expected E_ACCESSDENIED\n", hres); + if(SUCCEEDED(hres)) + VariantClear(&var); + + SET_EXPECT(QS_IActiveScriptSite); + SET_EXPECT(QS_GetCaller); + hres = dispex_propget(dispex, DISPID_VALUE, &var, &caller_sp); + ok(hres == S_OK, "InvokeEx returned: %08x, expected S_OK\n", hres); + ok(V_VT(&var) == VT_BSTR, "V_VT(var) = %d\n", V_VT(&var)); + ok(!strcmp_wa(V_BSTR(&var), "\nfunction toString() {\n [native code]\n}\n"), + "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var))); + VariantClear(&var); + todo_wine CHECK_CALLED(QS_IActiveScriptSite); + todo_wine CHECK_CALLED(QS_GetCaller); + IDispatchEx_Release(dispex); } @@ -2054,12 +2085,19 @@ static void test_default_arg_conv(IHTMLWindow2 *window) test_elem_disabled(elem, VARIANT_TRUE); V_VT(&v) = VT_I4; - V_BSTR(&v) = 0; + V_I4(&v) = 0; hres = dispex_propput(dispex, DISPID_IHTMLELEMENT3_DISABLED, 0, &v, NULL); ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); test_elem_disabled(elem, VARIANT_FALSE); + V_VT(&v) = VT_I4; + V_I4(&v) = 1; + hres = dispex_propput(dispex, DISPID_IHTMLELEMENT3_DISABLED, DISPATCH_PROPERTYPUTREF, &v, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + + test_elem_disabled(elem, VARIANT_TRUE); + IHTMLElement_Release(elem); IDispatchEx_Release(dispex); } diff --git a/rostests/winetests/mshtml/style.c b/rostests/winetests/mshtml/style.c index 3cab20065a9..15644f33e73 100644 --- a/rostests/winetests/mshtml/style.c +++ b/rostests/winetests/mshtml/style.c @@ -59,6 +59,22 @@ static BSTR a2bstr(const char *str) return ret; } +static const WCHAR *strstr_wa(const WCHAR *str, const char *suba) +{ + BSTR sub; + const WCHAR *ret = NULL; + sub = a2bstr(suba); + while (*str) + { + const WCHAR *p1 = str, *p2 = sub; + while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; } + if (!*p2) {ret = str; break;} + str++; + } + SysFreeString(sub); + return ret; +} + #define test_var_bstr(a,b) _test_var_bstr(__LINE__,a,b) static void _test_var_bstr(unsigned line, const VARIANT *v, const char *expect) { @@ -421,6 +437,18 @@ static void test_style2(IHTMLStyle2 *style2) hres = IHTMLStyle2_get_overflowY(style2, &str); ok(hres == S_OK, "get_overflowY failed: %08x\n", hres); ok(!strcmp_wa(str, "hidden"), "overflowX = %s\n", wine_dbgstr_w(str)); + + /* tableLayout */ + str = a2bstr("fixed"); + hres = IHTMLStyle2_put_tableLayout(style2, str); + ok(hres == S_OK, "put_tableLayout failed: %08x\n", hres); + SysFreeString(str); + + str = (void*)0xdeadbeef; + hres = IHTMLStyle2_get_tableLayout(style2, &str); + ok(hres == S_OK, "get_tableLayout failed: %08x\n", hres); + ok(!strcmp_wa(str, "fixed"), "tableLayout = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); } static void test_style3(IHTMLStyle3 *style3) @@ -471,6 +499,57 @@ static void test_style4(IHTMLStyle4 *style4) VariantClear(&vdefault); } +static void test_style5(IHTMLStyle5 *style5) +{ + HRESULT hres; + VARIANT v; + VARIANT vdefault; + + /* minWidth */ + hres = IHTMLStyle5_get_minWidth(style5, &vdefault); + ok(hres == S_OK, "get_minWidth failed: %08x\n", hres); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("12px"); + hres = IHTMLStyle5_put_minWidth(style5, v); + ok(hres == S_OK, "put_minWidth failed: %08x\n", hres); + VariantClear(&v); + + hres = IHTMLStyle5_get_minWidth(style5, &v); + ok(hres == S_OK, "get_minWidth failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "12px"), "expect 12px got (%s)\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("10%"); + hres = IHTMLStyle5_put_minWidth(style5, v); + ok(hres == S_OK, "put_minWidth failed: %08x\n", hres); + VariantClear(&v); + + hres = IHTMLStyle5_get_minWidth(style5, &v); + ok(hres == S_OK, "get_minWidth failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "10%"), "expect 10%% got (%s)\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("10"); + hres = IHTMLStyle5_put_minWidth(style5, v); + ok(hres == S_OK, "put_minWidth failed: %08x\n", hres); + VariantClear(&v); + + hres = IHTMLStyle5_get_minWidth(style5, &v); + ok(hres == S_OK, "get_minWidth failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + hres = IHTMLStyle5_put_minWidth(style5, vdefault); + ok(hres == S_OK, "put_minWidth failed: %08x\n", hres); + VariantClear(&vdefault); +} + static void test_style6(IHTMLStyle6 *style) { BSTR str; @@ -516,6 +595,7 @@ static void test_body_style(IHTMLStyle *style) IHTMLStyle2 *style2; IHTMLStyle3 *style3; IHTMLStyle4 *style4; + IHTMLStyle5 *style5; IHTMLStyle6 *style6; VARIANT_BOOL b; VARIANT v; @@ -742,6 +822,28 @@ static void test_body_style(IHTMLStyle *style) todo_wine ok(!strcmp_wa(V_BSTR(&v), "#00fdfd"), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + V_VT(&v) = VT_I4; + V_I4(&v) = 3; + hres = IHTMLStyle_put_lineHeight(style, v); + ok(hres == S_OK, "put_lineHeight failed: %08x\n", hres); + + hres = IHTMLStyle_get_lineHeight(style, &v); + ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(lineHeight) = %d, expect VT_BSTR\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "3"), "V_BSTR(lineHeight) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("300%"); + hres = IHTMLStyle_put_lineHeight(style, v); + ok(hres == S_OK, "put_lineHeight failed: %08x\n", hres); + VariantClear(&v); + + hres = IHTMLStyle_get_lineHeight(style, &v); + ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(lineHeight) = %d, expect VT_BSTR\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "300%"), "V_BSTR(lineHeight) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + b = 0xfefe; hres = IHTMLStyle_get_textDecorationUnderline(style, &b); ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres); @@ -861,6 +963,11 @@ static void test_body_style(IHTMLStyle *style) f == 2.2f, /* IE8 */ "f = %f\n", f); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelWidth(style, &l); + ok(hres == S_OK, "get_pixelWidth failed: %08x\n", hres); + ok(l == 2, "pixelWidth = %d\n", l); + V_VT(&v) = VT_BSTR; V_BSTR(&v) = a2bstr("auto"); hres = IHTMLStyle_put_width(style, v); @@ -879,6 +986,11 @@ static void test_body_style(IHTMLStyle *style) hres = IHTMLStyle_put_width(style, v); ok(hres == S_OK, "put_width failed: %08x\n", hres); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelWidth(style, &l); + ok(hres == S_OK, "get_pixelWidth failed: %08x\n", hres); + ok(l == 100, "pixelWidth = %d\n", l); + V_VT(&v) = VT_EMPTY; hres = IHTMLStyle_get_width(style, &v); ok(hres == S_OK, "get_width failed: %08x\n", hres); @@ -889,6 +1001,14 @@ static void test_body_style(IHTMLStyle *style) hres = IHTMLStyle_put_pixelWidth(style, 50); ok(hres == S_OK, "put_pixelWidth failed: %08x\n", hres); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelWidth(style, &l); + ok(hres == S_OK, "get_pixelWidth failed: %08x\n", hres); + ok(l == 50, "pixelWidth = %d\n", l); + + hres = IHTMLStyle_get_pixelWidth(style, NULL); + ok(hres == E_POINTER, "get_pixelWidth failed: %08x\n", hres); + V_VT(&v) = VT_EMPTY; hres = IHTMLStyle_get_width(style, &v); ok(hres == S_OK, "get_width failed: %08x\n", hres); @@ -1062,6 +1182,9 @@ static void test_body_style(IHTMLStyle *style) ok(hres == S_OK, "get_pixelLeft failed: %08x\n", hres); ok(l == 6, "pixelLeft = %d\n", l); + hres = IHTMLStyle_get_pixelLeft(style, NULL); + ok(hres == E_POINTER, "get_pixelLeft failed: %08x\n", hres); + V_VT(&v) = VT_EMPTY; hres = IHTMLStyle_get_left(style, &v); ok(hres == S_OK, "get_left failed: %08x\n", hres); @@ -1087,6 +1210,17 @@ static void test_body_style(IHTMLStyle *style) f == 4.9f, /* IE8 */ "expected 4.0 or 4.9 (IE8) got %f\n", f); + hres = IHTMLStyle_put_pixelTop(style, 6); + ok(hres == S_OK, "put_pixelTop failed: %08x\n", hres); + + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelTop(style, &l); + ok(hres == S_OK, "get_pixelTop failed: %08x\n", hres); + ok(l == 6, "pixelTop = %d\n", l); + + hres = IHTMLStyle_get_pixelTop(style, NULL); + ok(hres == E_POINTER, "get_pixelTop failed: %08x\n", hres); + V_VT(&v) = VT_BSTR; V_BSTR(&v) = a2bstr("3px"); hres = IHTMLStyle_put_top(style, v); @@ -1104,6 +1238,11 @@ static void test_body_style(IHTMLStyle *style) ok(hres == S_OK, "get_posTop failed: %08x\n", hres); ok(f == 3.0, "expected 3.0 got %f\n", f); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelTop(style, &l); + ok(hres == S_OK, "get_pixelTop failed: %08x\n", hres); + ok(l == 3, "pixelTop = %d\n", l); + V_VT(&v) = VT_NULL; hres = IHTMLStyle_put_top(style, v); ok(hres == S_OK, "put_top failed: %08x\n", hres); @@ -1115,6 +1254,11 @@ static void test_body_style(IHTMLStyle *style) ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n"); VariantClear(&v); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelTop(style, &l); + ok(hres == S_OK, "get_pixelTop failed: %08x\n", hres); + ok(!l, "pixelTop = %d\n", l); + /* Test posHeight */ hres = IHTMLStyle_get_posHeight(style, NULL); ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres); @@ -1131,6 +1275,11 @@ static void test_body_style(IHTMLStyle *style) ok(hres == S_OK, "get_posHeight failed: %08x\n", hres); ok(f == 0.0, "expected 0.0 got %f\n", f); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelHeight(style, &l); + ok(hres == S_OK, "get_pixelHeight failed: %08x\n", hres); + ok(!l, "pixelHeight = %d\n", l); + hres = IHTMLStyle_put_posHeight(style, 4.9f); ok(hres == S_OK, "put_posHeight failed: %08x\n", hres); @@ -1140,6 +1289,13 @@ static void test_body_style(IHTMLStyle *style) f == 4.9f, /* IE8 */ "expected 4.0 or 4.9 (IE8) got %f\n", f); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelHeight(style, &l); + ok(hres == S_OK, "get_pixelHeight failed: %08x\n", hres); + ok(l == 4 || + l == 5, /* IE8 */ + "pixelHeight = %d\n", l); + V_VT(&v) = VT_BSTR; V_BSTR(&v) = a2bstr("70px"); hres = IHTMLStyle_put_height(style, v); @@ -1153,6 +1309,11 @@ static void test_body_style(IHTMLStyle *style) ok(!strcmp_wa(V_BSTR(&v), "70px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelHeight(style, &l); + ok(hres == S_OK, "get_pixelHeight failed: %08x\n", hres); + ok(l == 70, "pixelHeight = %d\n", l); + V_VT(&v) = VT_BSTR; V_BSTR(&v) = NULL; hres = IHTMLStyle_put_height(style, v); @@ -1166,6 +1327,22 @@ static void test_body_style(IHTMLStyle *style) ok(!V_BSTR(&v), "V_BSTR(v) = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelHeight(style, &l); + ok(hres == S_OK, "get_pixelHeight failed: %08x\n", hres); + ok(!l, "pixelHeight = %d\n", l); + + hres = IHTMLStyle_put_pixelHeight(style, 50); + ok(hres == S_OK, "put_pixelHeight failed: %08x\n", hres); + + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelHeight(style, &l); + ok(hres == S_OK, "get_pixelHeight failed: %08x\n", hres); + ok(l == 50, "pixelHeight = %d\n", l); + + hres = IHTMLStyle_get_pixelHeight(style, NULL); + ok(hres == E_POINTER, "get_pixelHeight failed: %08x\n", hres); + V_VT(&v) = VT_I4; V_I4(&v) = 64; hres = IHTMLStyle_put_height(style, v); @@ -1182,6 +1359,11 @@ static void test_body_style(IHTMLStyle *style) ok(hres == S_OK, "get_posHeight failed: %08x\n", hres); ok(f == 64.0, "expected 64.0 got %f\n", f); + l = 0xdeadbeef; + hres = IHTMLStyle_get_pixelHeight(style, &l); + ok(hres == S_OK, "get_pixelHeight failed: %08x\n", hres); + ok(l == 64, "pixelHeight = %d\n", l); + str = (void*)0xdeadbeef; hres = IHTMLStyle_get_cursor(style, &str); ok(hres == S_OK, "get_cursor failed: %08x\n", hres); @@ -1248,6 +1430,39 @@ static void test_body_style(IHTMLStyle *style) ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v))); SysFreeString(str); + V_VT(&v) = VT_NULL; + hres = IHTMLStyle_get_textIndent(style, &v); + ok(hres == S_OK, "get_textIndent failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(textIndent) = %d\n", V_VT(&v)); + ok(!V_BSTR(&v), "V_BSTR(textIndent) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + + V_VT(&v) = VT_I4; + V_I4(&v) = 6; + hres = IHTMLStyle_put_textIndent(style, v); + ok(hres == S_OK, "put_textIndent failed: %08x\n", hres); + + V_VT(&v) = VT_NULL; + hres = IHTMLStyle_get_textIndent(style, &v); + ok(hres == S_OK, "get_textIndent failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(textIndent) = %d\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(textIndent) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + + str = (void*)0xdeadbeef; + hres = IHTMLStyle_get_textTransform(style, &str); + ok(hres == S_OK, "get_textTransform failed: %08x\n", hres); + ok(!str, "textTransform != NULL\n"); + + str = a2bstr("lowercase"); + hres = IHTMLStyle_put_textTransform(style, str); + ok(hres == S_OK, "put_textTransform failed: %08x\n", hres); + SysFreeString(str); + + str = NULL; + hres = IHTMLStyle_get_textTransform(style, &str); + ok(hres == S_OK, "get_textTransform failed: %08x\n", hres); + ok(!strcmp_wa(str, "lowercase"), "textTransform = %s\n", wine_dbgstr_w(V_BSTR(&v))); + SysFreeString(str); + str = (void*)0xdeadbeef; hres = IHTMLStyle_get_filter(style, &str); ok(hres == S_OK, "get_filter failed: %08x\n", hres); @@ -1478,6 +1693,16 @@ static void test_body_style(IHTMLStyle *style) ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + str = a2bstr("fixed"); + hres = IHTMLStyle_put_backgroundAttachment(style, str); + ok(hres == S_OK, "put_backgroundAttachment failed: %08x\n", hres); + SysFreeString(str); + + hres = IHTMLStyle_get_backgroundAttachment(style, &str); + ok(hres == S_OK, "get_backgroundAttachment failed: %08x\n", hres); + ok(!strcmp_wa(str, "fixed"), "ret = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + /* padding */ hres = IHTMLStyle_get_padding(style, &str); ok(hres == S_OK, "get_padding failed: %08x\n", hres); @@ -2106,8 +2331,35 @@ static void test_body_style(IHTMLStyle *style) hres = IHTMLStyle_get_listStyleType(style, &str); ok(hres == S_OK, "get_listStyleType failed: %08x\n", hres); ok(!strcmp_wa(str, "square"), "listStyleType = %s\n", wine_dbgstr_w(str)); + + str = a2bstr("inside"); + hres = IHTMLStyle_put_listStylePosition(style, str); + ok(hres == S_OK, "put_listStylePosition failed: %08x\n", hres); SysFreeString(str); + hres = IHTMLStyle_get_listStylePosition(style, &str); + ok(hres == S_OK, "get_listStylePosition failed: %08x\n", hres); + ok(!strcmp_wa(str, "inside"), "listStyleType = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = a2bstr("decimal-leading-zero none inside"); + hres = IHTMLStyle_put_listStyle(style, str); + ok(hres == S_OK || broken(hres == E_INVALIDARG), /* win 2000 */ + "put_listStyle(%s) failed: %08x\n", wine_dbgstr_w(str), hres); + SysFreeString(str); + + if (hres != E_INVALIDARG) { + hres = IHTMLStyle_get_listStyle(style, &str); + ok(hres == S_OK, "get_listStyle failed: %08x\n", hres); + ok(strstr_wa(str, "decimal-leading-zero") && + strstr_wa(str, "none") != NULL && + strstr_wa(str, "inside") != NULL, + "listStyle = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + } else { + win_skip("IHTMLStyle_put_listStyle already failed\n"); + } + hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2); ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres); if(SUCCEEDED(hres)) { @@ -2129,6 +2381,14 @@ static void test_body_style(IHTMLStyle *style) IHTMLStyle4_Release(style4); } + hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle5, (void**)&style5); + if(SUCCEEDED(hres)) { + test_style5(style5); + IHTMLStyle5_Release(style5); + }else { + win_skip("IHTMLStyle5 not available\n"); + } + hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle6, (void**)&style6); if(SUCCEEDED(hres)) { test_style6(style6); @@ -2490,6 +2750,10 @@ static void test_current_style(IHTMLCurrentStyle *current_style) ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); VariantClear(&v); + hres = IHTMLCurrentStyle_get_textTransform(current_style, &str); + ok(hres == S_OK, "get_textTransform failed: %08x\n", hres); + SysFreeString(str); + current_style2 = get_current_style2_iface((IUnknown*)current_style); b = 100; diff --git a/rostests/winetests/mshtml/vbtest.html b/rostests/winetests/mshtml/vbtest.html index c965f424261..382442ad6ac 100644 --- a/rostests/winetests/mshtml/vbtest.html +++ b/rostests/winetests/mshtml/vbtest.html @@ -24,7 +24,7 @@ try { counter++; incCounter(2); }catch(e) { - ok(false, "got an exception"); + ok(false, "got an exception " + e.message); }