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

mshtml: Implement performance.timing.unloadEventStart & unloadEventEnd.

parent 5db7d0d0
...@@ -4125,6 +4125,9 @@ HRESULT create_outer_window(GeckoBrowser *browser, mozIDOMWindowProxy *mozwindow ...@@ -4125,6 +4125,9 @@ HRESULT create_outer_window(GeckoBrowser *browser, mozIDOMWindowProxy *mozwindow
return hres; return hres;
} }
/* Initial empty doc does not have unload events or timings */
window->base.inner_window->doc->unload_sent = TRUE;
if(parent) { if(parent) {
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface); IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
......
...@@ -510,6 +510,8 @@ typedef struct { ...@@ -510,6 +510,8 @@ typedef struct {
LONG ref; LONG ref;
ULONGLONG navigation_start_time; ULONGLONG navigation_start_time;
ULONGLONG unload_event_start_time;
ULONGLONG unload_event_end_time;
ULONGLONG redirect_time; ULONGLONG redirect_time;
} HTMLPerformanceTiming; } HTMLPerformanceTiming;
......
...@@ -384,6 +384,7 @@ static nsresult NSAPI handle_unload(nsIDOMEventListener *iface, nsIDOMEvent *nse ...@@ -384,6 +384,7 @@ static nsresult NSAPI handle_unload(nsIDOMEventListener *iface, nsIDOMEvent *nse
{ {
nsEventListener *This = impl_from_nsIDOMEventListener(iface); nsEventListener *This = impl_from_nsIDOMEventListener(iface);
HTMLDocumentNode *doc = This->This->doc; HTMLDocumentNode *doc = This->This->doc;
HTMLPerformanceTiming *timing = NULL;
HTMLInnerWindow *window; HTMLInnerWindow *window;
DOMEvent *event; DOMEvent *event;
HRESULT hres; HRESULT hres;
...@@ -392,12 +393,21 @@ static nsresult NSAPI handle_unload(nsIDOMEventListener *iface, nsIDOMEvent *nse ...@@ -392,12 +393,21 @@ static nsresult NSAPI handle_unload(nsIDOMEventListener *iface, nsIDOMEvent *nse
return NS_OK; return NS_OK;
doc->unload_sent = TRUE; doc->unload_sent = TRUE;
if(window->base.outer_window->pending_window)
timing = window->base.outer_window->pending_window->performance_timing;
if(timing)
timing->unload_event_start_time = get_time_stamp();
hres = create_event_from_nsevent(nsevent, dispex_compat_mode(&doc->node.event_target.dispex), &event); hres = create_event_from_nsevent(nsevent, dispex_compat_mode(&doc->node.event_target.dispex), &event);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
dispatch_event(&window->event_target, event); dispatch_event(&window->event_target, event);
IDOMEvent_Release(&event->IDOMEvent_iface); IDOMEvent_Release(&event->IDOMEvent_iface);
} }
if(timing)
timing->unload_event_end_time = get_time_stamp();
return NS_OK; return NS_OK;
} }
......
...@@ -1601,9 +1601,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_unloadEventStart(IHTMLPerformanc ...@@ -1601,9 +1601,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_unloadEventStart(IHTMLPerformanc
{ {
HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface); 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->unload_event_start_time;
return S_OK; return S_OK;
} }
...@@ -1611,9 +1611,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_unloadEventEnd(IHTMLPerformanceT ...@@ -1611,9 +1611,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_unloadEventEnd(IHTMLPerformanceT
{ {
HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface); 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->unload_event_end_time;
return S_OK; return S_OK;
} }
......
...@@ -20,6 +20,8 @@ var compat_version; ...@@ -20,6 +20,8 @@ var compat_version;
var tests = []; var tests = [];
ok(performance.timing.navigationStart > 0, "navigationStart <= 0"); ok(performance.timing.navigationStart > 0, "navigationStart <= 0");
ok(performance.timing.unloadEventStart === 0, "unloadEventStart != 0");
ok(performance.timing.unloadEventEnd === 0, "unloadEventEnd != 0");
ok(performance.timing.redirectStart === 0, "redirectStart != 0"); ok(performance.timing.redirectStart === 0, "redirectStart != 0");
var pageshow_fired = false, pagehide_fired = false; var pageshow_fired = false, pagehide_fired = false;
......
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