Module: wine Branch: master Commit: 0118f3608fbbe7d4a80392be844cfa84711acefb URL: https://gitlab.winehq.org/wine/wine/-/commit/0118f3608fbbe7d4a80392be844cfa8...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Tue Nov 22 18:26:22 2022 +0200
mshtml: Implement the remaining pre-response performance.timing props.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/mshtml/mshtml_private.h | 3 +++ dlls/mshtml/navigate.c | 12 +++++++++ dlls/mshtml/omnavigator.c | 52 ++++++++++++++++++++++++++++----------- dlls/mshtml/tests/documentmode.js | 7 ++++++ 4 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index ef21507d553..6fe28252f64 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -513,6 +513,9 @@ typedef struct { ULONGLONG unload_event_start_time; ULONGLONG unload_event_end_time; ULONGLONG redirect_time; + ULONGLONG dns_lookup_time; + ULONGLONG connect_time; + ULONGLONG request_time; } HTMLPerformanceTiming;
typedef struct nsChannelBSC nsChannelBSC; diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index f53348b7721..fe3c823d508 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -1720,6 +1720,18 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG progress, ULONG t if(This->is_doc_channel && !This->bsc.window->performance_timing->redirect_time) This->bsc.window->performance_timing->redirect_time = get_time_stamp(); return handle_redirect(This, status_text); + case BINDSTATUS_FINDINGRESOURCE: + if(This->is_doc_channel && !This->bsc.window->performance_timing->dns_lookup_time) + This->bsc.window->performance_timing->dns_lookup_time = get_time_stamp(); + break; + case BINDSTATUS_CONNECTING: + if(This->is_doc_channel) + This->bsc.window->performance_timing->connect_time = get_time_stamp(); + break; + case BINDSTATUS_SENDINGREQUEST: + if(This->is_doc_channel) + This->bsc.window->performance_timing->request_time = get_time_stamp(); + break; case BINDSTATUS_BEGINDOWNLOADDATA: { IWinInetHttpInfo *http_info; DWORD status, size = sizeof(DWORD); diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 194d3a7a931..630ba7fad27 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -1587,6 +1587,24 @@ static HRESULT WINAPI HTMLPerformanceTiming_Invoke(IHTMLPerformanceTiming *iface
#define TIMING_FAKE_TIMESTAMP 0xdeadbeef
+static ULONGLONG get_fetch_time(HTMLPerformanceTiming *This) +{ + /* If there's no prior doc unloaded and no redirects, fetch time == navigationStart time */ + if(!This->unload_event_end_time && !This->redirect_time) + return This->navigation_start_time; + + if(This->dns_lookup_time) + return This->dns_lookup_time; + if(This->connect_time) + return This->connect_time; + if(This->request_time) + return This->request_time; + if(This->unload_event_end_time) + return This->unload_event_end_time; + + return This->redirect_time; +} + static HRESULT WINAPI HTMLPerformanceTiming_get_navigationStart(IHTMLPerformanceTiming *iface, ULONGLONG *p) { HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface); @@ -1631,9 +1649,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_redirectEnd(IHTMLPerformanceTimi { 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->redirect_time ? get_fetch_time(This) : 0; return S_OK; }
@@ -1641,9 +1659,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_fetchStart(IHTMLPerformanceTimin { 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 = get_fetch_time(This); return S_OK; }
@@ -1651,9 +1669,9 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_domainLookupStart(IHTMLPerforman { 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->dns_lookup_time ? This->dns_lookup_time : get_fetch_time(This); return S_OK; }
@@ -1661,9 +1679,10 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_domainLookupEnd(IHTMLPerformance { 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->connect_time ? This->connect_time : + This->dns_lookup_time ? This->dns_lookup_time : get_fetch_time(This); return S_OK; }
@@ -1671,9 +1690,10 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_connectStart(IHTMLPerformanceTim { 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->connect_time ? This->connect_time : + This->dns_lookup_time ? This->dns_lookup_time : get_fetch_time(This); return S_OK; }
@@ -1681,9 +1701,11 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_connectEnd(IHTMLPerformanceTimin { 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->request_time ? This->request_time : + This->connect_time ? This->connect_time : + This->dns_lookup_time ? This->dns_lookup_time : get_fetch_time(This); return S_OK; }
@@ -1691,9 +1713,11 @@ static HRESULT WINAPI HTMLPerformanceTiming_get_requestStart(IHTMLPerformanceTim { 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->request_time ? This->request_time : + This->connect_time ? This->connect_time : + This->dns_lookup_time ? This->dns_lookup_time : get_fetch_time(This); return S_OK; }
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index a9c2b36ceee..e933ea0ff54 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -20,9 +20,16 @@ var compat_version; var tests = [];
ok(performance.timing.navigationStart > 0, "navigationStart <= 0"); +ok(performance.timing.fetchStart == performance.timing.navigationStart, "fetchStart != navigationStart"); +ok(performance.timing.domainLookupStart >= performance.timing.fetchStart, "domainLookupStart < fetchStart"); +ok(performance.timing.domainLookupEnd >= performance.timing.domainLookupStart, "domainLookupEnd < domainLookupStart"); +ok(performance.timing.connectStart >= performance.timing.domainLookupEnd, "connectStart < domainLookupEnd"); +ok(performance.timing.connectEnd >= performance.timing.connectStart, "connectEnd < connectStart"); +ok(performance.timing.requestStart >= performance.timing.connectEnd, "requestStart < connectEnd"); ok(performance.timing.unloadEventStart === 0, "unloadEventStart != 0"); ok(performance.timing.unloadEventEnd === 0, "unloadEventEnd != 0"); ok(performance.timing.redirectStart === 0, "redirectStart != 0"); +ok(performance.timing.redirectEnd === 0, "redirectEnd != 0");
var pageshow_fired = false, pagehide_fired = false; document.doc_unload_events_called = false;