Module: wine Branch: master Commit: 4ff0a82416e61a99e7b30a0c4c2a525b008bff1a URL: http://source.winehq.org/git/wine.git/?a=commit;h=4ff0a82416e61a99e7b30a0c4c...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Sep 4 13:58:39 2012 +0200
mshtml: Properly expose frame and iframe element's windows to scripts.
---
dlls/mshtml/htmlwindow.c | 44 ++++++++++++++++++++++++++++++++++++++++- dlls/mshtml/mshtml_private.h | 3 +- dlls/mshtml/tests/jstest.html | 7 ++++++ 3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 2ec4a7f..2ed3ca7 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -2358,7 +2358,25 @@ static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, if(hres != DISP_E_UNKNOWNNAME) return hres;
- if(window->base.inner_window->doc) { + if(This->outer_window) { + HTMLOuterWindow *frame; + + hres = get_frame_by_name(This->outer_window, bstrName, FALSE, &frame); + if(SUCCEEDED(hres) && frame) { + global_prop_t *prop; + + IHTMLWindow2_Release(&frame->base.IHTMLWindow2_iface); + + prop = alloc_global_prop(window, GLOBAL_FRAMEVAR, bstrName); + if(!prop) + return E_OUTOFMEMORY; + + *pid = prop_to_dispid(window, prop); + return S_OK; + } + } + + if(window->doc) { global_prop_t *prop; IHTMLElement *elem;
@@ -2603,6 +2621,30 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD FIXME("Not supported flags: %x\n", flags); return E_NOTIMPL; } + case GLOBAL_FRAMEVAR: + if(!This->base.outer_window) + return E_UNEXPECTED; + + switch(flags) { + case DISPATCH_PROPERTYGET: { + HTMLOuterWindow *frame; + + hres = get_frame_by_name(This->base.outer_window, prop->name, FALSE, &frame); + if(FAILED(hres)) + return hres; + + if(!frame) + return DISP_E_MEMBERNOTFOUND; + + V_VT(res) = VT_DISPATCH; + V_DISPATCH(res) = (IDispatch*)&frame->base.inner_window->base.IHTMLWindow2_iface; + IDispatch_AddRef(V_DISPATCH(res)); + return S_OK; + } + default: + FIXME("Not supported flags: %x\n", flags); + return E_NOTIMPL; + } case GLOBAL_DISPEXVAR: return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller); default: diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index f23dc10..9f10382 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -294,7 +294,8 @@ typedef struct ScriptHost ScriptHost; typedef enum { GLOBAL_SCRIPTVAR, GLOBAL_ELEMENTVAR, - GLOBAL_DISPEXVAR + GLOBAL_DISPEXVAR, + GLOBAL_FRAMEVAR } global_prop_type_t;
typedef struct { diff --git a/dlls/mshtml/tests/jstest.html b/dlls/mshtml/tests/jstest.html index 99eca1a..d9d6da5 100644 --- a/dlls/mshtml/tests/jstest.html +++ b/dlls/mshtml/tests/jstest.html @@ -68,6 +68,13 @@ function test_document_name_as_index() { ok(window.formname === 1, "window.formname = " + window.formname); formname = 2; ok(window.formname === 2, "window.formname = " + window.formname); + + document.body.innerHTML = '<iframe id="iframeid"></iframe>'; + ok("iframeid" in window, "iframeid is not in window"); + e = document.getElementById("iframeid"); + ok(!!e, "e is null"); + ok(iframeid != e, "iframeid == e"); + ok(iframeid.frameElement === e, "frameid != e.contentWindow"); }
function test_remove_style_attribute() {