• Navigation Timing

  • Navigation Timing

  • Editor's Draft January 25th, 2013

  • This version:
  • Latest version:
  • Latest Editor's Draft:
  • Previous versions:
  • Editors:
  • Zhiheng Wang (Google Inc.)
  • Abstract

  • This specification defines an interface for web applications to access timing information related to navigation and elements.
  • 이 문서는 웹애플리케이션에서 네비게이션과 엘리먼트에 관계된 타이밍 정보에 접근하는 방법을 정의한다.
  • Status of this document

  • This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
  • This is a work in progress and may change without any notices.
  • Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
  • Table of Contents

  • 1 Introduction

  • This section is non-normative.
  • User latency is an important quality benchmark for Web Applications. While script-based mechanisms, such as the one described in [JSMEASURE], can provide comprehensive instrumentation for user latency measurements within an application, in many cases, they are unable to provide a complete end-to-end latency picture.
  • For example, the following script shows a naive attempt to measure the time it takes to fully load a page:
  • The script calculates the time it takes to load the page after the first bit of JavaScript in the head is executed, but it does not give any information about the time it takes to get the page from the server.
  • To address the need for complete information on user experience, this document introduces the PerformanceTiming interfaces. This interface allows JavaScript mechanisms to provide complete client-side latency measurements within applications. With the proposed interface, the previous example can be modified to measure a user's perceived page load time.
  • The following script calculates how much time to load a page since the most recent navigation.
  • The interface provided by this work does not intend to be used as any sort of performance benchmark for user agents.
  • 2 Conformance requirements

  • All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.
  • The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. For readability, these words do not appear in all uppercase letters in this specification.
  • Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.
  • Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
  • Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)
  • The IDL fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. [Web IDL]
  • 3 Terminology

  • The construction "a Foo object", where Foo is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface Foo".
  • The term "navigation" refers to the act of navigating.
  • The term "JavaScript" is used to refer to ECMA-262, rather than the official term ECMAScript, since the term JavaScript is more widely known.
  • Throughout this work, time is measured in milliseconds since midnight of January 1, 1970 (UTC). Note that the Navigation Timing 2 specification [Navigation Timing 2] allows access to timing information related to navigation using sub-milliseconds resolution instead.
  • 4 Navigation Timing

  • 4.1 Introduction

  • This section is non-normative
  • This specification introduces an interface that provides Web applications with timing-related information. This specification does not cover how Web applications leverage these interfaces to collect, store and report the provided information.
  • 4.2 The PerformanceTiming interface

  • navigationStart attribute

  • navigationStart 속성

  • This attribute must return the time immediately after the user agent finishes prompting to unload the previous document. If there is no previous document, this attribute must return the time the current document is created.
  • 이 속성은 사용자에이전트가 이전문서를 언로드하기 위한 메시지가 끝난 즉시의 시간을 반환해야한다.
    만약 이전 문서가 없다면, 이 속성은 현재 문서가 생성되는 시간을 반환한다.
  • unloadEventStart attribute

  • If the previous document and the current document have the same origin [IETF RFC 6454], this attribute must return the time immediately before the user agent starts the unload event of the previous document. If there is no previous document or the previous document has a different origin than the current document, this attribute must return zero.
  • unloadEventEnd attribute

  • If the previous document and the current document have the same same origin, this attribute must return the time immediately after the user agent finishes theunload event of the previous document. If there is no previous document or the previous document has a different origin than the current document or the unload is not yet completed, this attribute must return zero.
  • redirectStart attribute

  • If there are HTTP redirects or equivalent when navigating and if all the redirects or equivalent are from the same origin, this attribute must return the starting time of the fetch that initiates the redirect. Otherwise, this attribute must return zero.
  • redirectEnd attribute

  • If there are HTTP redirects or equivalent when navigating and all redirects and equivalents are from the same origin, this attribute must return the time immediately after receiving the last byte of the response of the last redirect. Otherwise, this attribute must return zero.
  • fetchStart attribute

  • domainLookupStart attribute

  • domainLookupEnd attribute

  • This section is non-normative.
  • Example
  • In case where the user agent already has the domain information in cache, domainLookupStart and domainLookupEnd represent the times when the user agent starts and ends the domain data retrieval from the cache.
  • connectStart attribute

  • connectEnd attribute

  • If the transport connection fails and the user agent reopens a connection, connectStart and connectEnd should return the corresponding values of the new connection.
  • connectEnd must include the time interval to establish the transport connection as well as other time interval such as SSL handshake and SOCKS authentication.
  • secureConnectionStart attribute

  • This attribute is optional. User agents that don't have this attribute available must set it as undefined. When this attribute is available, if the scheme of the current page is HTTPS, this attribute must return the time immediately before the user agent starts the handshake process to secure the current connection. If this attribute is available but HTTPS is not used, this attribute must return zero.
  • requestStart attribute

  • This attribute must return the time immediately before the user agent starts requesting the current document from the server, or from relevant application cachesor from local resources.
  • If the transport connection fails after a request is sent and the user agent reopens a connection and resend the request, requestStart should return the corresponding values of the new request.
  • This interface does not include an attribute to represent the completion of sending the request, e.g., requestEnd.
  • - Completion of sending the request from the user agent does not always indicate the corresponding completion time in the network transport, which brings most of the benefit of having such an attribute.
  • - Some user agents have high cost to determine the actual completion time of sending the request due to the HTTP layer encapsulation.
  • responseStart attribute

  • This attribute must return the time immediately after the user agent receives the first byte of the response from the server, or from relevant application caches or from local resources.
  • responseEnd attribute

  • This attribute must return the time immediately after the user agent receives the last byte of the current document or immediately before the transport connection is closed, whichever comes first. The document here can be received either from the server, relevant application caches or from local resources.
  • domLoading attribute

  • domInteractive attribute

  • domContentLoadedEventStart attribute

  • domContentLoadedEventEnd attribute

  • domComplete attribute

  • loadEventStart attribute

  • This attribute must return the time immediately before the load event of the current document is fired. It must return zero when the load event is not fired yet.
  • 이 속성은 현재 문서의 Load 이벤트가 발생하기 바로 전의 시간을 반환한다.
    load 이벤트가 아직 발생하지 않은 경우는 0를 반환하게 된다.
  • loadEventEnd attribute

  • loadEventEnd 속성

  • This attribute must return the time when the load event of the current document is completed. It must return zero when the load event is not fired or is not completed.
  • 이 속성은 현재 문서가 완전하게 로드된 이벤트가 발생할때의 시간을 반환한다.
    로드 이벤트가 발생되지 않았거나 완전하게 로드되지 않은 경우는 0를 반환하게 된다.
  • type attribute

  • This attribute must return the type of the last non-redirect navigation in the current browsing context. It must have one of the following navigation type values.
  • TYPE_NAVIGATE
  • Navigation 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 ones used by TYPE_RELOAD and TYPE_BACK_FORWARD as listed below.
  • TYPE_RELOAD
  • TYPE_BACK_FORWARD
  • TYPE_RESERVED
  • Any navigation types not defined by values above.
  • redirectCount attribute

  • This attribute must return the number of redirects since the last non-redirect navigation under the current browsing context. If there is no redirect or there is any redirect that is not from the same origin as the destination document, this attribute must return zero.
  • The HTML5 specification defines a Window interface [HTML5], which this specification extends.
  • The window.performance attribute provides a hosting area for performance related attributes.
  • timing attribute

  • The timing attribute represents the timing information related to the browsing contexts since the last non-redirect navigation. This attribute is defined by thePerformanceTiming interface.
  • navigation attribute

  • 5 Process

  • 5.1 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.
  • Note that user agents may choose to perform some of the steps involved in loading the document speculatively prior to user navigation e.g. the user agent could pre-resolve the host name, speculatively connect to the server hosting the document or prefetch the root document ahead of the actual user navigation. The timings in the PerformanceTiming interface represent the time spent waiting after user navigation in these steps. For example, in the case of speculative resolution that started and finished before user navigation and the user agent was able to use that result, the domainLookupStart anddomainLookupEnd attributes should both return the same value as fetchStart. If the speculative resolution started before user navigation and finished afternavigationStart and the user agent was able to use that result, the domainLookupStart attribute should return the same value as fetchStart and thedomainLookupEnd attribute should return the time immediately after the name lookup is successfully done.
