This document describes the processing model and interface for the planned Web Timing implementation in WebKit.
Processing Model
Throughout these steps, the variables used must act as global within the context of their immediate parent frame.
When invoking the algorithm for navigating across documents, the user agent must act as follows:
1. If the new resource is to be fetched using HTTP GET or equivalent, then immediately prior to checking the relevant application caches, let navigation-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: This is currently step 5.5.1.11 which is not yet assigned an anchor id. This step occurs if and only if it has been determined that the navigation is not caused by a fragment identified, is not to be handled by inline content and is not to be handled using a mechanism that does not affect the browsing context. It also happens after the Prompt to unload the Document object.
Otherwise, if the resource is being fetched using a method other than one equivalent to HTTP's GET, or, if the navigation algorithm was invoked as a result of the form submission algorithm, then immediately prior to invoking the fetching algorithm, let navigation-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: This happens after the prompt to re-POST form data.
Note: In both the GET and POST case, navigation-start is set after any user agent specific prompts (e.g. for an interstitial page) have been confirmed.
2. Let unload-event-end be 0.
When invoking the algorithm to unload a document, the user agent must act as follows:
1. Immediately after firing a simple event named unload at the Document's Window object, let unload-event-end be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
When invoking the algorithm for fetching resources, the user agent must act as follows:
1. If the fetch is not for a main resource or subframe resource, then abort these steps.
2. Immediately before invoking the algorithm for fetching resources
1. Let fetch-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
2. Let redirect-count, redirect-start and redirect-end be 0.
3. If the resource does not require a download (e.g. local file or retrieved from the relevant application caches), then let domain-lookup-start, domain-lookup-end, connect-start, and connect-end be 0.
Otherwise, if the resource does not have a domain name (e.g. IP address, etc), then let domain-lookup-start and domain-lookup-end be 0.
Otherwise, immediately before beginning to resolve the domain name of the resource, let domain-lookup-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: Time spent in proxy resolution will elapse prior to domain-lookup-start.
4. Immediately after receiving the resolved domain name, let domain-lookup-end be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
5. If a persistent transport connection is used, then let connect-start and connect-end be 0.
Otherwise, if a new transport connection is established, then immediately before issuing the network request to establish the connection, let connect-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
6. Immediately after establishing a new transport connection, let connect-end be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
7. Immediately before beginning to send the request to the relevant subsystem (e.g. network, local file system, relevant application caches) for the content of the resource, let request-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: Delay due to contention for a connection will elapse after fetch-start and prior to request-start.
8. Immediately after finishing sending the request to the relevant subsystem (e.g. network, local file system, relevant application caches) for the content of the resource, let request-end be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
9. Immediately after receiving the complete HTTP headers, let response-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: Delay due to any HTTP authentication prompts will elapse after response-start and prior to response-end.
10. If the fetched resource is an HTTP redirect or equivalent, then
1. Increment redirect-count by 1.
2. Let redirect-start be the value of fetch-start.
3. Let redirect-end be the value of response-start.
4. Let fetch-start be the value of redirect-end.
5. Abort these steps.
11. Immediately after receiving the complete response, let response-end be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: Delay due to user prompts produced by the page (e.g. alert, prompt) will not block response-end.
When invoking the algorithm to stop parsing, the user agent must act as follows:
1. Immediately before firing a simple event named load at the Document's Window object, let load-event-start be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: Delay due to user prompts produced by the page (e.g. alert, prompt) may block load-event-start.
2. Immediately after firing a simple event named load at the Document's Window object, let load-event-end be the number of milliseconds between midnight of January 1, 1970 (UTC) and the current time.
Note: Delay due to user prompts produced during the onload handler (e.g. alert, prompt) will block load-event-end.
When invoking the algorithm for opening the input stream, the user agent must act as follows:
1. When replacing the Document's singleton objects with new instances of those objects
a. Replace Performance with a new instance.
b. Replace Performance’s Navigation and Timing objects with new instances.
Performance interface
interface Performance {
readonly attribute Timing timing;
readonly attribute Navigation navigation;
};
timing
Must return the Document's Timing instance.
navigation
Must return the Document's Navigation instance.
Navigation interface
interface Navigation {
const unsigned short NAVIGATE = 0;
const unsigned short RELOAD = 1;
const unsigned short BACK_FORWARD = 2;
readonly attribute unsigned short type;
readonly attribute unsigned short redirectCount;
};
type
Must return the 2 if the navigation was the result of a back or forward action, 1 if the navigation was the result of a reload action, or 0 otherwise.
redirectCount
Must return the current value of redirect-count.
Timing interface
interface Timing {
readonly attribute unsigned long long navigationStart;
readonly attribute unsigned long long unloadEventEnd;
readonly attribute unsigned long long redirectStart;
readonly attribute unsigned long long redirectEnd;
readonly attribute unsigned long long fetchStart;
readonly attribute unsigned long long domainLookupStart;
readonly attribute unsigned long long domainLookupEnd;
readonly attribute unsigned long long connectStart;
readonly attribute unsigned long long connectEnd;
readonly attribute unsigned long long requestStart;
readonly attribute unsigned long long requestEnd;
readonly attribute unsigned long long responseStart;
readonly attribute unsigned long long responseEnd;
readonly attribute unsigned long long loadEventStart;
readonly attribute unsigned long long loadEventEnd;
};
navigationStart
Must return the current value of navigation-start.
unloadEventEnd
Must return the current value of unload-event-end.
redirectStart
Must return the current value of redirect-start.
redirectEnd
Must return the current value of redirect-end.
fetchStart
Must return the current value of fetch-start.
domainLookupStart
Must return the current value of domain-lookup-start.
domainLookupEnd
Must return the current value of domain-lookup-end.
connectStart
Must return the current value of connect-start.
connectEnd
Must return the current value of connect-end.
requestStart
Must return the current value of request-start.
requestEnd
Must return the current value of request-end.
responseStart
Must return the current value of response-start.
responseEnd
Must return the current value of response-end.
loadEventStart
Must return the current value of load-event-start.
loadEventEnd
Must return the current value of load-event-end.
Non normative illustrations
Note: These should be turned into graphics.
Cold network load of 302 redirect from foo.com -> bar.com
A B C D E F G H I J K L
| | | |-dns-|-conn-|-req-|-resp-| | | |-dns-|-conn-|-req-|-resp-| | |
| |-unload-| |--------fetch foo.com--------| |--------fetch bar.com--------| |-load-|
|-------------------------------end user latency----------------------------------------|
A navigationStart
B unloadEventEnd
C redirectStart
D redirectEnd
E fetchStart
F domainLookupStart
G domainLookupEnd+connectStart
H connectEnd+requestStart
I requestEnd+responseStart
J responseEnd
K loadEventStart
L loadEventEnd
Cold network load of bar.com
A B C D E F G H I J
| | | |-dns-|-conn-|-req-|-resp-| | |
| |-unload-| |--------fetch bar.com--------| |-load-|
|--------------end user latency------------------------|
A navigationStart
B unloadEventEnd
C fetchStart
D domainLookupStart
E domainLookupEnd+connectStart
F connectEnd+requestStart
G requestEnd+responseStart
H responseEnd
I loadEventStart
J loadEventEnd
Note: More examples should be given, e.g. file system load, cached load, etc.