From: Jacob Czekalla jczekalla@codeweavers.com
Documents such as iframes do not currently receive BeforeNavigate2 events. --- dlls/mshtml/nsio.c | 45 +++++++++++++++++++++++++++---------- dlls/mshtml/tests/htmldoc.c | 2 +- 2 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index a5564e1b6e4..f6462bd1aa7 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -1000,6 +1000,23 @@ static void start_binding_task_destr(task_t *_task) IBindStatusCallback_Release(&task->bscallback->bsc.IBindStatusCallback_iface); }
+static HRESULT fire_beforenavigate2(HTMLOuterWindow *window, BSTR url) +{ + BSTR frame_name = NULL; + BOOL cancel = FALSE; + HRESULT hres; + + hres = IHTMLWindow2_get_name(&window->base.IHTMLWindow2_iface, &frame_name); + if (FAILED(hres)) + return NS_ERROR_UNEXPECTED; + + hres = IDocObjectService_FireBeforeNavigate2(window->browser->doc->doc_object_service, NULL, url, 0, frame_name, NULL, 0, NULL, FALSE, &cancel); + SysFreeString(frame_name); + if (cancel) + return NS_BINDING_ABORTED; + return S_OK; +} + static nsresult async_open(nsChannel *This, HTMLOuterWindow *window, BOOL is_doc_channel, UINT32 load_type, nsIStreamListener *listener, nsISupports *context) { @@ -1058,24 +1075,19 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen BOOL is_document_channel; BOOL cancel = FALSE; nsresult nsres = NS_OK; + HRESULT hres; + BSTR uri_str;
TRACE("(%p)->(%p %p)\n", This, aListener, aContext);
if(!ensure_uri(This->uri)) return NS_ERROR_FAILURE;
- if(TRACE_ON(mshtml)) { - HRESULT hres; - BSTR uri_str; - - hres = IUri_GetDisplayUri(This->uri->uri, &uri_str); - if(SUCCEEDED(hres)) { - TRACE("opening %s\n", debugstr_w(uri_str)); - SysFreeString(uri_str); - }else { - WARN("GetDisplayUri failed: %08lx\n", hres); - } - } + hres = IUri_GetDisplayUri(This->uri->uri, &uri_str); + if(SUCCEEDED(hres) && TRACE_ON(mshtml)) + TRACE("opening %s\n", debugstr_w(uri_str)); + else if (FAILED(hres)) + WARN("GetDisplayUri failed: %08lx\n", hres);
window = get_channel_window(This, &load_type); if(!window) { @@ -1104,7 +1116,16 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen This->content_type = strdupWtoA(window->browser->doc->mime); } } + + if (!This->uri->channel_bsc && window->browser->doc->doc_object_service) + { + /* fire event for document navigations by Gecko */ + hres = fire_beforenavigate2(window, uri_str); + if (FAILED(hres)) + cancel = TRUE; + } } + SysFreeString(uri_str);
if(!cancel) nsres = async_open(This, window, is_document_channel, load_type, aListener, aContext); diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c index c17fd81e8a9..86845ce4d84 100644 --- a/dlls/mshtml/tests/htmldoc.c +++ b/dlls/mshtml/tests/htmldoc.c @@ -8344,7 +8344,7 @@ static void test_iframe_download(int flags) todo_wine CHECK_CALLED_N(FireDownloadBegin, total_iframes); todo_wine CHECK_CALLED_N(FireDownloadComplete, total_iframes);
- todo_wine CHECK_CALLED_N(FireBeforeNavigate2, total_iframes); + CHECK_CALLED_N(FireBeforeNavigate2, total_iframes); todo_wine CHECK_CALLED_N(FireNavigateComplete2, total_documents); todo_wine CHECK_CALLED_N(FireDocumentComplete, total_documents);