-- v2: mshtml: Implement document.vLinkColor. mshtml: Implement document.linkColor. mshtml: Clear the document before opening it for writing.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
On open(), native always clears the document, but gecko only clears it if it was closed.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 2 + dlls/mshtml/tests/dom.c | 140 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 174e1a784fd..53b9c01bcba 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1384,6 +1384,8 @@ static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR) FIXME("unsupported args\n");
+ nsIDOMHTMLDocument_Close(This->html_document); + nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL, get_context_from_document(This->dom_document), 0, &tmp); if(NS_FAILED(nsres)) { diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 9eb7bac9a11..f0ac1053c40 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -6910,6 +6910,144 @@ static void test_default_selection(IHTMLDocument2 *doc) IHTMLTxtRange_Release(range); }
+static void test_doc_open(IHTMLDocument2 *doc) +{ + IHTMLElementCollection *col; + IHTMLDocument3 *doc3; + LONG len, index = 0; + IHTMLElement *elem; + IDispatch *disp; + SAFEARRAY *sa; + HRESULT hres; + VARIANT v; + BSTR bstr; + + hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3); + ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08lx\n", hres); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + test_elem_tag((IUnknown*)elem, L"HTML"); + IHTMLElement_Release(elem); + + sa = SafeArrayCreateVector(VT_VARIANT, 0, 1); + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = SysAllocString(L"<p>test</p>"); + hres = SafeArrayPutElement(sa, &index, &v); + ok(hres == S_OK, "SafeArrayPutElement failed: %08lx\n", hres); + VariantClear(&v); + + disp = NULL; + hres = IHTMLDocument2_open(doc, NULL, v, v, v, &disp); + ok(hres == S_OK, "open failed: %08lx\n", hres); + ok(disp != NULL, "disp = NULL\n"); + IDispatch_Release(disp); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + ok(elem == NULL, "elem != NULL\n"); + + hres = IHTMLDocument2_write(doc, sa); + ok(hres == S_OK, "write failed: %08lx\n", hres); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + test_elem_tag((IUnknown*)elem, L"HTML"); + IHTMLElement_Release(elem); + + hres = IHTMLDocument2_close(doc); + ok(hres == S_OK, "close failed: %08lx\n", hres); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + test_elem_tag((IUnknown*)elem, L"HTML"); + IHTMLElement_Release(elem); + + disp = NULL; + hres = IHTMLDocument2_open(doc, NULL, v, v, v, &disp); + ok(hres == S_OK, "open failed: %08lx\n", hres); + ok(disp != NULL, "disp = NULL\n"); + IDispatch_Release(disp); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + ok(elem == NULL, "elem != NULL\n"); + + hres = IHTMLDocument2_write(doc, sa); + ok(hres == S_OK, "write failed: %08lx\n", hres); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + test_elem_tag((IUnknown*)elem, L"HTML"); + IHTMLElement_Release(elem); + + disp = NULL; + hres = IHTMLDocument2_open(doc, NULL, v, v, v, &disp); + ok(hres == S_OK, "open failed: %08lx\n", hres); + ok(disp != NULL, "disp = NULL\n"); + IDispatch_Release(disp); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + ok(elem == NULL, "elem != NULL\n"); + + hres = IHTMLDocument2_write(doc, sa); + ok(hres == S_OK, "write failed: %08lx\n", hres); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + test_elem_tag((IUnknown*)elem, L"HTML"); + IHTMLElement_Release(elem); + + hres = IHTMLDocument2_clear(doc); + ok(hres == S_OK, "clear failed: %08lx\n", hres); + + hres = IHTMLDocument3_get_documentElement(doc3, &elem); + ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres); + test_elem_tag((IUnknown*)elem, L"HTML"); + IHTMLElement_Release(elem); + + hres = IHTMLDocument2_close(doc); + ok(hres == S_OK, "close failed: %08lx\n", hres); + + bstr = SysAllocString(L"p"); + hres = IHTMLDocument3_getElementsByTagName(doc3, bstr, &col); + ok(hres == S_OK, "getElementsByTagName failed: %08lx\n", hres); + hres = IHTMLElementCollection_get_length(col, &len); + ok(hres == S_OK, "get_length failed: %08lx\n", hres); + ok(len == 1, "len = %ld\n", len); + IHTMLElementCollection_Release(col); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = SysAllocString(L"<div>wine</div>"); + hres = SafeArrayPutElement(sa, &index, &v); + ok(hres == S_OK, "SafeArrayPutElement failed: %08lx\n", hres); + VariantClear(&v); + + hres = IHTMLDocument2_write(doc, sa); + ok(hres == S_OK, "write failed: %08lx\n", hres); + + hres = IHTMLDocument3_getElementsByTagName(doc3, bstr, &col); + ok(hres == S_OK, "getElementsByTagName failed: %08lx\n", hres); + hres = IHTMLElementCollection_get_length(col, &len); + ok(hres == S_OK, "get_length failed: %08lx\n", hres); + ok(len == 0, "len = %ld\n", len); + IHTMLElementCollection_Release(col); + SysFreeString(bstr); + + bstr = SysAllocString(L"div"); + hres = IHTMLDocument3_getElementsByTagName(doc3, bstr, &col); + ok(hres == S_OK, "getElementsByTagName failed: %08lx\n", hres); + hres = IHTMLElementCollection_get_length(col, &len); + ok(hres == S_OK, "get_length failed: %08lx\n", hres); + ok(len == 1, "len = %ld\n", len); + IHTMLElementCollection_Release(col); + SysFreeString(bstr); + + IHTMLDocument3_Release(doc3); + SafeArrayDestroy(sa); +} + static void test_doc_dir(IHTMLDocument2 *doc2) { IHTMLDocument3 *doc = get_doc3_iface(doc2); @@ -12526,6 +12664,7 @@ START_TEST(dom)
run_domtest(doc_str1, test_doc_elem); run_domtest(doc_str1, test_get_set_attr); + run_domtest(doc_blank, test_doc_open); run_domtest(doc_blank, test_range); if (winetest_interactive || ! is_ie_hardened()) { run_domtest(elem_test_str, test_elems); @@ -12534,6 +12673,7 @@ START_TEST(dom) run_domtest(doc_blank, test_about_blank_storage); if(is_ie9plus) { compat_mode = COMPAT_IE9; + run_domtest(doc_blank_ie9, test_doc_open); run_domtest(doc_blank_ie9, test_dom_elements); run_domtest(doc_blank_ie9, test_about_blank_storage); compat_mode = COMPAT_NONE;
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 35 +++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.js | 12 ++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 53b9c01bcba..b9f0c71b13c 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -929,15 +929,42 @@ static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v) { HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + hres = variant_to_nsstr(&v, FALSE, &nsstr); + if(FAILED(hres)) + return hres; + + nsres = nsIDOMHTMLDocument_SetLinkColor(This->html_document, &nsstr); + nsAString_Finish(&nsstr); + return map_nsresult(nsres); }
static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p) { HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsAString_Init(&nsstr, NULL); + nsres = nsIDOMHTMLDocument_GetLinkColor(This->html_document, &nsstr); + return return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p); }
static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v) diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index 46dc239c3eb..dca41f60173 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -385,6 +385,18 @@ sync_test("document_owner", function() { ok(node.ownerDocument === document, "text.ownerDocument = " + node.ownerDocument); });
+sync_test("document_style_props", function() { + document.body.innerHTML = '<a href="#"></a>'; + var r, elem = document.getElementsByTagName("a")[0]; + todo_wine. + ok(document.linkColor === "#0000ff", "default linkColor = " + document.linkColor); + + document.linkColor = "#deadb8"; + ok(document.linkColor === "#deadb8", "linkColor = " + document.linkColor); + r = window.getComputedStyle(elem).color; + ok(r === "rgb(222, 173, 184)", "style color = " + r); +}); + sync_test("style_properties", function() { document.body.innerHTML = '<div>test</div><svg></svg>'; var elem = document.body.firstChild;
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 35 +++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.js | 4 ++++ 2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index b9f0c71b13c..c77a9b848e6 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -970,15 +970,42 @@ static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v) { HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + hres = variant_to_nsstr(&v, FALSE, &nsstr); + if(FAILED(hres)) + return hres; + + nsres = nsIDOMHTMLDocument_SetVlinkColor(This->html_document, &nsstr); + nsAString_Finish(&nsstr); + return map_nsresult(nsres); }
static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p) { HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsAString_Init(&nsstr, NULL); + nsres = nsIDOMHTMLDocument_GetVlinkColor(This->html_document, &nsstr); + return return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p); }
static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p) diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index dca41f60173..fd4c803893c 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -395,6 +395,10 @@ sync_test("document_style_props", function() { ok(document.linkColor === "#deadb8", "linkColor = " + document.linkColor); r = window.getComputedStyle(elem).color; ok(r === "rgb(222, 173, 184)", "style color = " + r); + + ok(document.vLinkColor === undefined, "default vLinkColor = " + document.vLinkColor); + document.vLinkColor = "#b8dead"; + ok(document.vLinkColor === "#b8dead", "vLinkColor = " + document.vLinkColor); });
sync_test("style_properties", function() {
This merge request was approved by Jacek Caban.