Commit 47c27742 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLLocation::put_href implementation.

parent 4aa48041
......@@ -134,8 +134,15 @@ static HRESULT WINAPI HTMLLocation_Invoke(IHTMLLocation *iface, DISPID dispIdMem
static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v)
{
HTMLLocation *This = HTMLLOCATION_THIS(iface);
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
return E_NOTIMPL;
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
if(!This->window || !This->window->doc) {
FIXME("No document available\n");
return E_FAIL;
}
return navigate_url(This->window->doc, v);
}
static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p)
......
......@@ -608,6 +608,7 @@ BOOL install_wine_gecko(BOOL);
HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
HRESULT navigate_url(HTMLDocumentNode*,OLECHAR*);
void call_property_onchanged(ConnectionPoint*,DISPID);
HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
......
......@@ -41,6 +41,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define CONTENT_LENGTH "Content-Length"
#define UTF16_STR "utf-16"
static WCHAR emptyW[] = {0};
typedef struct {
const nsIInputStreamVtbl *lpInputStreamVtbl;
......@@ -1217,3 +1219,26 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url,
IBindStatusCallback_Release(STATUSCLB(callback));
return hres;
}
HRESULT navigate_url(HTMLDocumentNode *doc, OLECHAR *url)
{
OLECHAR *translated_url = NULL;
HRESULT hres;
if(!url)
url = emptyW;
if(doc->basedoc.doc_obj->hostui) {
hres = IDocHostUIHandler_TranslateUrl(doc->basedoc.doc_obj->hostui, 0, url,
&translated_url);
if(hres == S_OK)
url = translated_url;
}
hres = hlink_frame_navigate(&doc->basedoc, url, NULL, 0);
if(FAILED(hres))
FIXME("hlink_frame_navigate failed: %08x\n", hres);
CoTaskMemFree(translated_url);
return hres;
}
......@@ -148,6 +148,7 @@ DEFINE_EXPECT(EnableModeless_FALSE);
DEFINE_EXPECT(Frame_EnableModeless_TRUE);
DEFINE_EXPECT(Frame_EnableModeless_FALSE);
DEFINE_EXPECT(Frame_GetWindow);
DEFINE_EXPECT(TranslateUrl);
static IUnknown *doc_unk;
static IMoniker *doc_mon;
......@@ -665,6 +666,7 @@ static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPB
DWORD site_data = 0xdeadbeef;
hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
todo_wine
ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
ok(frame_name == NULL, "frame_name = %p\n", frame_name);
......@@ -676,6 +678,7 @@ static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPB
hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
ok(site == NULL, "site = %p\n, expected NULL\n", site);
todo_wine
ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
}
......@@ -2107,8 +2110,13 @@ static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, ID
static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
CHECK_EXPECT(TranslateUrl);
ok(!dwTranslate, "dwTranslate = %x\n", dwTranslate);
ok(!strcmp_wa(pchURLIn, "about:blank"), "pchURLIn = %s\n", wine_dbgstr_w(pchURLIn));
ok(ppchURLOut != NULL, "ppchURLOut == NULL\n");
ok(!*ppchURLOut, "*ppchURLOut = %p\n", *ppchURLOut);
return S_FALSE;
}
static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
......@@ -2997,6 +3005,34 @@ static void test_Persist(IUnknown *unk, IMoniker *mon)
}
}
static void test_put_href(IUnknown *unk)
{
IHTMLLocation *location;
IHTMLDocument2 *doc;
BSTR str;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
location = NULL;
hres = IHTMLDocument2_get_location(doc, &location);
IHTMLDocument2_Release(doc);
ok(hres == S_OK, "get_location failed: %08x\n", hres);
ok(location != NULL, "location == NULL\n");
SET_EXPECT(TranslateUrl);
SET_EXPECT(Navigate);
str = a2bstr("about:blank");
hres = IHTMLLocation_put_href(location, str);
SysFreeString(str);
ok(hres == S_OK, "put_href failed: %08x\n", hres);
CHECK_CALLED(TranslateUrl);
CHECK_CALLED(Navigate);
IHTMLLocation_Release(location);
}
static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
0,
OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
......@@ -4118,6 +4154,8 @@ static void test_HTMLDocument_http(void)
test_IsDirty(unk, S_FALSE);
test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
test_put_href(unk);
test_InPlaceDeactivate(unk, TRUE);
test_Close(unk, FALSE);
test_IsDirty(unk, S_FALSE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment