Commit d9876902 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

Added support for shadowing of element pseudo-variables.

parent 34b41084
......@@ -480,6 +480,19 @@ HRESULT dispex_get_dprop_ref(DispatchEx *This, const WCHAR *name, BOOL alloc, VA
return S_OK;
}
HRESULT dispex_get_dynid(DispatchEx *This, const WCHAR *name, DISPID *id)
{
dynamic_prop_t *prop;
HRESULT hres;
hres = get_dynamic_prop(This, name, fdexNameEnsure, &prop);
if(FAILED(hres))
return hres;
*id = DISPID_DYNPROP_0 + (prop - This->dynamic_data->props);
return S_OK;
}
static HRESULT dispex_value(DispatchEx *This, LCID lcid, WORD flags, DISPPARAMS *params,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
......
......@@ -2461,21 +2461,40 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
IDispatch_Release(disp);
break;
}
case GLOBAL_ELEMENTVAR: {
IHTMLElement *elem;
case GLOBAL_ELEMENTVAR:
switch(flags) {
case DISPATCH_PROPERTYGET: {
IHTMLElement *elem;
hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
prop->name, &elem);
if(FAILED(hres))
return hres;
hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
prop->name, &elem);
if(FAILED(hres))
return hres;
if(!elem)
return DISP_E_MEMBERNOTFOUND;
if(!elem)
return DISP_E_MEMBERNOTFOUND;
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)elem;
break;
}
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)elem;
return S_OK;
}
case DISPATCH_PROPERTYPUT: {
DISPID dispex_id;
hres = dispex_get_dynid(&This->dispex, prop->name, &dispex_id);
if(FAILED(hres))
return hres;
prop->type = GLOBAL_DISPEXVAR;
prop->id = dispex_id;
return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, dispex_id, 0, flags, params, res, ei, caller);
}
default:
FIXME("Not suppoted 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:
ERR("invalid type %d\n", prop->type);
hres = DISP_E_MEMBERNOTFOUND;
......
......@@ -229,6 +229,7 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN;
HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**) DECLSPEC_HIDDEN;
HRESULT get_dispids(tid_t,DWORD*,DISPID**) DECLSPEC_HIDDEN;
HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*) DECLSPEC_HIDDEN;
HRESULT dispex_get_dynid(DispatchEx*,const WCHAR*,DISPID*) DECLSPEC_HIDDEN;
void release_typelib(void) DECLSPEC_HIDDEN;
HRESULT get_htmldoc_classinfo(ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
......@@ -248,7 +249,8 @@ typedef struct ScriptHost ScriptHost;
typedef enum {
GLOBAL_SCRIPTVAR,
GLOBAL_ELEMENTVAR
GLOBAL_ELEMENTVAR,
GLOBAL_DISPEXVAR
} global_prop_type_t;
typedef struct {
......
......@@ -60,6 +60,14 @@ function test_document_name_as_index() {
var e = document.getElementById("formid");
ok(!!e, "e is null");
ok(!("formid" in document), "formid is in document");
document.body.innerHTML = '<form name="formname"></form>';
ok("formname" in window, "formname' is not in window");
ok(typeof(window.formname) === "object", "typeof(window.formname) = " + typeof(window.formname));
window.formname = 1;
ok(window.formname === 1, "window.formname = " + window.formname);
formname = 2;
ok(window.formname === 2, "window.formname = " + window.formname);
}
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