From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- include/mshtml.idl | 67 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-)
diff --git a/include/mshtml.idl b/include/mshtml.idl index afeb44213d2..1540633efef 100644 --- a/include/mshtml.idl +++ b/include/mshtml.idl @@ -8142,10 +8142,6 @@ interface IHTMLDOMNode2 : IDispatch [propget, id(DISPID_IHTMLDOMNODE2_OWNERDOCUMENT)] \ IDispatch *ownerDocument()
-#define WINE_HTMLDOMNODE_DISPINTERFACE_DECL \ - WINE_IHTMLDOMNODE_DISPINTERFACE_DECL; \ - WINE_IHTMLDOMNODE2_DISPINTERFACE_DECL - /***************************************************************************** * IHTMLDOMNode3 interface */ @@ -8234,6 +8230,69 @@ interface IHTMLDOMNode3 : IDispatch [out, retval] VARIANT_BOOL *pfisSupported); }
+#define WINE_IHTMLDOMNODE3_DISPINTERFACE_DECL \ + [propput, id(DISPID_IHTMLDOMNODE3_PREFIX)] \ + void prefix(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLDOMNODE3_PREFIX)] \ + VARIANT prefix(); \ + \ + [propget, id(DISPID_IHTMLDOMNODE3_LOCALNAME)] \ + VARIANT localName(); \ + \ + [propget, id(DISPID_IHTMLDOMNODE3_NAMESPACEURI)] \ + VARIANT namespaceURI(); \ + \ + [propput, id(DISPID_IHTMLDOMNODE3_TEXTCONTENT)] \ + void textContent(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLDOMNODE3_TEXTCONTENT)] \ + VARIANT textContent(); \ + \ + [id(DISPID_IHTMLDOMNODE3_ISEQUALNODE)] \ + VARIANT_BOOL isEqualNode([in] IHTMLDOMNode3 *otherNode); \ + \ + [id(DISPID_IHTMLDOMNODE3_LOOKUPNAMESPACEURI)] \ + VARIANT lookupNamespaceURI([in] VARIANT *pvarPrefix); \ + \ + [id(DISPID_IHTMLDOMNODE3_LOOKUPPREFIX)] \ + VARIANT lookupPrefix([in] VARIANT *pvarNamespaceURI); \ + \ + [id(DISPID_IHTMLDOMNODE3_ISDEFAULTNAMESPACE)] \ + VARIANT_BOOL isDefaultNamespace([in] VARIANT *pvarNamespace); \ + \ + [id(DISPID_IHTMLDOMNODE3_IE9_APPENDCHILD)] \ + IHTMLDOMNode *ie9_appendChild([in] IHTMLDOMNode *newChild); \ + \ + [id(DISPID_IHTMLDOMNODE3_IE9_INSERTBEFORE)] \ + IHTMLDOMNode *ie9_insertBefore( \ + [in] IHTMLDOMNode *newChild, \ + [in, optional] VARIANT refChild); \ + \ + [id(DISPID_IHTMLDOMNODE3_IE9_REMOVECHILD)] \ + IHTMLDOMNode *ie9_removeChild([in] IHTMLDOMNode *oldChild); \ + \ + [id(DISPID_IHTMLDOMNODE3_IE9_REPLACECHILD)] \ + IHTMLDOMNode *ie9_replaceChild( \ + [in] IHTMLDOMNode *newChild, \ + [in] IHTMLDOMNode *oldChild); \ + \ + [id(DISPID_IHTMLDOMNODE3_ISSAMENODE)] \ + VARIANT_BOOL isSameNode([in] IHTMLDOMNode3 *otherNode); \ + \ + [id(DISPID_IHTMLDOMNODE3_COMPAREDOCUMENTPOSITION)] \ + USHORT compareDocumentPosition([in] IHTMLDOMNode *otherNode); \ + \ + [id(DISPID_IHTMLDOMNODE3_ISSUPPORTED)] \ + VARIANT_BOOL isSupported( \ + [in] BSTR feature, \ + [in] VARIANT version) \ + +#define WINE_HTMLDOMNODE_DISPINTERFACE_DECL \ + WINE_IHTMLDOMNODE_DISPINTERFACE_DECL; \ + WINE_IHTMLDOMNODE2_DISPINTERFACE_DECL; \ + WINE_IHTMLDOMNODE3_DISPINTERFACE_DECL + /***************************************************************************** * IHTMLDOMAttribute interface */
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- include/mshtml.idl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
diff --git a/include/mshtml.idl b/include/mshtml.idl index 1540633efef..6caa0c8ee5a 100644 --- a/include/mshtml.idl +++ b/include/mshtml.idl @@ -8497,6 +8497,51 @@ interface IDOMDocumentType : IDispatch HRESULT internalSubset([out, retval] VARIANT *p); }
+/***************************************************************************** + * DispDOMDocumentType dispinterface + */ +[ + hidden, + uuid(30590098-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispDOMDocumentType +{ +properties: +methods: + WINE_HTMLDOMNODE_DISPINTERFACE_DECL; + + [propget, id(DISPID_IDOMDOCUMENTTYPE_NAME)] + BSTR name(); + + [propget, id(DISPID_IDOMDOCUMENTTYPE_ENTITIES)] + IDispatch *entities(); + + [propget, id(DISPID_IDOMDOCUMENTTYPE_NOTATIONS)] + IDispatch *notations(); + + [propget, id(DISPID_IDOMDOCUMENTTYPE_PUBLICID)] + VARIANT publicId(); + + [propget, id(DISPID_IDOMDOCUMENTTYPE_SYSTEMID)] + VARIANT systemId(); + + [propget, id(DISPID_IDOMDOCUMENTTYPE_INTERNALSUBSET)] + VARIANT internalSubset(); +}; + +[ + noncreatable, + uuid(30510739-98b5-11cf-bb82-00aa00bdce0b) +] +coclass DOMDocumentType +{ + [default] dispinterface DispDOMDocumentType; + interface IHTMLDOMNode; + interface IHTMLDOMNode2; + interface IHTMLDOMNode3; + interface IDOMDocumentType; +}; + /***************************************************************************** * IHTMLDOMImplementation interface */
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 290 +++++++++++++++++++++++++++++- dlls/mshtml/htmlnode.c | 9 +- dlls/mshtml/mshtml_private.h | 3 + dlls/mshtml/tests/documentmode.js | 10 ++ 4 files changed, 309 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 3a742a86a1b..fb30b9d8405 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -146,6 +146,267 @@ UINT get_document_charset(HTMLDocumentNode *doc) return doc->charset = ret; }
+typedef struct { + HTMLDOMNode node; + IDOMDocumentType IDOMDocumentType_iface; +} DocumentType; + +static inline DocumentType *impl_from_IDOMDocumentType(IDOMDocumentType *iface) +{ + return CONTAINING_RECORD(iface, DocumentType, IDOMDocumentType_iface); +} + +static HRESULT WINAPI DocumentType_QueryInterface(IDOMDocumentType *iface, REFIID riid, void **ppv) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv); +} + +static ULONG WINAPI DocumentType_AddRef(IDOMDocumentType *iface) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface); +} + +static ULONG WINAPI DocumentType_Release(IDOMDocumentType *iface) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface); +} + +static HRESULT WINAPI DocumentType_GetTypeInfoCount(IDOMDocumentType *iface, UINT *pctinfo) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo); +} + +static HRESULT WINAPI DocumentType_GetTypeInfo(IDOMDocumentType *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI DocumentType_GetIDsOfNames(IDOMDocumentType *iface, REFIID riid, LPOLESTR *rgszNames, + UINT cNames, LCID lcid, DISPID *rgDispId) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, + cNames, lcid, rgDispId); +} + +static HRESULT WINAPI DocumentType_Invoke(IDOMDocumentType *iface, DISPID dispIdMember, REFIID riid, LCID lcid, + WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, + wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI DocumentType_get_name(IDOMDocumentType *iface, BSTR *p) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI DocumentType_get_entities(IDOMDocumentType *iface, IDispatch **p) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI DocumentType_get_notations(IDOMDocumentType *iface, IDispatch **p) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI DocumentType_get_publicId(IDOMDocumentType *iface, VARIANT *p) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI DocumentType_get_systemId(IDOMDocumentType *iface, VARIANT *p) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI DocumentType_get_internalSubset(IDOMDocumentType *iface, VARIANT *p) +{ + DocumentType *This = impl_from_IDOMDocumentType(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static const IDOMDocumentTypeVtbl DocumentTypeVtbl = { + DocumentType_QueryInterface, + DocumentType_AddRef, + DocumentType_Release, + DocumentType_GetTypeInfoCount, + DocumentType_GetTypeInfo, + DocumentType_GetIDsOfNames, + DocumentType_Invoke, + DocumentType_get_name, + DocumentType_get_entities, + DocumentType_get_notations, + DocumentType_get_publicId, + DocumentType_get_systemId, + DocumentType_get_internalSubset +}; + +static inline DocumentType *DocumentType_from_HTMLDOMNode(HTMLDOMNode *iface) +{ + return CONTAINING_RECORD(iface, DocumentType, node); +} + +static inline DocumentType *DocumentType_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, DocumentType, node.event_target.dispex); +} + +static HRESULT DocumentType_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + DocumentType *This = DocumentType_from_HTMLDOMNode(iface); + + if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDOMDocumentType, riid)) + *ppv = &This->IDOMDocumentType_iface; + else + return HTMLDOMNode_QI(&This->node, riid, ppv); + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static void DocumentType_destructor(HTMLDOMNode *iface) +{ + DocumentType *This = DocumentType_from_HTMLDOMNode(iface); + + HTMLDOMNode_destructor(&This->node); +} + +static HRESULT DocumentType_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + DocumentType *This = DocumentType_from_HTMLDOMNode(iface); + + return create_doctype_node(This->node.doc, nsnode, ret); +} + +static const cpc_entry_t DocumentType_cpc[] = {{NULL}}; + +static const NodeImplVtbl DocumentTypeImplVtbl = { + NULL, + DocumentType_QI, + DocumentType_destructor, + DocumentType_cpc, + DocumentType_clone +}; + +static nsISupports *DocumentType_get_gecko_target(DispatchEx *dispex) +{ + DocumentType *This = DocumentType_from_DispatchEx(dispex); + return (nsISupports*)This->node.nsnode; +} + +static EventTarget *DocumentType_get_parent_event_target(DispatchEx *dispex) +{ + DocumentType *This = DocumentType_from_DispatchEx(dispex); + nsIDOMNode *nsnode; + HTMLDOMNode *node; + nsresult nsres; + HRESULT hres; + + nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsnode); + assert(nsres == NS_OK); + if(!nsnode) + return NULL; + + hres = get_node(nsnode, TRUE, &node); + nsIDOMNode_Release(nsnode); + if(FAILED(hres)) + return NULL; + + return &node->event_target; +} + +static IHTMLEventObj *DocumentType_set_current_event(DispatchEx *dispex, IHTMLEventObj *event) +{ + DocumentType *This = DocumentType_from_DispatchEx(dispex); + return default_set_current_event(This->node.doc->window, event); +} + +static event_target_vtbl_t DocumentType_event_target_vtbl = { + { + NULL, + }, + DocumentType_get_gecko_target, + NULL, + DocumentType_get_parent_event_target, + NULL, + NULL, + DocumentType_set_current_event +}; + +static const tid_t DocumentType_iface_tids[] = { + IDOMDocumentType_tid, + IHTMLDOMNode_tid, + IHTMLDOMNode2_tid, + IHTMLDOMNode3_tid, + 0 +}; + +static dispex_static_data_t DocumentType_dispex = { + L"DocumentType", + &DocumentType_event_target_vtbl.dispex_vtbl, + DispDOMDocumentType_tid, + DocumentType_iface_tids +}; + +HRESULT create_doctype_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + nsIDOMDocumentType *nsdoctype; + DocumentType *doctype; + nsresult nsres; + + if(!(doctype = heap_alloc_zero(sizeof(*doctype)))) + return E_OUTOFMEMORY; + + nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocumentType, (void**)&nsdoctype); + assert(nsres == NS_OK); + + doctype->node.vtbl = &DocumentTypeImplVtbl; + doctype->IDOMDocumentType_iface.lpVtbl = &DocumentTypeVtbl; + HTMLDOMNode_Init(doc, &doctype->node, (nsIDOMNode*)nsdoctype, &DocumentType_dispex); + nsIDOMDocumentType_Release(nsdoctype); + + *ret = &doctype->node; + return S_OK; +} + static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface) { return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface); @@ -2818,8 +3079,33 @@ static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARI static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p) { HTMLDocument *This = impl_from_IHTMLDocument5(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + HTMLDocumentNode *doc_node = This->doc_node; + nsIDOMDocumentType *nsdoctype; + HTMLDOMNode *doctype_node; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + if(dispex_compat_mode(&doc_node->node.event_target.dispex) < COMPAT_MODE_IE9) { + *p = NULL; + return S_OK; + } + + nsres = nsIDOMHTMLDocument_GetDoctype(doc_node->nsdoc, &nsdoctype); + if(NS_FAILED(nsres)) + return map_nsresult(nsres); + if(!nsdoctype) { + *p = NULL; + return S_OK; + } + + hres = get_node((nsIDOMNode*)nsdoctype, TRUE, &doctype_node); + nsIDOMDocumentType_Release(nsdoctype); + + if(SUCCEEDED(hres)) + *p = &doctype_node->IHTMLDOMNode_iface; + return hres; }
static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p) diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index 13f178fc33b..e10af6c1436 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -1506,8 +1506,15 @@ static HRESULT create_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNod if(FAILED(hres)) return hres; break; - /* doctype nodes are represented as comment nodes (at least in quirks mode) */ case DOCUMENT_TYPE_NODE: + if(dispex_compat_mode(&doc->node.event_target.dispex) >= COMPAT_MODE_IE9) { + hres = create_doctype_node(doc, nsnode, ret); + if(FAILED(hres)) + return hres; + break; + } + /* doctype nodes are represented as comment nodes in quirks mode */ + /* fall through */ case COMMENT_NODE: { HTMLElement *comment; hres = HTMLCommentElement_Create(doc, nsnode, &comment); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 2e30210db2e..0946c9d2ee4 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -91,6 +91,7 @@ typedef struct EventTarget EventTarget; XDIID(DispDOMMouseEvent) \ XDIID(DispDOMProgressEvent) \ XDIID(DispDOMUIEvent) \ + XDIID(DispDOMDocumentType) \ XDIID(DispHTMLAnchorElement) \ XDIID(DispHTMLAreaElement) \ XDIID(DispHTMLAttributeCollection) \ @@ -153,6 +154,7 @@ typedef struct EventTarget EventTarget; XIID(IDOMMouseEvent) \ XIID(IDOMProgressEvent) \ XIID(IDOMUIEvent) \ + XIID(IDOMDocumentType) \ XIID(IDocumentEvent) \ XIID(IDocumentRange) \ XIID(IDocumentSelector) \ @@ -929,6 +931,7 @@ HRESULT MHTMLDocument_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN; HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN; HRESULT create_document_node(nsIDOMHTMLDocument*,GeckoBrowser*,HTMLInnerWindow*, compat_mode_t,HTMLDocumentNode**) DECLSPEC_HIDDEN; +HRESULT create_doctype_node(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**) DECLSPEC_HIDDEN;
HRESULT create_outer_window(GeckoBrowser*,mozIDOMWindowProxy*,HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN; HRESULT update_window_doc(HTMLInnerWindow*) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 52b433f1577..c1e5e96125d 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -242,6 +242,7 @@ sync_test("builtin_toString", function() { } if(v >= 9) { test("computedStyle", window.getComputedStyle(e), "CSSStyleDeclaration"); + test("doctype", document.doctype, "DocumentType");
test("Event", document.createEvent("Event"), "Event"); test("CustomEvent", document.createEvent("CustomEvent"), "CustomEvent"); @@ -662,6 +663,15 @@ sync_test("doc_mode", function() { ok(document.compatMode === "BackCompat", "document.compatMode = " + document.compatMode); });
+sync_test("doctype", function() { + var doctype = document.doctype; + + if(document.documentMode < 9) { + ok(doctype === null, "doctype = " + document.doctype); + return; + } +}); + async_test("iframe_doc_mode", function() { var iframe = document.createElement("iframe");
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 8 ++++++-- dlls/mshtml/tests/documentmode.js | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index fb30b9d8405..9092186bcf6 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -212,10 +212,14 @@ static HRESULT WINAPI DocumentType_Invoke(IDOMDocumentType *iface, DISPID dispId static HRESULT WINAPI DocumentType_get_name(IDOMDocumentType *iface, BSTR *p) { DocumentType *This = impl_from_IDOMDocumentType(iface); + nsAString nsstr; + nsresult nsres;
- FIXME("(%p)->(%p)\n", This, p); + TRACE("(%p)->(%p)\n", This, p);
- return E_NOTIMPL; + nsAString_Init(&nsstr, NULL); + nsres = nsIDOMDocumentType_GetName((nsIDOMDocumentType*)This->node.nsnode, &nsstr); + return return_nsstr(nsres, &nsstr, p); }
static HRESULT WINAPI DocumentType_get_entities(IDOMDocumentType *iface, IDispatch **p) diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index c1e5e96125d..b9aea679258 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -670,6 +670,8 @@ sync_test("doctype", function() { ok(doctype === null, "doctype = " + document.doctype); return; } + + ok(doctype.name === "html", "doctype.name = " + doctype.name); });
async_test("iframe_doc_mode", function() {
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Instead of crashing when window == NULL.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 28 ++++++++++++++++++--- dlls/mshtml/tests/dom.c | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 9092186bcf6..0b11c0ba83b 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -877,7 +877,10 @@ static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSel
TRACE("(%p)->(%p)\n", This, p);
- nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection); + if(This->window) + nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection); + else + nsres = nsIDOMHTMLDocument_GetSelection(This->doc_node->nsdoc, &nsselection); if(NS_FAILED(nsres)) { ERR("GetSelection failed: %08lx\n", nsres); return E_FAIL; @@ -896,7 +899,7 @@ static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p if(!p) return E_POINTER;
- return get_readystate_string(This->window->readystate, p); + return get_readystate_string(This->window ? This->window->readystate : 0, p); }
static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p) @@ -905,6 +908,10 @@ static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFrames
TRACE("(%p)->(%p)\n", This, p);
+ if(!This->window) { + /* Not implemented by IE */ + return E_NOTIMPL; + } return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p); }
@@ -1087,7 +1094,7 @@ static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", iface, p);
- *p = SysAllocString(This->window->url ? This->window->url : L"about:blank"); + *p = SysAllocString(This->window && This->window->url ? This->window->url : L"about:blank"); return *p ? S_OK : E_OUTOFMEMORY; }
@@ -1143,6 +1150,9 @@ static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+ if(!This->window) + return S_OK; + bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0); if(!bret) { FIXME("InternetSetCookieExW failed: %lu\n", GetLastError()); @@ -1160,6 +1170,11 @@ static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", This, p);
+ if(!This->window) { + *p = NULL; + return S_OK; + } + size = 0; bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL); if(!bret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { @@ -1380,6 +1395,11 @@ static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name), debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
+ *pomWindowResult = NULL; + + if(!This->window) + return E_FAIL; + if(!This->doc_node->nsdoc) { ERR("!nsdoc\n"); return E_NOTIMPL; @@ -2263,7 +2283,7 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I
TRACE("(%p)->(%p)\n", This, p);
- if(This->window->readystate == READYSTATE_UNINITIALIZED) { + if(This->window && This->window->readystate == READYSTATE_UNINITIALIZED) { *p = NULL; return S_OK; } diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index d25c7ac0df8..e3ac177205c 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -7322,10 +7322,14 @@ static void test_dom_implementation(IHTMLDocument2 *doc) hres = IHTMLDOMImplementation_QueryInterface(dom_implementation, &IID_IHTMLDOMImplementation2, (void**)&dom_implementation2); if(SUCCEEDED(hres)) { + IHTMLSelectionObject *selection; + IHTMLFramesCollection2 *frames; IHTMLDocument2 *new_document2; + IHTMLDocument3 *new_document3; IHTMLDocument7 *new_document; IHTMLLocation *location; IHTMLWindow2 *window; + IHTMLElement *elem; VARIANT v; IDispatch *disp;
@@ -7334,6 +7338,7 @@ static void test_dom_implementation(IHTMLDocument2 *doc) str = SysAllocString(L"test"); hres = IHTMLDOMImplementation2_createHTMLDocument(dom_implementation2, str, &new_document); ok(hres == S_OK, "createHTMLDocument failed: %08lx\n", hres); + SysFreeString(str);
test_disp((IUnknown*)new_document, &DIID_DispHTMLDocument, &CLSID_HTMLDocument, L"[object]"); test_ifaces((IUnknown*)new_document, doc_node_iids); @@ -7349,15 +7354,63 @@ static void test_dom_implementation(IHTMLDocument2 *doc) hres = IHTMLDocument7_QueryInterface(new_document, &IID_IHTMLDocument2, (void**)&new_document2); ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08lx\n", hres);
+ hres = IHTMLDocument7_QueryInterface(new_document, &IID_IHTMLDocument3, (void**)&new_document3); + ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08lx\n", hres); + hres = IHTMLDocument2_get_parentWindow(new_document2, &window); ok(hres == E_FAIL, "get_parentWindow returned: %08lx\n", hres);
+ hres = IHTMLDocument2_get_readyState(new_document2, &str); + ok(hres == S_OK, "get_readyState returned: %08lx\n", hres); + ok(!lstrcmpW(str, L"uninitialized"), "readyState = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + hres = IHTMLDocument2_get_Script(new_document2, &disp); ok(hres == E_PENDING, "get_Script returned: %08lx\n", hres);
+ str = SysAllocString(L"test=testval"); + hres = IHTMLDocument2_put_cookie(new_document2, str); + ok(hres == S_OK, "put_cookie returned: %08lx\n", hres); + SysFreeString(str); + + hres = IHTMLDocument2_get_cookie(doc, &str); + ok(hres == S_OK, "get_cookie returned: %08lx\n", hres); + ok(str == NULL, "cookie = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + hres = IHTMLDocument3_get_documentElement(new_document3, &elem); + ok(hres == S_OK, "get_documentElement returned: %08lx\n", hres); + ok(elem != NULL, "documentElement = NULL\n"); + IHTMLElement_Release(elem); + + hres = IHTMLDocument2_get_frames(new_document2, &frames); + ok(hres == E_NOTIMPL, "get_frames returned: %08lx\n", hres); + hres = IHTMLDocument2_get_location(new_document2, &location); ok(hres == E_UNEXPECTED, "get_location returned: %08lx\n", hres);
+ hres = IHTMLDocument2_get_selection(new_document2, &selection); + ok(hres == S_OK, "get_selection returned: %08lx\n", hres); + ok(selection != NULL, "selection = NULL\n"); + hres = IHTMLSelectionObject_get_type(selection, &str); + ok(hres == S_OK, "selection get_type returned: %08lx\n", hres); + ok(!lstrcmpW(str, L"None"), "selection type = %s\n", wine_dbgstr_w(str)); + IHTMLSelectionObject_Release(selection); + SysFreeString(str); + + hres = IHTMLDocument2_get_URL(new_document2, &str); + ok(hres == S_OK, "get_URL returned: %08lx\n", hres); + ok(!lstrcmpW(str, L"about:blank"), "URL = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + str = SysAllocString(L"text/html"); + V_VT(&v) = VT_ERROR; + disp = (IDispatch*)0xdeadbeef; + hres = IHTMLDocument2_open(new_document2, str, v, v, v, &disp); + ok(hres == E_FAIL, "open returned: %08lx\n", hres); + ok(disp == NULL, "disp = %p\n", disp); + SysFreeString(str); + memset(&v, 0xcc, sizeof(v)); hres = IHTMLDocument7_get_onmsthumbnailclick(new_document, &v); ok(hres == S_OK, "get_onmsthumbnailclick returned: %08lx\n", hres); @@ -7365,6 +7418,7 @@ static void test_dom_implementation(IHTMLDocument2 *doc) ok((DWORD)(DWORD_PTR)V_DISPATCH(&v) == 0xcccccccc, "got %p\n", V_DISPATCH(&v));
IHTMLDocument2_Release(new_document2); + IHTMLDocument3_Release(new_document3); IHTMLDocument7_Release(new_document); IHTMLDOMImplementation2_Release(dom_implementation2); }else {