Image of 1933 article
  • - 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 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.
  • - 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.
  • - Immediately after the unload event is completed, record the current time as unloadEventEnd.
  • - If no domain lookup is required, go to step 11. Otherwise, immediately before a user agent starts the domain name lookup, record the time asdomainLookupStart.
  • - 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
  • - Return to step 6 with the new resource.
  • - 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.
  • 5.2 Garbage Collection

  • There are implied strong references from the window object to its window.performance.timing and window.performance.navigation objects.
  • 5.3 Monotonic Clock

  • The value of the timing attributes must monotonically increase to ensure timing attributes are not skewed by adjustments to the system clock during the navigation. The difference between any two chronologically recorded timing attributes must never be negative. For all navigations, including subdocument navigations, the user agent must record the system clock at the beginning of the root document navigation and define subsequent timing attributes in terms of a monotonic clock measuring time elapsed from the beginning of the navigation.
  • 5.4 Vendor Prefixes

  • Vendor-specific proprietary user agent extensions are discouraged. If such extensions are needed, e.g., for experimental purposes, vendors must use the following extension mechanisms:
  • - If the extension to be added is an navigation type, the new type must
  • - follow the naming convention: TYPE_[VENDORPREFIX]_[TYPE], where [VENDORPREFIX] is a name that identifies the vendor.
  • - have a value in the range of 100 to 200.
  • - If the extension is a new timing attribute, it must
  • - follow the naming convention: [vendorPrefix]TimeAttribute, where [vendorPrefix] identifies the vendor name and TimeAttribute identifies the name of the timing attribute.
  • - be measured in milliseconds since midnight of January 1, 1970 (UTC), as defined in Section 3 Terminology.
  • - If the extension is a new navigation attribute, it must follow the naming convention: [vendorPrefix]NavigationAttribute, where [vendorPrefix] identifies the vendor name and NavigationAttribute identifies the name of the navigation attribute.
  • 6 Privacy

  • This section is non-normative.
  • 6.1 Information disclosure

  • There is the potential for disclosing an end-user's browsing and activity history by using carefully crafted timing attacks. For instance, the unloading time reveals how long the previous page takes to execute its unload handler, which could be used to infer the user's login status. These attacks have been mitigated by enforcing the same origin policy when timing information involving the previous navigation is accessed.
  • The relaxed same origin policy doesn't provide sufficient protection against unauthorized visits across documents. In shared hosting, an untrusted third party is able to host an HTTP server at the same IP address but on a different port.
  • 6.2 Cross-directory access

  • Different pages sharing one host name, for example contents from different authors hosted on sites with user generated content are considered from the same origin because there is no feature to restrict the access by pathname. Navigating between these pages allows a latter page to access timing information of the previous one, such as timing regarding redirection and unload event.
  • 7 Security

  • This section is non-normative.
  • 7.1 Detecting proxy servers

  • In case a proxy is deployed between the user agent and the web server, the time interval between the connectStart and the connectEnd attributes indicates the delay between the user agent and the proxy instead of the web server. With that, web server can potentially infer the existence of the proxy. For SOCKS proxy, this time interval includes the proxy authentication time and time the proxy takes to connect to the web server, which obfuscate the proxy detection. In case of an HTTP proxy, the user agent might not have any knowledge about the proxy server at all so it's not always feasible to mitigate this attack.
  • 7.2 Tampering by replacing timing objects

  • The window.performance object is replaceable to avoid conflicts with existing pages using the same object. By doing that, it is possible for third-party to replace the object and scripts relying on the interface described in this work would break.
  • 8 References

  • 8.1 Normative References

  • Web IDL, Cameron McCormack, Editor. World Wide Web Consortium, April 2012. This version of the Web IDL specification is available from http://www.w3.org/TR/2012/CR-WebIDL-20120419/. The latest version of Web IDL is available at http://www.w3.org/TR/WebIDL/.
  • 8.2 Informative References

  • Navigation Timing 2, Jatinder Mann, Arvind Jain, Editors. World Wide Web Consortium, unpublished.
  • Acknowledgements

  • I would like to offer my sincere thanks to all the people that I have been in touch with regarding this draft, including Anderson Quach, Alex Russell, Alois Reitbauer, Annie Sullivan, Christian Biesinger, Darin Fisher, Eric Lawrence, James Simonsen, Jatinder Mann, Jason Sobel, Jason Weber, Jonas Sicking, Kyle Scholz, Lenny Rachitsky, Nic Jansma, Richard Rabbat, Sergey Novikov, Sigbjørn Vik, Steve Souders, Tony Gentilcore for their reviews and feedback.
0 Comments