Module: wine Branch: master Commit: 4aad315a3f122cd26d2092cf163dc2c4f8953a9d URL: https://gitlab.winehq.org/wine/wine/-/commit/4aad315a3f122cd26d2092cf163dc2c...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Dec 1 15:44:34 2023 +0100
mshtml: Return failure in IHTMLDocument2::get_URL for detached documents.
---
dlls/mshtml/htmldoc.c | 10 +++++++++- dlls/mshtml/tests/navigation.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 9f9791c3b1e..504e0b9fc10 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1108,7 +1108,15 @@ static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", iface, p);
- *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank"); + if(This->window && !This->window->base.outer_window) { + WARN("detached document\n"); + return E_FAIL; + } + + if(This->window && This->window->base.outer_window->url) + *p = SysAllocString(This->window->base.outer_window->url); + else + *p = SysAllocString(L"about:blank"); return *p ? S_OK : E_OUTOFMEMORY; }
diff --git a/dlls/mshtml/tests/navigation.js b/dlls/mshtml/tests/navigation.js index 668ee78245b..71bda9ea2a5 100644 --- a/dlls/mshtml/tests/navigation.js +++ b/dlls/mshtml/tests/navigation.js @@ -119,7 +119,7 @@ function detached_iframe_doc() { expect_exception(function() { origDoc.onclick; }, true); expect_exception(function() { origDoc.toString; }, true); expect_exception(function() { origDoc.toString(); }, true); - expect_exception(function() { origDoc.URL; }, true); + expect_exception(function() { origDoc.URL; });
next_test(); });