mshtml: Return proper errors when navigating with no browser.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
This commit is contained in:
Gabriel Ivăncescu 2023-10-20 22:24:51 +03:00 committed by Alexandre Julliard
parent 110dad9ca5
commit 4418f928af
3 changed files with 24 additions and 2 deletions

View file

@ -2832,7 +2832,7 @@ static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface,
FIXME("unimplemented flags %lx\n", flags & ~2);
if(!window || !window->browser)
return E_UNEXPECTED;
return E_FAIL;
if(window->browser->doc->hostui) {
hres = IDocHostUIHandler_TranslateUrl(window->browser->doc->hostui, 0, url, &translated_url);

View file

@ -2679,6 +2679,9 @@ HRESULT navigate_url(HTMLOuterWindow *window, const WCHAR *new_url, IUri *base_u
BSTR display_uri;
HRESULT hres;
if(!window->browser)
return E_UNEXPECTED;
if(new_url && base_uri)
hres = CoInternetCombineUrlEx(base_uri, new_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
&nav_uri, 0);

View file

@ -6003,12 +6003,13 @@ static void test_document_close(void)
{
IHTMLPrivateWindow *priv_window;
IHTMLDocument2 *doc, *doc_node;
IHTMLLocation *location;
IHTMLDocument3 *doc3;
IHTMLElement *elem;
DWORD cookie;
BSTR bstr, bstr2;
HRESULT hres;
VARIANT v;
BSTR bstr;
LONG ref;
MSG msg;
@ -6091,6 +6092,24 @@ static void test_document_close(void)
IHTMLDocument2_Release(doc_node);
IHTMLDocument2_Release(doc);
bstr = SysAllocString(L"about:blank");
hres = IHTMLWindow2_get_location(window, &location);
ok(hres == S_OK, "get_location failed: %08lx\n", hres);
hres = IHTMLLocation_put_href(location, bstr);
ok(hres == E_UNEXPECTED || broken(hres == E_ABORT), "put_href returned: %08lx\n", hres);
IHTMLLocation_Release(location);
V_VT(&v) = VT_EMPTY;
bstr2 = SysAllocString(L"");
hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window);
ok(hres == S_OK, "Could not get IHTMLPrivateWindow) interface: %08lx\n", hres);
hres = IHTMLPrivateWindow_SuperNavigate(priv_window, bstr, bstr2, NULL, NULL, &v, &v, 0);
ok(hres == E_FAIL, "SuperNavigate returned: %08lx\n", hres);
IHTMLPrivateWindow_Release(priv_window);
SysFreeString(bstr2);
SysFreeString(bstr);
IHTMLWindow2_Release(window);
window = NULL;