diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c
index 217037a86fd..97d451c1444 100644
--- a/dlls/mshtml/tests/htmldoc.c
+++ b/dlls/mshtml/tests/htmldoc.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2007 Jacek Caban for CodeWeavers
+ * Copyright 2005-2009 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -121,6 +121,7 @@ DEFINE_EXPECT(Navigate);
DEFINE_EXPECT(OnFrameWindowActivate);
DEFINE_EXPECT(OnChanged_READYSTATE);
DEFINE_EXPECT(OnChanged_1005);
+DEFINE_EXPECT(OnChanged_1012);
DEFINE_EXPECT(GetDisplayName);
DEFINE_EXPECT(BindToStorage);
DEFINE_EXPECT(IsSystemMoniker);
@@ -144,8 +145,10 @@ DEFINE_EXPECT(EnableModeless_TRUE);
DEFINE_EXPECT(EnableModeless_FALSE);
DEFINE_EXPECT(Frame_EnableModeless_TRUE);
DEFINE_EXPECT(Frame_EnableModeless_FALSE);
+DEFINE_EXPECT(Frame_GetWindow);
static IUnknown *doc_unk;
+static IMoniker *doc_mon;
static BOOL expect_LockContainer_fLock;
static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
static BOOL ipsex;
@@ -182,8 +185,6 @@ static BOOL nogecko = FALSE;
#define test_readyState(u) _test_readyState(__LINE__,u)
static void _test_readyState(unsigned,IUnknown*);
-static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
-
static const WCHAR wszTimesNewRoman[] =
{'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
static const WCHAR wszArial[] =
@@ -236,6 +237,75 @@ static void test_timer(DWORD flags)
CHECK_CALLED(Exec_SETTITLE);
}
+static IMoniker Moniker;
+
+#define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
+static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
+{
+ IHTMLDocument2 *doc;
+ IPersistMoniker *permon;
+ IMoniker *mon = (void*)0xdeadbeef;
+ BSTR doc_url = (void*)0xdeadbeef;
+ HRESULT hres;
+
+ hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
+ ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
+ if(FAILED(hres))
+ return;
+
+ hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
+ ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
+
+ hres = IHTMLDocument2_get_URL(doc, &doc_url);
+ ok(hres == S_OK, "get_URL failed: %08x\n", hres);
+
+ hres = IPersistMoniker_GetCurMoniker(permon, &mon);
+ IPersistMoniker_Release(permon);
+
+ if(exmon) {
+ LPOLESTR url;
+ BOOL exb = expect_GetDisplayName;
+ BOOL clb = called_GetDisplayName;
+
+ ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
+ ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
+
+ if(mon == &Moniker)
+ SET_EXPECT(GetDisplayName);
+ hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
+ ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
+ if(mon == &Moniker)
+ CHECK_CALLED(GetDisplayName);
+ expect_GetDisplayName = exb;
+ called_GetDisplayName = clb;
+
+ ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
+ CoTaskMemFree(url);
+ }else if(exurl) {
+ LPOLESTR url;
+
+ ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
+
+ hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
+ ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
+
+ ok(!lstrcmpW(url, exurl), "unexpected url\n");
+ ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
+
+ CoTaskMemFree(url);
+ }else {
+ ok(hres == E_UNEXPECTED,
+ "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
+ ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
+ ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
+ }
+
+ SysFreeString(doc_url);
+ IHTMLDocument_Release(doc);
+ if(mon && mon != (void*)0xdeadbeef)
+ IMoniker_Release(mon);
+}
+
DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
@@ -667,6 +737,13 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D
test_readyState(NULL);
readystate_set_interactive = (load_state != LD_INTERACTIVE);
return S_OK;
+ case 1012:
+ CHECK_EXPECT(OnChanged_1012);
+ return S_OK;
+ case 3000029:
+ case 3000030:
+ /* TODO */
+ return S_OK;
}
ok(0, "unexpected id %d\n", dispID);
@@ -1220,7 +1297,7 @@ static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
{
- ok(0, "unexpected call\n");
+ CHECK_EXPECT(Frame_GetWindow);
return E_NOTIMPL;
}
@@ -1323,9 +1400,9 @@ static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLE
static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
{
if(fEnable)
- CHECK_EXPECT(Frame_EnableModeless_TRUE);
+ CHECK_EXPECT2(Frame_EnableModeless_TRUE);
else
- CHECK_EXPECT(Frame_EnableModeless_FALSE);
+ CHECK_EXPECT2(Frame_EnableModeless_FALSE);
return E_NOTIMPL;
}
@@ -1386,7 +1463,7 @@ static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
{
- CHECK_EXPECT(GetWindow);
+ CHECK_EXPECT2(GetWindow);
ok(phwnd != NULL, "phwnd = NULL\n");
*phwnd = container_hwnd;
return S_OK;
@@ -1943,9 +2020,9 @@ static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
{
if(fEnable)
- CHECK_EXPECT(EnableModeless_TRUE);
+ CHECK_EXPECT2(EnableModeless_TRUE);
else
- CHECK_EXPECT(EnableModeless_FALSE);
+ CHECK_EXPECT2(EnableModeless_FALSE);
return E_NOTIMPL;
}
@@ -2168,8 +2245,12 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
return S_OK;
case OLECMDID_HTTPEQUIV:
CHECK_EXPECT2(Exec_HTTPEQUIV);
- ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
- /* TODO */
+ ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
+ ok(pvaIn != NULL, "pvaIn == NULL\n");
+ ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
+ ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
+ ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
+ test_readyState(NULL);
return S_OK;
default:
ok(0, "unexpected command %d\n", nCmdID);
@@ -2187,7 +2268,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
if(load_from_stream)
test_GetCurMoniker(doc_unk, NULL, about_blank_url);
else if(!editmode)
- test_GetCurMoniker(doc_unk, &Moniker, NULL);
+ test_GetCurMoniker(doc_unk, doc_mon, NULL);
ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
ok(pvaIn != NULL, "pvaIn == NULL\n");
@@ -2267,6 +2348,9 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
ok(pvaIn == NULL, "pvaIn != NULL\n");
ok(pvaOut == NULL, "pvaOut != NULL\n");
return S_OK;
+ case OLECMDID_SHOWSCRIPTERROR:
+ /* TODO */
+ return S_OK;
default:
ok(0, "unexpected command %d\n", nCmdID);
return E_FAIL;
@@ -2496,6 +2580,10 @@ static void _test_readyState(unsigned line, IUnknown *unk)
hres = IHTMLDocument2_get_readyState(htmldoc, &state);
ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
+
+ if(!lstrcmpW(state, wszInteractive) && load_state == LD_LOADING)
+ load_state = LD_INTERACTIVE;
+
ok_(__FILE__, line)
(!lstrcmpW(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
wine_dbgstr_w(state), load_state);
@@ -2573,71 +2661,7 @@ static void test_ConnectionPointContainer(IUnknown *unk)
IConnectionPointContainer_Release(container);
}
-static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
-{
- IHTMLDocument2 *doc;
- IPersistMoniker *permon;
- IMoniker *mon = (void*)0xdeadbeef;
- BSTR doc_url = (void*)0xdeadbeef;
- HRESULT hres;
-
- hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
- ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
- if(FAILED(hres))
- return;
-
- hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
- ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
-
- hres = IHTMLDocument2_get_URL(doc, &doc_url);
- ok(hres == S_OK, "get_URL failed: %08x\n", hres);
-
- hres = IPersistMoniker_GetCurMoniker(permon, &mon);
- IPersistMoniker_Release(permon);
-
- if(exmon) {
- LPOLESTR url;
- BOOL exb = expect_GetDisplayName;
- BOOL clb = called_GetDisplayName;
-
- ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
- ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
-
- SET_EXPECT(GetDisplayName);
- hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
- ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
- CHECK_CALLED(GetDisplayName);
- expect_GetDisplayName = exb;
- called_GetDisplayName = clb;
-
- ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
- CoTaskMemFree(url);
- }else if(exurl) {
- LPOLESTR url;
-
- ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
-
- hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
- ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
-
- ok(!lstrcmpW(url, exurl), "unexpected url\n");
- ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
-
- CoTaskMemFree(url);
- }else {
- ok(hres == E_UNEXPECTED,
- "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
- ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
- ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
- }
-
- SysFreeString(doc_url);
- IHTMLDocument_Release(doc);
- if(mon && mon != (void*)0xdeadbeef)
- IMoniker_Release(mon);
-}
-
-static void test_Load(IPersistMoniker *persist)
+static void test_Load(IPersistMoniker *persist, IMoniker *mon)
{
IBindCtx *bind;
HRESULT hres;
@@ -2647,11 +2671,14 @@ static void test_Load(IPersistMoniker *persist)
test_readyState((IUnknown*)persist);
+ doc_mon = mon;
+
CreateBindCtx(0, &bind);
IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
(IUnknown*)&ClientSite);
- SET_EXPECT(GetDisplayName);
+ if(mon == &Moniker)
+ SET_EXPECT(GetDisplayName);
if(!set_clientsite) {
SET_EXPECT(Invoke_AMBIENT_USERMODE);
SET_EXPECT(GetHostInfo);
@@ -2675,7 +2702,8 @@ static void test_Load(IPersistMoniker *persist)
SET_EXPECT(OnChanged_READYSTATE);
SET_EXPECT(Exec_ShellDocView_84);
SET_EXPECT(IsSystemMoniker);
- SET_EXPECT(BindToStorage);
+ if(mon == &Moniker)
+ SET_EXPECT(BindToStorage);
SET_EXPECT(SetActiveObject);
if(set_clientsite) {
SET_EXPECT(Invoke_AMBIENT_SILENT);
@@ -2686,10 +2714,11 @@ static void test_Load(IPersistMoniker *persist)
expect_LockContainer_fLock = TRUE;
readystate_set_loading = TRUE;
- hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
+ hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
ok(hres == S_OK, "Load failed: %08x\n", hres);
- CHECK_CALLED(GetDisplayName);
+ if(mon == &Moniker)
+ CHECK_CALLED(GetDisplayName);
if(!set_clientsite) {
CHECK_CALLED(Invoke_AMBIENT_USERMODE);
CHECK_CALLED(GetHostInfo);
@@ -2714,7 +2743,8 @@ static void test_Load(IPersistMoniker *persist)
CHECK_CALLED(OnChanged_READYSTATE);
SET_CALLED(IsSystemMoniker); /* IE7 */
SET_CALLED(Exec_ShellDocView_84);
- CHECK_CALLED(BindToStorage);
+ if(mon == &Moniker)
+ CHECK_CALLED(BindToStorage);
SET_CALLED(SetActiveObject); /* FIXME */
if(set_clientsite) {
CHECK_CALLED(Invoke_AMBIENT_SILENT);
@@ -2724,7 +2754,7 @@ static void test_Load(IPersistMoniker *persist)
set_clientsite = container_locked = TRUE;
- test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
+ test_GetCurMoniker((IUnknown*)persist, mon, NULL);
IBindCtx_Release(bind);
@@ -2764,6 +2794,11 @@ static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
SET_EXPECT(EnableModeless_FALSE); /* IE7 */
SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
+ if(doc_mon != &Moniker) {
+ SET_EXPECT(OnChanged_1012);
+ SET_EXPECT(Exec_HTTPEQUIV);
+ SET_EXPECT(Exec_SETTITLE);
+ }
SET_EXPECT(OnChanged_1005);
SET_EXPECT(OnChanged_READYSTATE);
SET_EXPECT(Exec_SETPROGRESSPOS);
@@ -2817,6 +2852,11 @@ static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
SET_CALLED(EnableModeless_FALSE); /* IE7 */
SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
+ if(doc_mon != &Moniker) todo_wine {
+ CHECK_CALLED(OnChanged_1012);
+ CHECK_CALLED(Exec_HTTPEQUIV);
+ CHECK_CALLED(Exec_SETTITLE);
+ }
CHECK_CALLED(OnChanged_1005);
CHECK_CALLED(OnChanged_READYSTATE);
CHECK_CALLED(Exec_SETPROGRESSPOS);
@@ -2832,7 +2872,7 @@ static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
test_readyState(NULL);
}
-static void test_Persist(IUnknown *unk)
+static void test_Persist(IUnknown *unk, IMoniker *mon)
{
IPersistMoniker *persist_mon;
IPersistFile *persist_file;
@@ -2863,7 +2903,7 @@ static void test_Persist(IUnknown *unk)
ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
if(load_state == LD_DOLOAD)
- test_Load(persist_mon);
+ test_Load(persist_mon, mon);
test_readyState(unk);
@@ -3829,7 +3869,7 @@ static void test_HTMLDocument(BOOL do_load)
test_external(unk, FALSE);
test_ConnectionPointContainer(unk);
test_GetCurMoniker(unk, NULL, NULL);
- test_Persist(unk);
+ test_Persist(unk, &Moniker);
if(!do_load)
test_OnAmbientPropertyChange2(unk);
@@ -3924,7 +3964,7 @@ static void test_HTMLDocument_hlink(void)
test_ConnectionPointContainer(unk);
test_GetCurMoniker(unk, NULL, NULL);
- test_Persist(unk);
+ test_Persist(unk, &Moniker);
test_Navigate(unk);
if(show_failed) {
IUnknown_Release(unk);
@@ -3951,6 +3991,59 @@ static void test_HTMLDocument_hlink(void)
ok(ref == 0, "ref=%d, expected 0\n", ref);
}
+static void test_HTMLDocument_http(void)
+{
+ IMoniker *http_mon;
+ IUnknown *unk;
+ ULONG ref;
+ HRESULT hres;
+
+ static const WCHAR http_urlW[] =
+ {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
+
+ trace("Testing HTMLDocument (http)...\n");
+
+ hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
+ ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
+
+ init_test(LD_DOLOAD);
+ ipsex = TRUE;
+
+ hres = create_document(&unk);
+ if(FAILED(hres))
+ return;
+ doc_unk = unk;
+
+ test_ConnectionPointContainer(unk);
+ test_GetCurMoniker(unk, NULL, NULL);
+ test_Persist(unk, http_mon);
+ test_Navigate(unk);
+ if(show_failed) {
+ IUnknown_Release(unk);
+ return;
+ }
+
+ test_download(FALSE, FALSE, FALSE);
+
+ test_IsDirty(unk, S_FALSE);
+ test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
+
+ test_InPlaceDeactivate(unk, TRUE);
+ test_Close(unk, FALSE);
+ test_IsDirty(unk, S_FALSE);
+ test_GetCurMoniker(unk, http_mon, NULL);
+
+ if(view)
+ IOleDocumentView_Release(view);
+ view = NULL;
+
+ ref = IUnknown_Release(unk);
+ ok(!ref, "ref=%d, expected 0\n", ref);
+
+ ref = IMoniker_Release(http_mon);
+ ok(!ref, "ref=%d, expected 0\n", ref);
+}
+
static void test_HTMLDocument_StreamLoad(void)
{
IOleObject *oleobj;
@@ -4055,7 +4148,7 @@ static void test_editing_mode(BOOL do_load)
test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
if(do_load)
- test_Persist(unk);
+ test_Persist(unk, &Moniker);
stream_read = protocol_read = 0;
test_exec_editmode(unk, do_load);
test_UIDeactivate();
@@ -4217,6 +4310,7 @@ START_TEST(htmldoc)
test_HTMLDocument_StreamLoad();
test_editing_mode(FALSE);
test_editing_mode(TRUE);
+ test_HTMLDocument_http();
}
test_HTMLDoc_ISupportErrorInfo();
test_IPersistHistory();