Commit 79a2fb71 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement `url` prop for StorageEvent objs.

parent cfefbb8f
......@@ -347,6 +347,20 @@ static DOMUIEvent *DOMUIEvent_from_DOMEvent(DOMEvent *event)
}
typedef struct {
DOMEvent event;
IDOMStorageEvent IDOMStorageEvent_iface;
BSTR key;
BSTR old_value;
BSTR new_value;
BSTR url;
} DOMStorageEvent;
static DOMStorageEvent *DOMStorageEvent_from_DOMEvent(DOMEvent *event)
{
return CONTAINING_RECORD(event, DOMStorageEvent, event);
}
typedef struct {
DispatchEx dispex;
IHTMLEventObj IHTMLEventObj_iface;
IHTMLEventObj2 IHTMLEventObj2_iface;
......@@ -1765,20 +1779,44 @@ static HRESULT WINAPI HTMLEventObj5_Invoke(IHTMLEventObj5 *iface, DISPID dispIdM
static HRESULT WINAPI HTMLEventObj5_put_url(IHTMLEventObj5 *iface, BSTR v)
{
HTMLEventObj *This = impl_from_IHTMLEventObj5(iface);
IDOMStorageEvent *storage_event;
DOMStorageEvent *p;
BSTR url;
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
return DISP_E_MEMBERNOTFOUND;
if(!v)
return E_POINTER;
if(!This->event || FAILED(IDOMEvent_QueryInterface(&This->event->IDOMEvent_iface, &IID_IDOMStorageEvent, (void**)&storage_event)))
return DISP_E_MEMBERNOTFOUND;
IDOMStorageEvent_Release(storage_event);
if(!(url = SysAllocString(v)))
return E_OUTOFMEMORY;
p = DOMStorageEvent_from_DOMEvent(This->event);
SysFreeString(p->url);
p->url = url;
return S_OK;
}
static HRESULT WINAPI HTMLEventObj5_get_url(IHTMLEventObj5 *iface, BSTR *p)
{
HTMLEventObj *This = impl_from_IHTMLEventObj5(iface);
IDOMStorageEvent *storage_event;
HRESULT hres;
FIXME("(%p)->(%p)\n", This, p);
TRACE("(%p)->(%p)\n", This, p);
*p = NULL;
return S_OK;
if(!This->event || FAILED(IDOMEvent_QueryInterface(&This->event->IDOMEvent_iface, &IID_IDOMStorageEvent, (void**)&storage_event))) {
*p = NULL;
return S_OK;
}
hres = IDOMStorageEvent_get_url(storage_event, p);
IDOMStorageEvent_Release(storage_event);
return hres;
}
static HRESULT WINAPI HTMLEventObj5_put_data(IHTMLEventObj5 *iface, BSTR v)
......@@ -3954,15 +3992,6 @@ static void DOMProgressEvent_unlink(DispatchEx *dispex)
unlink_ref(&This->nsevent);
}
typedef struct {
DOMEvent event;
IDOMStorageEvent IDOMStorageEvent_iface;
BSTR key;
BSTR old_value;
BSTR new_value;
BSTR url;
} DOMStorageEvent;
static inline DOMStorageEvent *impl_from_IDOMStorageEvent(IDOMStorageEvent *iface)
{
return CONTAINING_RECORD(iface, DOMStorageEvent, IDOMStorageEvent_iface);
......@@ -4097,11 +4126,6 @@ static const IDOMStorageEventVtbl DOMStorageEventVtbl = {
DOMStorageEvent_initStorageEvent
};
static DOMStorageEvent *DOMStorageEvent_from_DOMEvent(DOMEvent *event)
{
return CONTAINING_RECORD(event, DOMStorageEvent, event);
}
static void *DOMStorageEvent_query_interface(DispatchEx *dispex, REFIID riid)
{
DOMStorageEvent *storage_event = DOMStorageEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex));
......
......@@ -3872,9 +3872,11 @@ static void test_storage_event(DISPPARAMS *params, BOOL doc_onstorage)
{
const WCHAR *expect_key = onstorage_expect_key, *expect_old_value = onstorage_expect_old_value, *expect_new_value = onstorage_expect_new_value;
unsigned line = onstorage_expect_line;
IHTMLEventObj5 *event_obj5;
IHTMLEventObj *event_obj;
IDOMStorageEvent *event;
IDispatchEx *dispex;
IDispatch *disp;
HRESULT hres;
unsigned i;
DISPID id;
......@@ -3898,6 +3900,8 @@ static void test_storage_event(DISPPARAMS *params, BOOL doc_onstorage)
hres = IDispatchEx_QueryInterface(dispex, &IID_IHTMLEventObj, (void**)&event_obj);
ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLEventObj: %08lx\n", hres);
hres = IHTMLEventObj_QueryInterface(event_obj, &IID_IHTMLEventObj5, (void**)&event_obj5);
ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLEventObj5: %08lx\n", hres);
IHTMLEventObj_Release(event_obj);
for(i = 0; i < ARRAY_SIZE(props); i++) {
......@@ -3906,8 +3910,39 @@ static void test_storage_event(DISPPARAMS *params, BOOL doc_onstorage)
ok_(__FILE__,line)(hres == DISP_E_UNKNOWNNAME, "GetDispID(%s) failed: %08lx\n", wine_dbgstr_w(bstr), hres);
SysFreeString(bstr);
}
IDispatchEx_Release(dispex);
hres = IHTMLEventObj5_get_data(event_obj5, &bstr);
ok_(__FILE__,line)(hres == S_OK, "get_data failed: %08lx\n", hres);
ok_(__FILE__,line)(!bstr, "data = %s\n", wine_dbgstr_w(bstr));
hres = IHTMLEventObj5_get_origin(event_obj5, &bstr);
ok_(__FILE__,line)(hres == S_OK, "get_origin failed: %08lx\n", hres);
ok_(__FILE__,line)(!bstr, "origin = %s\n", wine_dbgstr_w(bstr));
hres = IHTMLEventObj5_get_source(event_obj5, &disp);
ok_(__FILE__,line)(hres == S_OK, "get_source failed: %08lx\n", hres);
ok_(__FILE__,line)(!disp, "source != NULL\n");
hres = IHTMLEventObj5_get_url(event_obj5, &bstr);
ok_(__FILE__,line)(hres == S_OK, "get_url failed: %08lx\n", hres);
ok_(__FILE__,line)(!wcscmp(bstr, L"http://winetest.example.org/"), "url = %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
bstr = SysAllocString(L"barfoo");
hres = IHTMLEventObj5_put_url(event_obj5, bstr);
ok_(__FILE__,line)(hres == S_OK, "put_url failed: %08lx\n", hres);
SysFreeString(bstr);
hres = IHTMLEventObj5_get_url(event_obj5, &bstr);
ok_(__FILE__,line)(hres == S_OK, "get_url after put failed: %08lx\n", hres);
ok_(__FILE__,line)(!wcscmp(bstr, L"barfoo"), "url after put = %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
hres = IHTMLEventObj5_put_url(event_obj5, NULL);
ok_(__FILE__,line)(hres == E_POINTER, "put_url NULL returned: %08lx\n", hres);
IHTMLEventObj5_Release(event_obj5);
return;
}
......
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