Jacek Caban : mshtml: Added open and close implementation.
Alexandre Julliard
julliard at winehq.org
Mon Oct 13 06:37:40 CDT 2008
Module: wine
Branch: master
Commit: 50393191a133be8fd9015556b1617458bcd41bc9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=50393191a133be8fd9015556b1617458bcd41bc9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Oct 10 15:48:46 2008 -0500
mshtml: Added open and close implementation.
---
dlls/mshtml/htmldoc.c | 45 +++++++++++++++++++++++++++---
dlls/mshtml/tests/dom.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 4e8f063..7637c29 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -815,15 +815,52 @@ static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT
VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
{
HTMLDocument *This = HTMLDOC_THIS(iface);
- FIXME("(%p)->(%s %p)\n", This, debugstr_w(url), pomWindowResult);
- return E_NOTIMPL;
+ nsresult nsres;
+
+ static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
+
+ TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
+ debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
+
+ if(!This->nsdoc) {
+ ERR("!nsdoc\n");
+ return E_NOTIMPL;
+ }
+
+ if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
+ || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
+ FIXME("unsupported args\n");
+
+ nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
+ if(NS_FAILED(nsres)) {
+ ERR("Open failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
+ IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
+ return S_OK;
}
static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
{
HTMLDocument *This = HTMLDOC_THIS(iface);
- FIXME("(%p)\n", This);
- return E_NOTIMPL;
+ nsresult nsres;
+
+ TRACE("(%p)\n", This);
+
+ if(!This->nsdoc) {
+ ERR("!nsdoc\n");
+ return E_NOTIMPL;
+ }
+
+ nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
+ if(NS_FAILED(nsres)) {
+ ERR("Close failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ return S_OK;
}
static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 2f91a1c..87d372d 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -387,6 +387,21 @@ static BSTR a2bstr(const char *str)
return ret;
}
+static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
+{
+ IUnknown *unk1, *unk2;
+
+ if(iface1 == iface2)
+ return TRUE;
+
+ IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
+ IUnknown_Release(unk1);
+ IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk2);
+ IUnknown_Release(unk2);
+
+ return unk1 == unk2;
+}
+
static IHTMLDocument2 *create_document(void)
{
IHTMLDocument2 *doc;
@@ -2630,13 +2645,48 @@ static void test_table_elem(IHTMLElement *elem)
IHTMLTable_Release(table);
}
+static void doc_write(IHTMLDocument2 *doc, const char *text)
+{
+ SAFEARRAYBOUND dim;
+ SAFEARRAY *sa;
+ VARIANT *var;
+ BSTR str;
+ HRESULT hres;
+
+ dim.lLbound = 0;
+ dim.cElements = 1;
+ sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
+ SafeArrayAccessData(sa, (void**)&var);
+ V_VT(var) = VT_BSTR;
+ V_BSTR(var) = str = a2bstr(text);
+ SafeArrayUnaccessData(sa);
+
+ hres = IHTMLDocument2_write(doc, sa);
+ ok(hres == S_OK, "write failed: %08x\n", hres);
+
+ SysFreeString(str);
+ SafeArrayDestroy(sa);
+}
+
static void test_iframe_elem(IHTMLElement *elem)
{
+ IHTMLElementCollection *col;
IHTMLDocument2 *content_doc;
IHTMLWindow2 *content_window;
IHTMLFrameBase2 *base2;
+ IDispatch *disp;
+ VARIANT errv;
+ BSTR str;
HRESULT hres;
+ static const elem_type_t all_types[] = {
+ ET_HTML,
+ ET_HEAD,
+ ET_TITLE,
+ ET_BODY,
+ ET_BR
+ };
+
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
@@ -2652,6 +2702,26 @@ static void test_iframe_elem(IHTMLElement *elem)
ok(hres == S_OK, "get_document failed: %08x\n", hres);
ok(content_doc != NULL, "content_doc = NULL\n");
+ str = a2bstr("text/html");
+ V_VT(&errv) = VT_ERROR;
+ disp = NULL;
+ hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
+ SysFreeString(str);
+ ok(hres == S_OK, "open failed: %08x\n", hres);
+ ok(disp != NULL, "disp == NULL\n");
+ ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
+ IDispatch_Release(disp);
+
+ doc_write(content_doc, "<html><head><title>test</title></head><body><br /></body></html>");
+
+ hres = IHTMLDocument2_get_all(content_doc, &col);
+ ok(hres == S_OK, "get_all failed: %08x\n", hres);
+ test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
+ IHTMLElementCollection_Release(col);
+
+ hres = IHTMLDocument2_close(content_doc);
+ ok(hres == S_OK, "close failed: %08x\n", hres);
+
IHTMLDocument2_Release(content_doc);
}
More information about the wine-cvs
mailing list