· the PerformanceTiming interface
· the PerformanceNavigation interface
· the window.performance attribute
Process
Processing Model
All the attributes in window.performance.timing and window.performance.navigation should not be written to until the Window object of the current document is created, even though their attributes are referred to in the following steps to facilitate description.
User agents may provide users the option of disabling the window.performance.timing and window.performance.navigation interfaces.
When these interfaces are disabled, both window.performance.timing and window.performance.navigation must return a null value.
Example
A user agent may maintain instances of the PerformanceTiming and PerformanceNavigation interfaces until the Window object associated with the current document is created, when window.performance.timing and window.performance.navigation are replaced with these instances.
ILLUSTRATION
This illustration is non-normative.
The following graph illustrates the timing attributes defined by the PerformanceTiming interface and the PerformanceNavigation interface with or without redirect, respectively. Attributes underlined may not be available in navigation involving documents from different origins. User agents may perform internal processing in between timings, which allow for non-normative intervals between timings.
-
If the navigation is aborted for any of the following reasons, abort these steps without changing the attributes in window.performance.timing and window.performance.navigation
-
The navigation is aborted due to the sandboxed navigation browsing context flag or the sandboxed top-level navigation browsing context flag, or a preexist attempt to navigate the browsing context.
-
The navigation is caused by fragment identifiers within the page.
-
The new resource is to be handled by some sort of inline content.
-
The new resource is to be handled using a mechanism that does not affect the browsing context.
-
Immediately after the user agent prompts to unload the previous document, record the current time as navigationStart.
-
Record the current navigation type in window.performance.navigation.type if it has not been set:
-
If the navigation was started by clicking on a link, or entering the URL in the user agent's address bar, or form submission, or initializing through a script operation other than the location.reload() method, let the navigation type be TYPE_NAVIGATE.
-
If the navigation was started either as a result of a meta refresh, or the location.reload() method, or other equivalent actions, let the navigation type be TYPE_RELOAD.
-
If the navigation was started as a result of history traversal, let the navigation type be TYPE_BACK_FORWARD.
-
Otherwise, let the navigation type be TYPE_RESERVED.
-
If the current document and the previous document are from different origins, set both unloadEventStart and unloadEventEnd to 0 then go to step 6. Otherwise, record unloadEventStart as the time immediately before the unload event.
-
Immediately after the unload event is completed, record the current time as unloadEventEnd.
-
If the new resource is to be fetched using HTTP GET or equivalent, immediately before a user agent checks with the relevant application caches, record the current time as fetchStart. Otherwise, immediately before a user agent starts the fetching process, record the current time as fetchStart.
-
Let domainLookupStart, domainLookupEnd, connectStart and connectEnd be the same value as fetchStart.
-
If the resource is fetched from the relevant application cache or local resources, including the HTTP cache, go to step 13.
-
If no domain lookup is required, go to step 11. Otherwise, immediately before a user agent starts the domain name lookup, record the time as domainLookupStart.
-
Record the time as domainLookupEnd immediately after the domain name lookup is successfully done. A user agent may need multiple retries before that. If the domain lookup fails, abort the rest of the steps.
-
If a persistent transport connection is used to fetch the resource, let connectStart and connectEnd be the same value of domainLookupEnd. Otherwise, record the time as connectStart immediately before initiating the connection to the server and record the time as connectEnd immediately after the connection to the server or the proxy is established. A user agent may need multiple retries before this time. If a connection can not be established, abort the rest of the steps.
-
In step 11, a user agent should also carry out these additional steps if it supports the secureConnectionStart attribute:
-
If the scheme of the current document is HTTPS, the user agent must record the time as secureConnectionStart immediately before the handshake process to secure the connection.
-
If the scheme of the current document is not HTTPS, the user agent must set the value of secureConnectionStart to 0.
-
Immediately before a user agent starts sending request for the document, record the current time as requestStart.
-
Record the time as responseStart immediately after the user agent receives the first byte of the response.
-
Record the time as responseEnd immediately after receiving the last byte of the response.
Return to step 11 if the user agent fails to send the request or receive the entire response, and needs to reopen the connection.
Example
When persistent connection [RFC 2616] is enabled, a user agent may first try to re-use an open connect to send the request while the connection can be asynchronously closed. In such case, connectStart, connectEnd and requestStart should represent timing information collected over the re-open connection.
-
If the fetched resource results in an HTTP redirect or equivalent, then
-
if the current document and the document that is redirected to are not from the same origin, set redirectStart, redirectEnd, unloadEventStart, unloadEventEnd and redirectCount to 0. Then, return to step 6 with the new resource.
-
if there is previous redirect involving documents that are not from the same origin, set redirectStart, redirectEnd, unloadEventStart, unloadEventStart and redirectCount to 0. Then, return to step 6 with the new resource.
-
Increment redirectCount by 1.
-
If the value of redirectStart is 0, let it be the value of fetchStart.
-
Let redirectEnd be the value of responseEnd.
-
Set all the attributes in window.performance.timing to 0 except navigationStart, redirectStart, redirectEnd, unloadEventStart and unloadEventEnd.
-
Return to step 6 with the new resource.
-
Record the time as domLoading immediately before the user agent sets the current document readiness to "loading".
-
Record the time as domInteractive immediately before the user agent sets the current document readiness to "interactive".
-
Record the time as domContentLoadedEventStart immediately before the user agent fires the DOMContentLoaded event at the document.
-
Record the time as domContentLoadedEventEnd immediately after the DOMContentLoaded event completes.
-
Record the time as domComplete immediately before the user agent sets the current document readiness to "complete".
-
Record the time as loadEventStart immediately before the user agent fires the load event.
-
Record the time as loadEventEnd immediately after the user agent completes the load event.