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

mshtml: Implement url prop for StorageEvent.

parent 79703048
......@@ -2616,6 +2616,7 @@ typedef struct {
BSTR key;
BSTR old_value;
BSTR new_value;
BSTR url;
} DOMStorageEvent;
static inline DOMStorageEvent *impl_from_IDOMStorageEvent(IDOMStorageEvent *iface)
......@@ -2710,8 +2711,13 @@ static HRESULT WINAPI DOMStorageEvent_get_newValue(IDOMStorageEvent *iface, BSTR
static HRESULT WINAPI DOMStorageEvent_get_url(IDOMStorageEvent *iface, BSTR *p)
{
DOMStorageEvent *This = impl_from_IDOMStorageEvent(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, p);
if(This->url)
return (*p = SysAllocStringLen(This->url, SysStringLen(This->url))) ? S_OK : E_OUTOFMEMORY;
*p = NULL;
return S_OK;
}
static HRESULT WINAPI DOMStorageEvent_get_storageArea(IDOMStorageEvent *iface, IHTMLStorage **p)
......@@ -2766,6 +2772,7 @@ static void DOMStorageEvent_destroy(DOMEvent *event)
SysFreeString(storage_event->key);
SysFreeString(storage_event->old_value);
SysFreeString(storage_event->new_value);
SysFreeString(storage_event->url);
}
static const tid_t DOMEvent_iface_tids[] = {
......@@ -3120,7 +3127,7 @@ HRESULT create_message_event(HTMLDocumentNode *doc, VARIANT *data, DOMEvent **re
}
HRESULT create_storage_event(HTMLDocumentNode *doc, BSTR key, BSTR old_value, BSTR new_value,
BOOL commit, DOMEvent **ret)
const WCHAR *url, BOOL commit, DOMEvent **ret)
{
DOMStorageEvent *storage_event;
DOMEvent *event;
......@@ -3140,6 +3147,11 @@ HRESULT create_storage_event(HTMLDocumentNode *doc, BSTR key, BSTR old_value, BS
}
}
if(url && !(storage_event->url = SysAllocString(url))) {
IDOMEvent_Release(&event->IDOMEvent_iface);
return E_OUTOFMEMORY;
}
*ret = event;
return S_OK;
}
......
......@@ -114,7 +114,7 @@ HRESULT create_document_event(HTMLDocumentNode*,eventid_t,DOMEvent**) DECLSPEC_H
HRESULT create_document_event_str(HTMLDocumentNode*,const WCHAR*,IDOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_event_from_nsevent(nsIDOMEvent*,compat_mode_t,DOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_message_event(HTMLDocumentNode*,VARIANT*,DOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_storage_event(HTMLDocumentNode*,BSTR,BSTR,BSTR,BOOL,DOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_storage_event(HTMLDocumentNode*,BSTR,BSTR,BSTR,const WCHAR*,BOOL,DOMEvent**) DECLSPEC_HIDDEN;
void init_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void release_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
......
......@@ -235,6 +235,7 @@ struct send_storage_event_ctx {
BSTR key;
BSTR old_value;
BSTR new_value;
const WCHAR *url;
};
static HRESULT push_storage_event_task(struct send_storage_event_ctx *ctx, HTMLInnerWindow *window, BOOL commit)
......@@ -243,7 +244,7 @@ static HRESULT push_storage_event_task(struct send_storage_event_ctx *ctx, HTMLI
DOMEvent *event;
HRESULT hres;
hres = create_storage_event(window->doc, ctx->key, ctx->old_value, ctx->new_value, commit, &event);
hres = create_storage_event(window->doc, ctx->key, ctx->old_value, ctx->new_value, ctx->url, commit, &event);
if(FAILED(hres))
return hres;
......@@ -327,6 +328,7 @@ static HRESULT send_storage_event(HTMLStorage *storage, BSTR key, BSTR old_value
goto done;
get_top_window(window->base.outer_window, &top_window);
ctx.url = window->base.outer_window->url;
ctx.key = key;
ctx.old_value = old_value;
ctx.new_value = new_value;
......
......@@ -1322,7 +1322,7 @@ async_test("storage events", function() {
}
}
function test_event(e, key, oldValue, newValue) {
function test_event(e, idx, key, oldValue, newValue) {
if(v < 9) {
ok(e === undefined, "event not undefined in legacy mode: " + e);
return;
......@@ -1333,6 +1333,8 @@ async_test("storage events", function() {
ok(e.key === key, "key = " + e.key + ", expected " + key);
ok(e.oldValue === oldValue, "oldValue = " + e.oldValue + ", expected " + oldValue);
ok(e.newValue === newValue, "newValue = " + e.newValue + ", expected " + newValue);
s = (idx ? iframe.contentWindow : window)["location"]["href"];
ok(e.url === s, "url = " + e.url + ", expected " + s);
}
function expect(idx, key, oldValue, newValue, quirk) {
......@@ -1352,10 +1354,10 @@ async_test("storage events", function() {
(v < 9 ? document2 : window2)["onstorage"] = function(e) {
(local && idx ? document2 : (local || v < 9 ? document : window))[local ? "onstoragecommit" : "onstorage"] = function(e) {
test_event(e, local ? "" : key, local ? "" : oldValue, local ? "" : newValue);
test_event(e, idx, local ? "" : key, local ? "" : oldValue, local ? "" : newValue);
next();
}
test_event(e, key, oldValue, newValue);
test_event(e, idx, key, oldValue, newValue);
}
}
}
......
......@@ -2925,6 +2925,11 @@ static void test_storage_event(DISPPARAMS *params, BOOL doc_onstorage)
"newValue = %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
hres = IDOMStorageEvent_get_url(event, &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);
IDOMStorageEvent_Release(event);
}
......
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