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

mshtml: Implement performance.timing.domContentLoadedEventStart & End.

parent e0cda0e1
......@@ -117,7 +117,7 @@ typedef struct {
/* Keep these sorted case sensitively */
static const event_info_t event_info[] = {
{L"DOMContentLoaded", EVENT_TYPE_EVENT, 0,
EVENT_DEFAULTLISTENER | EVENT_BUBBLES | EVENT_CANCELABLE},
EVENT_BUBBLES | EVENT_CANCELABLE},
{L"abort", EVENT_TYPE_EVENT, DISPID_EVMETH_ONABORT,
EVENT_BIND_TO_TARGET},
{L"animationend", EVENT_TYPE_EVENT, DISPID_EVPROP_ONANIMATIONEND,
......
......@@ -520,6 +520,8 @@ typedef struct {
ULONGLONG response_end_time;
ULONGLONG dom_interactive_time;
ULONGLONG dom_complete_time;
ULONGLONG dom_content_loaded_event_start_time;
ULONGLONG dom_content_loaded_event_end_time;
} HTMLPerformanceTiming;
typedef struct nsChannelBSC nsChannelBSC;
......
......@@ -56,6 +56,7 @@ typedef struct {
static nsresult NSAPI handle_blur(nsIDOMEventListener*,nsIDOMEvent*);
static nsresult NSAPI handle_focus(nsIDOMEventListener*,nsIDOMEvent*);
static nsresult NSAPI handle_keypress(nsIDOMEventListener*,nsIDOMEvent*);
static nsresult NSAPI handle_dom_content_loaded(nsIDOMEventListener*,nsIDOMEvent*);
static nsresult NSAPI handle_pageshow(nsIDOMEventListener*,nsIDOMEvent*);
static nsresult NSAPI handle_pagehide(nsIDOMEventListener*,nsIDOMEvent*);
static nsresult NSAPI handle_load(nsIDOMEventListener*,nsIDOMEvent*);
......@@ -75,10 +76,11 @@ static const struct {
{ EVENTID_BLUR, 0, EVENTLISTENER_VTBL(handle_blur) },
{ EVENTID_FOCUS, 0, EVENTLISTENER_VTBL(handle_focus) },
{ EVENTID_KEYPRESS, BUBBLES, EVENTLISTENER_VTBL(handle_keypress) },
{ EVENTID_PAGESHOW, OVERRIDE, EVENTLISTENER_VTBL(handle_pageshow), },
{ EVENTID_PAGEHIDE, OVERRIDE, EVENTLISTENER_VTBL(handle_pagehide), },
{ EVENTID_LOAD, OVERRIDE, EVENTLISTENER_VTBL(handle_load), },
{ EVENTID_BEFOREUNLOAD, OVERRIDE, EVENTLISTENER_VTBL(handle_beforeunload), },
{ EVENTID_DOMCONTENTLOADED, OVERRIDE, EVENTLISTENER_VTBL(handle_dom_content_loaded) },
{ EVENTID_PAGESHOW, OVERRIDE, EVENTLISTENER_VTBL(handle_pageshow) },
{ EVENTID_PAGEHIDE, OVERRIDE, EVENTLISTENER_VTBL(handle_pagehide) },
{ EVENTID_LOAD, OVERRIDE, EVENTLISTENER_VTBL(handle_load) },
{ EVENTID_BEFOREUNLOAD, OVERRIDE, EVENTLISTENER_VTBL(handle_beforeunload) },
{ EVENTID_UNLOAD, OVERRIDE, EVENTLISTENER_VTBL(handle_unload) },
};
......@@ -216,6 +218,31 @@ static nsresult NSAPI handle_keypress(nsIDOMEventListener *iface,
return NS_OK;
}
static nsresult NSAPI handle_dom_content_loaded(nsIDOMEventListener *iface, nsIDOMEvent *nsevent)
{
nsEventListener *This = impl_from_nsIDOMEventListener(iface);
HTMLDocumentNode *doc = This->This->doc;
DOMEvent *event;
HRESULT hres;
if(!doc)
return NS_OK;
if(doc->window)
doc->window->performance_timing->dom_content_loaded_event_start_time = get_time_stamp();
hres = create_event_from_nsevent(nsevent, dispex_compat_mode(&doc->node.event_target.dispex), &event);
if(SUCCEEDED(hres)) {
dispatch_event(&doc->node.event_target, event);
IDOMEvent_Release(&event->IDOMEvent_iface);
}
if(doc->window)
doc->window->performance_timing->dom_content_loaded_event_end_time = get_time_stamp();
return NS_OK;
}
static nsresult NSAPI handle_pageshow(nsIDOMEventListener *iface, nsIDOMEvent *nsevent)
{
nsEventListener *This = impl_from_nsIDOMEventListener(iface);
......
......@@ -1766,9 +1766,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_domContentLoadedEventStart(IHTML
{
HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
FIXME("(%p)->(%p) returning fake value\n", This, p);
TRACE("(%p)->(%p)\n", This, p);
*p = TIMING_FAKE_TIMESTAMP;
*p = This->dom_content_loaded_event_start_time;
return S_OK;
}
......@@ -1776,9 +1776,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_domContentLoadedEventEnd(IHTMLPe
{
HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
FIXME("(%p)->(%p) returning fake value\n", This, p);
TRACE("(%p)->(%p)\n", This, p);
*p = TIMING_FAKE_TIMESTAMP;
*p = This->dom_content_loaded_event_end_time;
return S_OK;
}
......
......@@ -31,6 +31,8 @@ ok(performance.timing.responseEnd >= performance.timing.responseStart, "response
ok(performance.timing.domLoading >= performance.timing.responseEnd, "domLoading < responseEnd");
ok(performance.timing.domInteractive === 0, "domInteractive != 0");
ok(performance.timing.domComplete === 0, "domComplete != 0");
ok(performance.timing.domContentLoadedEventStart === 0, "domContentLoadedEventStart != 0");
ok(performance.timing.domContentLoadedEventEnd === 0, "domContentLoadedEventEnd != 0");
ok(performance.timing.unloadEventStart === 0, "unloadEventStart != 0");
ok(performance.timing.unloadEventEnd === 0, "unloadEventEnd != 0");
ok(performance.timing.redirectStart === 0, "redirectStart != 0");
......@@ -79,7 +81,9 @@ if(window.addEventListener) {
sync_test("performance timing", function() {
ok(performance.timing.domInteractive >= performance.timing.domLoading, "domInteractive < domLoading");
ok(performance.timing.domComplete >= performance.timing.domInteractive, "domComplete < domInteractive");
ok(performance.timing.domContentLoadedEventStart >= performance.timing.domInteractive, "domContentLoadedEventStart < domInteractive");
ok(performance.timing.domContentLoadedEventEnd >= performance.timing.domContentLoadedEventStart, "domContentLoadedEventEnd < domContentLoadedEventStart");
ok(performance.timing.domComplete >= performance.timing.domContentLoadedEventEnd, "domComplete < domContentLoadedEventEnd");
});
sync_test("page transition events", function() {
......
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