Commit 4ff0a824 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Properly expose frame and iframe element's windows to scripts.

parent 99d1c9ba
...@@ -2358,7 +2358,25 @@ static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, ...@@ -2358,7 +2358,25 @@ static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName,
if(hres != DISP_E_UNKNOWNNAME) if(hres != DISP_E_UNKNOWNNAME)
return hres; 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; global_prop_t *prop;
IHTMLElement *elem; IHTMLElement *elem;
...@@ -2603,6 +2621,30 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD ...@@ -2603,6 +2621,30 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
FIXME("Not supported flags: %x\n", flags); FIXME("Not supported flags: %x\n", flags);
return E_NOTIMPL; 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: case GLOBAL_DISPEXVAR:
return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller); return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller);
default: default:
......
...@@ -294,7 +294,8 @@ typedef struct ScriptHost ScriptHost; ...@@ -294,7 +294,8 @@ typedef struct ScriptHost ScriptHost;
typedef enum { typedef enum {
GLOBAL_SCRIPTVAR, GLOBAL_SCRIPTVAR,
GLOBAL_ELEMENTVAR, GLOBAL_ELEMENTVAR,
GLOBAL_DISPEXVAR GLOBAL_DISPEXVAR,
GLOBAL_FRAMEVAR
} global_prop_type_t; } global_prop_type_t;
typedef struct { typedef struct {
......
...@@ -68,6 +68,13 @@ function test_document_name_as_index() { ...@@ -68,6 +68,13 @@ function test_document_name_as_index() {
ok(window.formname === 1, "window.formname = " + window.formname); ok(window.formname === 1, "window.formname = " + window.formname);
formname = 2; formname = 2;
ok(window.formname === 2, "window.formname = " + window.formname); 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() { function test_remove_style_attribute() {
......
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