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

mshtml: Implement ProgressEvent's initProgressEvent method.

parent 14db082f
......@@ -2583,6 +2583,7 @@ typedef struct {
DOMEvent event;
IDOMProgressEvent IDOMProgressEvent_iface;
nsIDOMProgressEvent *nsevent;
BOOL manual_init;
} DOMProgressEvent;
static inline DOMProgressEvent *impl_from_IDOMProgressEvent(IDOMProgressEvent *iface)
......@@ -2670,7 +2671,7 @@ static HRESULT WINAPI DOMProgressEvent_get_total(IDOMProgressEvent *iface, ULONG
TRACE("(%p)->(%p)\n", This, p);
if(NS_FAILED(nsIDOMProgressEvent_GetLengthComputable(This->nsevent, &b)) || !b) {
if(!This->manual_init && (NS_FAILED(nsIDOMProgressEvent_GetLengthComputable(This->nsevent, &b)) || !b)) {
*p = ~0;
return S_OK;
}
......@@ -2683,9 +2684,30 @@ static HRESULT WINAPI DOMProgressEvent_initProgressEvent(IDOMProgressEvent *ifac
ULONGLONG loaded, ULONGLONG total)
{
DOMProgressEvent *This = impl_from_IDOMProgressEvent(iface);
FIXME("(%p)->(%s %x %x %x %s %s)\n", This, debugstr_w(type), can_bubble, cancelable, lengthComputable,
nsAString type_str;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%s %x %x %x %s %s)\n", This, debugstr_w(type), can_bubble, cancelable, lengthComputable,
wine_dbgstr_longlong(loaded), wine_dbgstr_longlong(total));
return E_NOTIMPL;
if(This->event.target) {
TRACE("called on already dispatched event\n");
return S_OK;
}
hres = IDOMEvent_initEvent(&This->event.IDOMEvent_iface, type, can_bubble, cancelable);
if(SUCCEEDED(hres)) {
nsAString_InitDepend(&type_str, type);
nsres = nsIDOMProgressEvent_InitProgressEvent(This->nsevent, &type_str, !!can_bubble, !!cancelable,
!!lengthComputable, loaded, total);
nsAString_Finish(&type_str);
if(NS_FAILED(nsres))
return map_nsresult(nsres);
This->manual_init = TRUE;
}
return hres;
}
static const IDOMProgressEventVtbl DOMProgressEventVtbl = {
......
......@@ -2095,3 +2095,16 @@ sync_test("matchMedia", function() {
mql = window.matchMedia("(max-width: 1000px)");
ok(mql.matches === true, "(max-width: 1000px) does not match");
});
sync_test("initProgressEvent", function() {
var e = document.createEvent("ProgressEvent");
e.initProgressEvent("loadend", false, false, true, 13, 42);
ok(e.lengthComputable === true, "lengthComputable = " + e.lengthComputable);
ok(e.loaded === 13, "loaded = " + e.loaded);
ok(e.total === 42, "total = " + e.total);
e.initProgressEvent("loadstart", false, false, false, 99, 50);
ok(e.lengthComputable === false, "lengthComputable after re-init = " + e.lengthComputable);
ok(e.loaded === 99, "loaded after re-init = " + e.loaded);
ok(e.total === 50, "total after re-init = " + e.total);
});
......@@ -319,6 +319,11 @@ function test_timeout() {
ok(e.lengthComputable === false, "lengthComputable = " + e.lengthComputable);
ok(e.loaded === 0, "loaded = " + e.loaded);
ok(e.total === 18446744073709552000, "total = " + e.total);
e.initProgressEvent("timeout", false, false, true, 13, 42);
ok(e.lengthComputable === false, "lengthComputable after initProgressEvent = " + e.lengthComputable);
ok(e.loaded === 0, "loaded after initProgressEvent = " + e.loaded);
ok(e.total === 18446744073709552000, "total after initProgressEvent = " + e.total);
}
next_test();
}
......
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