mshtml: Added get_URL implementation.

This commit is contained in:
Jacek Caban 2007-06-11 17:37:20 +02:00 committed by Alexandre Julliard
parent 068ce61523
commit b95197ac19
4 changed files with 57 additions and 5 deletions

View File

@ -508,8 +508,15 @@ static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p) static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
{ {
FIXME("(%p)->(%p)\n", iface, p); HTMLDocument *This = HTMLDOC_THIS(iface);
return E_NOTIMPL;
static const WCHAR about_blank_url[] =
{'a','b','o','u','t',':','b','l','a','n','k',0};
TRACE("(%p)->(%p)\n", iface, p);
*p = SysAllocString(This->url ? This->url : about_blank_url);
return S_OK;
} }
static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v) static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)

View File

@ -102,6 +102,7 @@ struct HTMLDocument {
BSCallback *bscallback; BSCallback *bscallback;
IMoniker *mon; IMoniker *mon;
BSTR url;
HWND hwnd; HWND hwnd;
HWND tooltips_hwnd; HWND tooltips_hwnd;

View File

@ -115,11 +115,27 @@ static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
void set_current_mon(HTMLDocument *This, IMoniker *mon) void set_current_mon(HTMLDocument *This, IMoniker *mon)
{ {
if(This->mon) HRESULT hres;
if(This->mon) {
IMoniker_Release(This->mon); IMoniker_Release(This->mon);
if(mon) This->mon = NULL;
IMoniker_AddRef(mon); }
if(This->url) {
SysFreeString(This->url);
This->url = NULL;
}
if(!mon)
return;
IMoniker_AddRef(mon);
This->mon = mon; This->mon = mon;
hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->url);
if(FAILED(hres))
WARN("GetDisplayName failed: %08x\n", hres);
} }
static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL *bind_complete) static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL *bind_complete)
@ -674,4 +690,5 @@ void HTMLDocument_Persist_Init(HTMLDocument *This)
This->bscallback = NULL; This->bscallback = NULL;
This->mon = NULL; This->mon = NULL;
This->url = NULL;
} }

View File

@ -2189,8 +2189,10 @@ static void test_ConnectionPointContainer(IUnknown *unk)
static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl) static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
{ {
IHTMLDocument2 *doc;
IPersistMoniker *permon; IPersistMoniker *permon;
IMoniker *mon = (void*)0xdeadbeef; IMoniker *mon = (void*)0xdeadbeef;
BSTR doc_url = (void*)0xdeadbeef;
HRESULT hres; HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon); hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
@ -2198,12 +2200,32 @@ static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
if(FAILED(hres)) if(FAILED(hres))
return; 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); hres = IPersistMoniker_GetCurMoniker(permon, &mon);
IPersistMoniker_Release(permon); IPersistMoniker_Release(permon);
if(exmon) { if(exmon) {
BSTR url;
BOOL exb = expect_GetDisplayName;
BOOL clb = called_GetDisplayName;
ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres); ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon); 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;
SysFreeString(url);
ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
}else if(exurl) { }else if(exurl) {
BSTR url; BSTR url;
@ -2213,13 +2235,18 @@ static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres); ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
ok(!lstrcmpW(url, exurl), "unexpected url\n"); ok(!lstrcmpW(url, exurl), "unexpected url\n");
ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
SysFreeString(url); SysFreeString(url);
}else { }else {
ok(hres == E_UNEXPECTED, ok(hres == E_UNEXPECTED,
"GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres); "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon); 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) if(mon && mon != (void*)0xdeadbeef)
IMoniker_Release(mon); IMoniker_Release(mon);
} }