[PATCH v7 0/4] MR11394: ieframe/mshtml: Fire property change notification when document title is set.
NSIS HTML installers communicate with the installer engine by setting document.title and expecting the host to receive a property change notification. Without this notification the installer never sets the default install path, so clicking the install button has no effect. -- v7: ieframe/tests: Test TitleChange event is fired on navigation. ieframe: Fire TitleChange event on document title change. mshtml/tests: Add test for property change notification when document title is set. https://gitlab.winehq.org/wine/wine/-/merge_requests/11394
From: chenzhengyong <chenzhengyong@uniontech.com> NSIS HTML installers communicate with the installer engine by setting document.title and expecting the host to receive a property change notification. Without this notification the installer never sets the default install path, so clicking the install button has no effect. Signed-off-by: chenzhengyong <chenzhengyong@uniontech.com> --- dlls/mshtml/htmldoc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index ef964297404..f3dee79e997 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -649,6 +649,11 @@ static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v) if(NS_FAILED(nsres)) ERR("SetTitle failed: %08lx\n", nsres); + if(This->doc_obj) + call_property_onchanged(&This->doc_obj->cp_container, DISPID_IHTMLDOCUMENT2_TITLE); + else + call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_TITLE); + return S_OK; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11394
From: chenzhengyong <chenzhengyong@uniontech.com> Verify that IPropertyNotifySink::OnChanged is fired with DISPID_IHTMLDOCUMENT2_TITLE when IHTMLDocument2::put_title is called. Signed-off-by: chenzhengyong <chenzhengyong@uniontech.com> --- dlls/mshtml/tests/events.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index 43451cdba6a..c0b80c83ce9 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -127,6 +127,7 @@ DEFINE_EXPECT(QS_GetCaller); DEFINE_EXPECT(QS_GetCaller_parent2); DEFINE_EXPECT(QS_GetCaller_parent3); DEFINE_EXPECT(cmdtarget_Exec); +DEFINE_EXPECT(OnChanged_title); static HWND container_hwnd = NULL; static IHTMLWindow2 *window; @@ -4656,6 +4657,26 @@ static void test_create_event(IHTMLDocument2 *doc) IDocumentEvent_Release(doc_event); } +static void test_doc_title_notify(IHTMLDocument2 *doc) +{ + BSTR title = NULL, tmp; + HRESULT hres; + + trace("doc title notify tests...\n"); + + SET_EXPECT(OnChanged_title); + tmp = SysAllocString(L"wine title notify test"); + hres = IHTMLDocument2_put_title(doc, tmp); + ok(hres == S_OK, "put_title failed: %08lx\n", hres); + SysFreeString(tmp); + CHECK_CALLED(OnChanged_title); + + hres = IHTMLDocument2_get_title(doc, &title); + ok(hres == S_OK, "get_title failed: %08lx\n", hres); + ok(!lstrcmpW(title, L"wine title notify test"), "unexpected title %s\n", wine_dbgstr_w(title)); + SysFreeString(title); +} + static unsigned onstorage_expect_line; static const WCHAR *onstorage_expect_key, *onstorage_expect_old_value, *onstorage_expect_new_value; @@ -6473,6 +6494,9 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D nav_notif_test(); } + if(dispID == DISPID_IHTMLDOCUMENT2_TITLE) + CHECK_EXPECT(OnChanged_title); + return S_OK; } @@ -7779,6 +7803,7 @@ START_TEST(events) run_test(empty_doc_ie9_str, test_submit); run_test(iframe_doc_str, test_message_event); run_test(iframe_doc_str, test_iframe_connections); + run_test(empty_doc_str, test_doc_title_notify); if(is_ie9plus) { run_test_from_res(L"doc_with_prop.html", test_doc_obj); run_test_from_res(L"doc_with_prop_ie9.html", test_doc_obj); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11394
From: chenzhengyong <chenzhengyong@uniontech.com> Fire DWebBrowserEvents2::TitleChange when the document title changes, both from the OLECMDID_SETTITLE command (sent by mshtml during navigation) and from the IPropertyNotifySink::OnChanged(DISPID_IHTMLDOCUMENT2_TITLE) notification (sent when document.title is set via script or COM). This makes NSIS HTML installers receive the title-based communication messages and proceed with installation. Signed-off-by: chenzhengyong <chenzhengyong@uniontech.com> --- dlls/ieframe/dochost.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dlls/ieframe/dochost.c b/dlls/ieframe/dochost.c index add816fe97e..b603d24aa6e 100644 --- a/dlls/ieframe/dochost.c +++ b/dlls/ieframe/dochost.c @@ -22,6 +22,7 @@ #include "exdispid.h" #include "mshtml.h" +#include "mshtmdid.h" #include "perhist.h" #include "initguid.h" @@ -82,6 +83,40 @@ void abort_dochost_tasks(DocHost *This, task_proc_t proc) } } +static BOOL fire_titlechange(DocHost *This) +{ + IHTMLDocument2 *doc; + BSTR title = NULL; + DISPPARAMS dp = { NULL, NULL, 0, 0 }; + HRESULT hres; + BOOL has_title = FALSE; + VARIANTARG arg; + + if(!This->document) + return FALSE; + + hres = IUnknown_QueryInterface(This->document, &IID_IHTMLDocument2, (void **)&doc); + if(FAILED(hres)) + return FALSE; + + hres = IHTMLDocument2_get_title(doc, &title); + IHTMLDocument2_Release(doc); + if(FAILED(hres) || !title) + return FALSE; + + has_title = *title != 0; + + VariantInit(&arg); + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = title; + dp.rgvarg = &arg; + dp.cArgs = 1; + call_sink(This->cps.wbe2, DISPID_TITLECHANGE, &dp); + VariantClear(&arg); + + return has_title; +} + void on_commandstate_change(DocHost *doc_host, LONG command, BOOL enable) { DISPPARAMS dispparams; @@ -708,6 +743,10 @@ static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface, if(!This->olecmd) return E_NOTIMPL; return IOleCommandTarget_Exec(This->olecmd, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); + case OLECMDID_SETTITLE: + if(fire_titlechange(This) && This->olecmd) + return IOleCommandTarget_Exec(This->olecmd, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); + return S_OK; case OLECMDID_SETDOWNLOADSTATE: if(pvaIn && V_VT(pvaIn) == VT_I4) This->busy = V_I4(pvaIn) ? VARIANT_TRUE : VARIANT_FALSE; @@ -1109,6 +1148,9 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D update_ready_state(This, ready_state); break; } + case DISPID_IHTMLDOCUMENT2_TITLE: + fire_titlechange(This); + break; default: FIXME("unimplemented dispid %ld\n", dispID); return E_NOTIMPL; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11394
From: chenzhengyong <chenzhengyong@uniontech.com> Remove the todo_wine marker for Invoke_TITLECHANGE, since ieframe now fires DWebBrowserEvents2::TitleChange in response to the OLECMDID_SETTITLE command sent by mshtml during navigation and the DISPID_IHTMLDOCUMENT2_TITLE property change notification. Also validate the BSTR argument passed to the event. Signed-off-by: chenzhengyong <chenzhengyong@uniontech.com> --- dlls/ieframe/tests/webbrowser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/ieframe/tests/webbrowser.c b/dlls/ieframe/tests/webbrowser.c index 8c514a6ffc2..2cd8491d5f6 100644 --- a/dlls/ieframe/tests/webbrowser.c +++ b/dlls/ieframe/tests/webbrowser.c @@ -1010,7 +1010,10 @@ static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMe case DISPID_TITLECHANGE: CHECK_EXPECT2(Invoke_TITLECHANGE); - /* FIXME */ + ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n"); + ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs); + ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n", + V_VT(pDispParams->rgvarg)); break; case DISPID_NAVIGATECOMPLETE2: @@ -3128,7 +3131,7 @@ static void test_download(DWORD flags) CHECK_CALLED(Exec_SETDOWNLOADSTATE_0); else CHECK_CALLED(Invoke_DOWNLOADCOMPLETE); - todo_wine CHECK_CALLED(Invoke_TITLECHANGE); + CHECK_CALLED(Invoke_TITLECHANGE); if(!(flags & DWL_REFRESH)) CHECK_CALLED(Invoke_NAVIGATECOMPLETE2); if(is_first_load) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11394
On Mon Jul 20 01:12:03 2026 +0000, zhengyong chen wrote:
changed this line in [version 7 of the diff](/wine/wine/-/merge_requests/11394/diffs?diff_id=282842&start_sha=9aca576e07028b8df95f60ba4e321c11a9da2f69#8d45b764d5c26b8bc7304eb19184e039878391d3_12569_12567) I'v move tests to events.c
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11394#note_146090
participants (2)
-
chenzhengyong -
zhengyong chen (@chenzhengyong)