diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index a2494dfb0fb..e0c06194b97 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -228,15 +228,41 @@ static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, long *p)
static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
{
HTMLImgElement *This = HTMLIMG_THIS(iface);
- FIXME("(%p)->(%s)\n", This, debugstr_w(v));
- return E_NOTIMPL;
+ nsAString alt_str;
+ nsresult nsres;
+
+ TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+ nsAString_Init(&alt_str, v);
+ nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
+ nsAString_Finish(&alt_str);
+ if(NS_FAILED(nsres))
+ ERR("SetAlt failed: %08x\n", nsres);
+
+ return S_OK;
}
static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
{
HTMLImgElement *This = HTMLIMG_THIS(iface);
- FIXME("(%p)->(%p)\n", This, p);
- return E_NOTIMPL;
+ nsAString alt_str;
+ nsresult nsres;
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ nsAString_Init(&alt_str, NULL);
+ nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
+ if(NS_SUCCEEDED(nsres)) {
+ const PRUnichar *alt;
+
+ nsAString_GetData(&alt_str, &alt);
+ *p = *alt ? SysAllocString(alt) : NULL;
+ }else {
+ ERR("GetAlt failed: %08x\n", nsres);
+ }
+ nsAString_Finish(&alt_str);
+
+ return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
}
static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 92a240ecf64..dd2d30335af 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -411,6 +411,17 @@ static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
return node;
}
+#define get_img_iface(u) _get_img_iface(__LINE__,u)
+static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
+{
+ IHTMLImgElement *img;
+ HRESULT hres;
+
+ hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
+ ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
+ return img;
+}
+
#define test_node_name(u,n) _test_node_name(__LINE__,u,n)
static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
{
@@ -932,13 +943,10 @@ static long _get_node_type(unsigned line, IUnknown *unk)
#define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
{
- IHTMLImgElement *img;
+ IHTMLImgElement *img = _get_img_iface(line, unk);
BSTR tmp;
HRESULT hres;
- hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
- ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
-
tmp = a2bstr(src);
hres = IHTMLImgElement_put_src(img, tmp);
IHTMLImgElement_Release(img);
@@ -946,6 +954,37 @@ static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
}
+#define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
+static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
+{
+ IHTMLImgElement *img = _get_img_iface(line, unk);
+ BSTR alt;
+ HRESULT hres;
+
+ hres = IHTMLImgElement_get_alt(img, &alt);
+ ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
+ if(exalt)
+ ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", dbgstr_w(alt));
+ else
+ ok_(__FILE__,line) (!alt, "alt != NULL\n");
+ SysFreeString(alt);
+}
+
+#define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
+static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
+{
+ IHTMLImgElement *img = _get_img_iface(line, unk);
+ BSTR tmp;
+ HRESULT hres;
+
+ tmp = a2bstr(alt);
+ hres = IHTMLImgElement_put_alt(img, tmp);
+ ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
+ SysFreeString(tmp);
+
+ _test_img_alt(line, unk, alt);
+}
+
#define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
{
@@ -2167,6 +2206,8 @@ static void test_elems(IHTMLDocument2 *doc)
elem = get_elem_by_id(doc, imgidW, TRUE);
if(elem) {
test_img_set_src((IUnknown*)elem, "about:blank");
+ test_img_alt((IUnknown*)elem, NULL);
+ test_img_set_alt((IUnknown*)elem, "alt test");
IHTMLElement_Release(elem);
}