You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
993 lines
56 KiB
993 lines
56 KiB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html lang="en">
|
|
<head>
|
|
<meta content="text/html; charset=utf-8" http-equiv="content-type">
|
|
<title>Navigation Timing</title>
|
|
<style type="text/css">
|
|
pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
|
|
pre.idl :link, pre.idl :visited { color:inherit; background:transparent }
|
|
pre code { color:inherit; background:transparent }
|
|
div.example { margin-left:1em; padding-left:1em; border-left:double; color:#222; background:#fcfcfc }
|
|
.note { margin-left:2em; font-weight:bold; font-style:italic; color:#008000 }
|
|
p.note::before { content:"Note: " }
|
|
.XXX { padding:.5em; border:solid #f00 }
|
|
p.XXX::before { content:"Issue: " }
|
|
dl.switch { padding-left:2em }
|
|
dl.switch > dt { text-indent:-1.5em }
|
|
dl.switch > dt:before { content:'\21AA'; padding:0 0.5em 0 0; display:inline-block; width:1em; text-align:right; line-height:0.5em }
|
|
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
|
|
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
|
|
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
|
|
dl.domintro dd p { margin: 0.5em 0; }
|
|
dl.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: red; border: solid 2px; background: white; padding: 0 0.25em; }
|
|
em.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
|
|
dfn { font-weight:bold; font-style:normal }
|
|
code { color:orangered }
|
|
code :link, code :visited { color:inherit }
|
|
hr:not(.top) { display:block; background:none; border:none; padding:0; margin:2em 0; height:auto }
|
|
table { border-collapse:collapse; border-style:hidden hidden none hidden }
|
|
table thead { border-bottom:solid }
|
|
table tbody th:first-child { border-left:solid }
|
|
table td, table th { border-left:solid; border-right:solid; border-bottom:solid thin; vertical-align:top; padding:0.2em }
|
|
</style>
|
|
<link href="http://www.w3.org/StyleSheets/TR/W3C-CR.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
|
|
<body class="draft">
|
|
|
|
<div class="head">
|
|
<h1>Navigation Timing</h1>
|
|
<p>
|
|
<a href="http://www.w3.org/"><img alt="W3C" src="http://www.w3.org/Icons/w3c_home" height="48" width="72"></a>
|
|
</p>
|
|
|
|
<h2 class="no-num no-toc" id="candidate-recommendation-june-02-2011">W3C Candidate Recommendation 2 June 2011</h2>
|
|
<dl>
|
|
<dt>This version:</dt>
|
|
<dd><a href="http://www.w3.org/TR/2011/CR-navigation-timing-20110602/">http://www.w3.org/TR/2011/CR-navigation-timing-20110602/</a></dd>
|
|
<dt>Latest version:</dt>
|
|
<dd><a href="http://www.w3.org/TR/navigation-timing/">http://www.w3.org/TR/navigation-timing/</a></dd>
|
|
<dt>Latest Editor's Draft:</dt>
|
|
|
|
<dd><a href="http://www.w3c-test.org/webperf/specs/NavigationTiming/">http://www.w3c-test.org/webperf/specs/NavigationTiming/</a></dd>
|
|
<dt>Previous version:</dt>
|
|
<dd><a href="http://www.w3.org/TR/2011/CR-navigation-timing-20110315/">http://www.w3.org/TR/2011/CR-navigation-timing-20110315/</a></dd>
|
|
<dt>Editors:</dt>
|
|
<dd class="vcard"><span class="fn">Zhiheng Wang</span> (<span class="org">Google Inc.</span>) <<a class="email" href="mailto:zhihengw@google.com">zhihengw@google.com</a>> </dd>
|
|
|
|
</dl>
|
|
|
|
<p class=copyright><a
|
|
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
|
|
© 2011 <a href="http://www.w3.org/"><acronym title="World Wide Web
|
|
Consortium">W3C</acronym></a><sup>®</sup> (<a
|
|
href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute
|
|
of Technology">MIT</acronym></a>, <a
|
|
href="http://www.ercim.eu/"><acronym title="European Research Consortium
|
|
for Informatics and Mathematics">ERCIM</acronym></a>, <a
|
|
href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
|
|
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
|
|
<a
|
|
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
|
|
|
|
and <a
|
|
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
|
|
use</a> rules apply.</p>
|
|
|
|
<hr class='top'>
|
|
</div>
|
|
|
|
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
|
|
|
|
<p>This specification defines an interface for web applications to access
|
|
timing information related to navigation and elements. </p>
|
|
|
|
<h2 class="no-num no-toc" id="status-of-this-document">Status of this
|
|
document</h2>
|
|
|
|
<p><em>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 <a href="http://www.w3.org/TR/">W3C technical reports
|
|
index</a> at http://www.w3.org/TR/.</em></p>
|
|
|
|
<p>
|
|
This is an update to the Candidate Recommendation of Navigation Timing, taking into
|
|
account feedback from implementors.
|
|
</p>
|
|
<p>W3C publishes a
|
|
<a href="http://www.w3.org/2005/10/Process-20051014/tr.html#maturity-levels">Candidate
|
|
Recommendation</a> to indicate that the document is believed to be
|
|
stable and to encourage implementation by the developer community.
|
|
</p>
|
|
<p>
|
|
The entrance criteria for this document to enter the Proposed
|
|
Recommendation stage is to have a minimum of two independent and
|
|
interoperable user agents that implementation all the features of this
|
|
specification, which will be determined by passing the user agent
|
|
tests defined in the <a href="http://w3c-test.org/webperf/tests/">test
|
|
suite developed by the Working Group</a>.
|
|
</p>
|
|
|
|
<p>
|
|
The Working Group does not
|
|
expect to advance to Proposed Recommendation prior to 30 June 2011. A
|
|
preliminary <a href="http://www.w3.org/2011/03/navigation-timing-report">implementation
|
|
report</a> is available and will be updated during the Candidate
|
|
Recommendation period.
|
|
</p>
|
|
|
|
<p>Please send comments
|
|
to <a href="mailto:public-web-perf@w3.org?subject=[NavigationTiming]%20">public-web-perf@w3.org</a>
|
|
(<a href="http://lists.w3.org/Archives/Public/public-web-perf/">archived</a>)
|
|
with <samp>[NavigationTiming]</samp> at the start of the subject line.</p>
|
|
|
|
<p>A <a href="http://www.w3.org/2011/05/navigation-timing-diff">diff document</a> outlining the changes done since the previous
|
|
publication is available. Those are based on
|
|
the <a href="http://www.w3.org/2011/06/navigation-timing-issues.html">feedback
|
|
received during the Candidate Recommendation period</a>.
|
|
|
|
</p><p>This document is produced by
|
|
the <a href="http://www.w3.org/2010/webperf/">Web Performance</a>
|
|
Working Group. The Web Performance Working Group is part of
|
|
the <a href="http://www.w3.org/2006/rwc/Activity">Rich Web Clients
|
|
Activity</a> in the
|
|
W3C <a href="http://www.w3.org/Interaction/">Interaction
|
|
Domain</a>.
|
|
|
|
|
|
</p><p>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.</p>
|
|
|
|
<p>This document was produced by a group operating under
|
|
the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
|
|
February 2004 W3C Patent Policy</a>. W3C maintains
|
|
a <a href="http://www.w3.org/2004/01/pp-impl/45211/status"
|
|
rel="disclosure">public list of any patent disclosures</a> made in
|
|
connection with the deliverables of the group; that page also
|
|
includes instructions for disclosing a patent. An individual who
|
|
has actual knowledge of a patent which the individual believes
|
|
contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
|
|
Claim(s)</a> must disclose the information in accordance
|
|
with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
|
|
6 of the W3C Patent Policy</a>.</p>
|
|
|
|
|
|
<h2 class="no-num no-toc" id="table-of-contents">Table of Contents</h2>
|
|
<!--begin-toc-->
|
|
<ol class="toc">
|
|
<li><a href="#introduction"><span class="secno">1
|
|
</span>Introduction</a></li>
|
|
<li><a href="#conformance-requirements"><span class="secno">2
|
|
</span>Conformance requirements</a></li>
|
|
<li><a href="#terminology"><span class="secno">3 </span>Terminology</a></li>
|
|
<li><a href="#sec-navigation-timing"><span class="secno">4 </span>Navigation Timing</a>
|
|
<ol class="toc">
|
|
<li><a href="#sec-navigation-timing-introduction"><span class="secno">4.1 </span>Introduction</a></li>
|
|
<li><a href="#sec-navigation-timing-interface"><span class="secno">4.2 </span>The <code>PerformanceTiming</code> interface</a></li>
|
|
<li><a href="#sec-navigation-info-interface"><span class="secno">4.3 </span>The <code>PerformanceNavigation</code> interface</a></li>
|
|
<li><a href="#sec-window.performance-attribute"><span class="secno">4.4 </span> The <code>window.performance</code> attribute</a></li>
|
|
</ol>
|
|
</li>
|
|
<li><a href="#process"><span class="secno">5 </span>Process</a>
|
|
<ol class="toc">
|
|
<li><a href="#processing-model"><span class="secno">5.1 </span>Processing Model</a></li>
|
|
<li><a href="#garbage-collection"><span class="secno">5.2 </span>Garbage Collection</a></li>
|
|
<li><a href="#mono-clock"><span class="secno">5.3 </span>The Monotonic Clock</a></li>
|
|
</ol>
|
|
<li><a href="#privacy"><span class="secno">6 </span>Privacy</a></li>
|
|
<li><a href="#security"><span class="secno">7 </span>Security</a></li>
|
|
<li><a href="#references"><span class="secno">8 </span>References</a></li>
|
|
<li><a class="no-num" href="#acknowledgements">Acknowledgements</a></li>
|
|
</ol>
|
|
<!--end-toc-->
|
|
|
|
<h2 id="introduction"><span class="secno">1 </span>Introduction</h2>
|
|
|
|
<p>This section is non-normative.</p>
|
|
|
|
<p>
|
|
User latency is an important quality benchmark for Web Applications. While
|
|
JavaScript-based mechanisms 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.
|
|
</p>
|
|
|
|
<div class="example">
|
|
<p>For example, the following Javascript shows a naive attempt to
|
|
measure the time it takes to fully load a page:</p>
|
|
<pre><html>
|
|
<head>
|
|
<script type="text/javascript">
|
|
|
|
var start = new Date().getTime();
|
|
function onLoad() {
|
|
var now = new Date().getTime();
|
|
var latency = now - start;
|
|
alert("page loading time: " + latency);
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="onLoad()">
|
|
<!- Main page body goes from here. -->
|
|
</body>
|
|
</html></pre>
|
|
</div>
|
|
|
|
<p>The script calculates the time it takes to load the page <b>after</b> 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. </p>
|
|
|
|
<p>To address the need for complete information on user experience, this
|
|
document introduces the <a href="#nt-navigation-timing-interface">PerformanceTiming</a>
|
|
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. </p>
|
|
|
|
<div class="example">
|
|
<p>The following script calculates how much time to load a page since the
|
|
most recent navigation.</p>
|
|
<pre><html>
|
|
<head>
|
|
<script type="text/javascript">
|
|
function onLoad() {
|
|
var now = new Date().getTime();
|
|
var page_load_time = now - performance.timing.navigationStart;
|
|
alert("User-perceived page loading time: " + page_load_time);
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="onLoad()">
|
|
<!- Main page body goes from here. -->
|
|
</body>
|
|
</html></pre>
|
|
</div>
|
|
|
|
<p>The interface provided by this work does not intend to be used as any sort of
|
|
performance benchmark for user agents.</p>
|
|
|
|
<h2 id="conformance-requirements"><span class="secno">2 </span>Conformance
|
|
requirements</h2>
|
|
|
|
<p>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. </p>
|
|
|
|
<p>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 <a href="#rfc2119">RFC 2119</a>.
|
|
For readability, these words do not appear in all uppercase letters in this specification.</p>
|
|
|
|
<p>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. </p>
|
|
|
|
<p>Some conformance requirements are phrased as requirements on attributes,
|
|
methods or objects. Such requirements are to be interpreted as requirements
|
|
on user agents. </p>
|
|
|
|
<p>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.) </p>
|
|
|
|
<h2 id="terminology"><span class="secno">3 </span>Terminology</h2>
|
|
|
|
<p>The construction "a <code title="">Foo</code> object", where <code
|
|
title="">Foo</code> is actually an interface, is sometimes used instead of
|
|
the more accurate "an object implementing the interface <code
|
|
title="">Foo</code>". </p>
|
|
|
|
<p>The term DOM is used to refer to the API set made available to scripts in
|
|
Web applications, and does not necessarily imply the existence of an actual
|
|
<code>Document</code> object or of any other <code>Node</code> objects as
|
|
defined in the <a href="#DOM3Core">DOM Core specifications</a>.</p>
|
|
|
|
<p>A DOM attribute is said to be <em>getting</em> when its value is being
|
|
retrieved (such as by author script), and is said to be <em>setting</em> when
|
|
a new value is assigned to it. </p>
|
|
|
|
<p>The term "JavaScript" is used to refer to
|
|
<a href="#ECMA262">ECMA-262</a>,
|
|
rather than the official term ECMAScript, since the term JavaScript is more widely known.</p>
|
|
|
|
<p>Throughout this work, time is measured in milliseconds since midnight of January 1, 1970 (UTC).</p>
|
|
|
|
<h2 id="sec-navigation-timing"><span class="secno">4 </span>Navigation Timing</h2>
|
|
|
|
<h3 id="sec-navigation-timing-introduction"><span class="secno">4.1 </span>Introduction</h3>
|
|
|
|
<p>This section is non-normative</p>
|
|
|
|
<p>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. </p>
|
|
|
|
<h3 id="sec-navigation-timing-interface"><span class="secno">4.2 </span>The <code>PerformanceTiming</code> interface</h3>
|
|
<pre class="idl">interface <dfn id="nt-navigation-timing-interface">PerformanceTiming</dfn> {
|
|
readonly attribute unsigned long long <a href="#nt-navigation-start" title="navigationstart">navigationStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-unload-start" title="unloadeventstart">unloadEventStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-unload-end" title="unloadeventend">unloadEventEnd</a>;
|
|
readonly attribute unsigned long long <a href="#nt-redirect-start" title="redirectstart">redirectStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-redirect-end" title="redirectend">redirectEnd</a>;
|
|
readonly attribute unsigned long long <a href="#nt-fetch-start" title="fetchstart">fetchStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-domain-lookup-start" title="domainlookupstart">domainLookupStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-domain-lookup-end" title="domainlookupend">domainLookupEnd</a>;
|
|
readonly attribute unsigned long long <a href="#nt-connect-start" title="connectstart">connectStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-connect-end" title="connectend">connectEnd</a>;
|
|
readonly attribute unsigned long long <a href="#nt-secure-connect-start" title="secureconnectstart">secureConnectionStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-request-start" title="requeststart">requestStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-response-start" title="responsestart">responseStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-response-end" title="responseend">responseEnd</a>;
|
|
readonly attribute unsigned long long <a href="#nt-dom-loading" title="domloading">domLoading</a>;
|
|
readonly attribute unsigned long long <a href="#nt-dom-interactive" title="dominteractive">domInteractive</a>;
|
|
readonly attribute unsigned long long <a href="#nt-dom-content-event-start" title="domcontenteventstart">domContentLoadedEventStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-dom-content-event-end" title="domcontenteventend">domContentLoadedEventEnd</a>;
|
|
readonly attribute unsigned long long <a href="#nt-dom-complete" title="domcomplete">domComplete</a>;
|
|
readonly attribute unsigned long long <a href="#nt-load-start" title="loadeventstart">loadEventStart</a>;
|
|
readonly attribute unsigned long long <a href="#nt-load-end" title="loadeventend">loadEventEnd</a>;
|
|
};</pre>
|
|
|
|
<h4><code><dfn id="nt-navigation-start">navigationStart</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately after the user agent finishes <a
|
|
href="http://dev.w3.org/html5/spec/history.html#prompt-to-unload-a-document">prompting
|
|
to unload</a> the previous document. If there is no previous document, this attribute
|
|
must return the same value as <a href="#nt-fetch-start">fetchStart</a>.</p>
|
|
|
|
<h4><code><dfn id="nt-unload-start">unloadEventStart</dfn></code> attribute</h4>
|
|
|
|
<p>If the previous document and the current document have the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
this attribute must return the time immediately before the user agent starts
|
|
the <a href="http://dev.w3.org/html5/spec/history.html#unloading-documents">unload</a>
|
|
event of the previous document.
|
|
|
|
If there is no previous document or the previous document has a
|
|
different <a href="http://dev.w3.org/html5/spec/origin-0.html#origin">origin</a> than the
|
|
current document, this attribute must return zero.</p>
|
|
|
|
<h4><code><dfn id="nt-unload-end">unloadEventEnd</dfn></code> attribute</h4>
|
|
|
|
<p>If the previous document and the current document have the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
this attribute must return the time immediately after the user agent finishes the
|
|
<a href="http://dev.w3.org/html5/spec/history.html#unload-a-document">unload</a>
|
|
event of the previous document. If there is no previous document or the previous document has
|
|
a different <a href="http://dev.w3.org/html5/spec/origin-0.html#origin">origin</a> than the
|
|
current document or the unload is not yet completed, this attribute must return zero.</p>
|
|
|
|
<p>If there are HTTP redirects
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or equivalent</a>
|
|
when navigating and not all the redirects or equivalent are from the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
both <a href="#nt-unload-start">unloadEventStart</a> and
|
|
<a href="#nt-unload-end">unloadEventEnd</a> must return the zero.</p>
|
|
|
|
<h4><code><dfn id="nt-redirect-start">redirectStart</dfn></code> attribute </h4>
|
|
|
|
<p>If there are HTTP redirects
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or equivalent</a>
|
|
when navigating and if all the redirects or equivalent are from the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
this attribute must return the <a href="#nt-fetch-start">starting time
|
|
of the fetch</a> that initiates the redirect. Otherwise, this attribute must return zero.</p>
|
|
|
|
<h4><code><dfn id="nt-redirect-end">redirectEnd</dfn></code> attribute </h4>
|
|
|
|
<p>If there are HTTP redirects
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or equivalent</a>
|
|
when navigating and all redirects and equivalents are from the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
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.</p>
|
|
|
|
<h4><code><dfn id="nt-fetch-start">fetchStart</dfn></code> attribute</h4>
|
|
|
|
<p>If the new resource is to be fetched using HTTP GET
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or
|
|
equivalent</a>, fetchStart must return the time immediately before the user agent starts
|
|
checking <a href="http://dev.w3.org/html5/spec/Overview.html#relevant-application-cache">
|
|
any relevant application caches</a>. Otherwise, it must return the time when the
|
|
user agent starts
|
|
<a href="http://dev.w3.org/html5/spec/Overview.html#fetching-resources">fetching the resource</a>.</p>
|
|
|
|
<h4><code><dfn id="nt-domain-lookup-start">domainLookupStart</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent starts the domain name
|
|
lookup for the current document.
|
|
If a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1">persistent
|
|
connection</a> [<a href='#rfc2616'>RFC 2616</a>] is used or the current document
|
|
is retrieved from <a href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application caches</a> or local resources,
|
|
this attribute must return the same value as <a href="#nt-fetch-start">fetchStart</a>. </p>
|
|
|
|
<h4><code><dfn id="nt-domain-lookup-end">domainLookupEnd</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately after the user agent
|
|
finishes the domain name lookup for the current document.
|
|
If a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1">persistent
|
|
connection</a> [<a href='#rfc2616'>RFC 2616</a>] is used or the current document
|
|
is retrieved from <a href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application caches</a> or local resources,
|
|
this attribute must return the same value as <a href="#nt-fetch-start">fetchStart</a>. </p>
|
|
|
|
<div class="example">
|
|
<p>This section is non-normative.</p>
|
|
<p>Checking and retrieving contents from the
|
|
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13">HTTP cache</a> [<a href='#rfc2616'>RFC 2616</a>]
|
|
is part of the <a href="http://dev.w3.org/html5/spec/fetching-resources.html#fetching-resources">
|
|
fetching process</a>. It's covered by the
|
|
<a href="#nt-request-start">requestStart</a>,
|
|
<a href="#nt-response-start">responseStart</a> and
|
|
<a href="#nt-response-end">responseEnd</a> attributes.</p>
|
|
</div>
|
|
<div class="example">
|
|
|
|
<div class="exampleHeader">
|
|
Example</div>
|
|
|
|
<p>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. </p>
|
|
|
|
</div>
|
|
|
|
<h4><code><dfn id="nt-connect-start">connectStart</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent start
|
|
establishing the connection to the server to retrieve the document.
|
|
If a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1">persistent
|
|
connection</a> [<a href='#rfc2616'>RFC 2616</a>] is used or the current document is retrieved from <a
|
|
href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application caches</a> or local resources,
|
|
this attribute must return value of <a href="#nt-domain-lookup-end">domainLookupEnd</a>.</p>
|
|
|
|
<h4><code><dfn id="nt-connect-end">connectEnd</dfn></code> attribute </h4>
|
|
|
|
<p>This attribute must return the time immediately after the user agent
|
|
finishes establishing the connection to the server to retrieve the current document.
|
|
If a <a
|
|
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1">persistent
|
|
connection</a> [<a href='#rfc2616'>RFC 2616</a>] is used or the current document is retrieved from <a
|
|
href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application caches</a> or local resources,
|
|
this attribute must return the value of <a href="#nt-domain-lookup-end">domainLookupEnd</a>
|
|
</p>
|
|
|
|
<p>If the transport connection fails and the user agent reopens a connection,
|
|
<a href="#nt-connect-start">connectStart</a> and
|
|
<a href="#nt-connect-end">connectEnd</a> should return the corresponding
|
|
values of the new connection. </p>
|
|
<p>
|
|
<a href="#nt-connect-end">connectEnd</a> must include the time interval to
|
|
establish the transport connection as well as other time interval
|
|
such as SSL handshake and SOCKS authentication.
|
|
</p>
|
|
|
|
<h4><code><dfn id="nt-secure-connect-start">secureConnectionStart</dfn></code> attribute</h4>
|
|
|
|
<p>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
|
|
<a href="http://dev.w3.org/html5/spec/urls.html#url-scheme">scheme</a> of the
|
|
current page is <a href="http://tools.ietf.org/html/rfc2817">HTTPS</a>, 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.
|
|
</p>
|
|
|
|
<h4><code><dfn id="nt-request-start">requestStart</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent
|
|
starts requesting the current document from the server, or from
|
|
<a href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">
|
|
relevant application caches</a> or from local resources.</p>
|
|
|
|
<p>If the transport connection fails after a request is sent and the user
|
|
agent reopens a connection and resend the request, <a
|
|
href="#nt-request-start">requestStart</a> should return the corresponding values
|
|
of the new request.</p>
|
|
|
|
<div class="note">
|
|
<p>This interface does not include an attribute to represent the completion of
|
|
sending the request, e.g., requestEnd.
|
|
<ul>
|
|
<li>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.</li>
|
|
<li>Some user agents have high cost to determine the actual completion time of
|
|
sending the request due to the HTTP layer encapsulation.</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<h4><code><dfn id="nt-response-start">responseStart</dfn></code> attribute </h4>
|
|
|
|
<p>This attribute must return the time immediately after the user agent receives the first
|
|
byte of the response from the server, or from
|
|
<a href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application caches</a> or from local resources. </p>
|
|
|
|
<h4><code><dfn id="nt-response-end">responseEnd</dfn></code> attribute</h4>
|
|
|
|
<p>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,
|
|
<a href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application caches</a> or from local resources.</p>
|
|
|
|
<h4><code><dfn id="nt-dom-loading">domLoading</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent sets the
|
|
<a href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">current
|
|
document readiness</a> to
|
|
<a href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">"loading"</a>.</p>
|
|
|
|
<h4><code><dfn id="nt-dom-interactive">domInteractive</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent sets the
|
|
<a href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">current
|
|
document readiness</a> to
|
|
<a href="http://dev.w3.org/html5/spec/the-end.html#the-end">"interactive"</a>.</p>
|
|
|
|
<h4><code><dfn id="nt-dom-content-event-start">domContentLoadedEventStart</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent fires <a
|
|
href="http://dev.w3.org/html5/spec/the-end.html#the-end">the DOMContentLoaded
|
|
event</a> at the Document.</p>
|
|
|
|
<h4><code><dfn id="nt-dom-content-event-end">domContentLoadedEventEnd</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately after the document's <a
|
|
href="http://dev.w3.org/html5/spec/the-end.html#the-end">DOMContentLoaded
|
|
event</a> completes.</p>
|
|
|
|
<h4><code><dfn id="nt-dom-complete">domComplete</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the time immediately before the user agent sets the
|
|
<a href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">current
|
|
document readiness</a> to
|
|
<a href="http://dev.w3.org/html5/spec/the-end.html#the-end">"complete"</a>.</p>
|
|
|
|
<p>If the <a href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">
|
|
current document readiness</a> changes to the same state multiple times,
|
|
<a href="#nt-dom-loading">domLoading</a>,
|
|
<a href="#nt-dom-interactive">domInteractive</a>,
|
|
<a href="#nt-dom-content-event-start">domContentLoadedEventStart</a>,
|
|
<a href="#nt-dom-content-event-end">domContentLoadedEventEnd</a> and
|
|
<a href="#nt-dom-complete">domComplete</a> must return the time of the first
|
|
occurrence of the corresponding
|
|
<a href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">document readiness</a>
|
|
change.</p>
|
|
|
|
<h4><code><dfn id="nt-load-start">loadEventStart</dfn></code> attribute </h4>
|
|
|
|
<p>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.</p>
|
|
|
|
<h4><code><dfn id="nt-load-end">loadEventEnd</dfn></code> attribute</h4>
|
|
|
|
<p>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.</p>
|
|
|
|
<h3 id="sec-navigation-info-interface"><span class="secno">4.3 </span>The
|
|
<code><a href="#nt-navigation-info-interface">PerformanceNavigation</a></code> interface</h3>
|
|
<pre class="idl">interface <dfn id="nt-navigation-info-interface">PerformanceNavigation</dfn> {
|
|
const unsigned short <a href="#nt-navigation-info-type-navigate">TYPE_NAVIGATE</a> = 0;
|
|
const unsigned short <a href="#nt-navigation-info-type-reload">TYPE_RELOAD</a> = 1;
|
|
const unsigned short <a href="#nt-navigation-info-type-back-forward">TYPE_BACK_FORWARD</a> = 2;
|
|
const unsigned short <a href="#nt-navigation-info-type-reserved">TYPE_RESERVED</a> = 255;
|
|
readonly attribute unsigned short <a href="#nt-navigation-info-type" title="navigationtype">type</a>;
|
|
readonly attribute unsigned short <a href="#nt-navigation-info-redirect-count" title="redirectcount">redirectCount</a>;
|
|
};</pre>
|
|
|
|
<h4><code><dfn id="nt-navigation-info-type">type</dfn></code> attribute</h4>
|
|
|
|
<p>This attribute must return the type of the last non-redirect <a
|
|
href="http://dev.w3.org/html5/spec/history.html#navigate">navigation</a>
|
|
in the current browsing context. It must have one of the following <a
|
|
href="#nt-navigation-info-type">navigation type</a> values. </p>
|
|
<dl>
|
|
<dt><dfn id="nt-navigation-info-type-navigate">TYPE_NAVIGATE</dfn>:
|
|
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 <a href="#nt-navigation-info-type-navigate">TYPE_RELOAD</a>
|
|
and <a href="#nt-navigation-info-type-back-forward">TYPE_BACK_FORWARD</a> as listed below.
|
|
<dt><dfn id="nt-navigation-info-type-reload">TYPE_RELOAD</dfn>: Navigation through
|
|
the reload operation or the
|
|
<a href="http://dev.w3.org/html5/spec/Overview.html#dom-location-reload">location.reload()</a>
|
|
method.</dt>
|
|
<dt><dfn id="nt-navigation-info-type-back-forward">TYPE_BACK_FORWARD</dfn>: Navigation
|
|
through a <a href="http://dev.w3.org/html5/spec/Overview.html#traverse-the-history">history traversal</a> operation.</dt>
|
|
<dt><dfn id="nt-navigation-info-type-reserved">TYPE_RESERVED</dfn>: Any navigation
|
|
types not defined by values above.</dt>
|
|
</dl>
|
|
|
|
<div class="note">
|
|
<p>Client-side redirects, such as those using <a href="http://dev.w3.org/html5/spec/semantics.html#attr-meta-http-equiv-refresh">the Refresh pragma directive</a>,
|
|
are not considered HTTP redirects <a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or equivalent</a> by this spec.
|
|
In those cases, the <a href="#nt-navigation-info-type">type</a> attribute should return appropriate value,
|
|
such as <a href="#nt-navigation-info-type-navigate">TYPE_RELOAD</a> if reloading the current page, or
|
|
<a href="#nt-navigation-info-type-navigate">TYPE_NAVIGATE</a> if navigating to a new URL.</p>
|
|
</div>
|
|
|
|
<h4><code><dfn id="nt-navigation-info-redirect-count">redirectCount</dfn></code> attribute </h4>
|
|
|
|
<p>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
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">
|
|
same origin</a> as the destination document, this attribute must return zero. </p>
|
|
|
|
<h3 id="sec-window.performance-attribute"><span class="secno">4.4 </span> The <code><a href="#nt-window-performance">window.performance</a> </code>
|
|
attribute</h3>
|
|
<pre class="idl">interface <dfn id="nt-performance-interface">Performance</dfn> {
|
|
readonly attribute <a href="#nt-navigation-timing-interface">PerformanceTiming</a> <dfn id="window-performance-timing">timing</dfn>;
|
|
readonly attribute <a href="#nt-navigation-info-interface">PerformanceNavigation</a> <dfn id="window-performance-navigation">navigation</dfn>;
|
|
};
|
|
|
|
[Supplemental]
|
|
interface Window {
|
|
[Replaceable] readonly attribute <a href="#nt-performance-interface">Performance</a> <dfn id="nt-window-performance">performance</dfn>;
|
|
};</pre>
|
|
|
|
<p>
|
|
The <a href="#nt-window-performance">window.performance</a> attribute provides
|
|
a hosting area for performance related attributes. Specifically, the <a
|
|
href="#window-performance-timing">window.performance.timing</a> attribute
|
|
represents the timing information related to the browsing contexts since the
|
|
last non-redirect navigation. Each browsing context must have a unique <a
|
|
href="#window-performance-timing">window.performance.timing</a> attribute.
|
|
PerformanceTiming objects in the timing attribute may be sorted by the
|
|
chronological order of the corresponding browsing context.
|
|
</p>
|
|
|
|
<div class="example">
|
|
<p>Following is an example of how to use the interface in an HTML page: </p>
|
|
<pre>var t = performance.timing;
|
|
var n = performance.navigation;
|
|
if (t.loadEventEnd > 0) {
|
|
var page_load_time = t.loadEventEnd - t.navigationStart;
|
|
if (n.type == n.TYPE_NAVIGATE) {
|
|
alert (page_load_time);
|
|
}
|
|
}</pre>
|
|
</div>
|
|
|
|
<h2 id="process"><span class="secno">5 </span>Process</h2>
|
|
|
|
<h3 id="processing-model"><span class="secno">5.1 </span>Processing Model</h3>
|
|
|
|
<p class="note">All the attributes in window.performance.timing and
|
|
window.performance.navigation should not be written to until <a
|
|
href="http://dev.w3.org/html5/spec/history.html#create-a-document-object">the
|
|
Window object of the current document is created</a>, even though their
|
|
attributes are referred to in the following steps to facilitate
|
|
description.</p>
|
|
|
|
<p class="note">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.</p>
|
|
|
|
<div class="example">
|
|
<div class="exampleHeader">
|
|
Example</div>
|
|
<p>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.</p>
|
|
</div>
|
|
|
|
<div class="example">
|
|
<div class="exampleHeader">Illustration</div>
|
|
<p>This section is non-normative.</p>
|
|
<p>The following graph illustrates the timing attributes defined by the
|
|
<a href="#nt-navigation-timing-interface">PerformanceTiming</a> interface and the
|
|
<a href="#nt-navigation-info-interface">PerformanceNavigation</a> interface
|
|
with or without redirect, respectively. Attributes underlined may not be
|
|
available in navigation involving documents from different
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">origins</a>. User
|
|
agents may perform internal processing in between timings, which allow for
|
|
non-normative intervals between timings.</p>
|
|
<p><img width="85%" src="timing-overview.png" alt='Timing attributes'></p>
|
|
</div>
|
|
|
|
<ol>
|
|
<li>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.
|
|
<ol style="list-style-type:lower-alpha;">
|
|
<li>The navigation is aborted due to the
|
|
<a href="http://dev.w3.org/html5/spec/the-iframe-element.html#sandboxed-navigation-browsing-context-flag">sandboxed
|
|
navigation browsing context flag</a> or the
|
|
<a href="http://dev.w3.org/html5/spec/the-iframe-element.html#sandboxed-top-level-navigation-browsing-context-flag">sandboxed
|
|
top-level navigation browsing context flag</a>, or a preexist attempt
|
|
to navigate the <a href="http://dev.w3.org/html5/spec/browsers.html#browsing-context">browsing context</a>.</li>
|
|
<li>The navigation is caused by <a
|
|
href="http://dev.w3.org/html5/spec/history.html#navigate-fragid-step"><em>fragment
|
|
identifiers</em></a> within the page.</li>
|
|
<li>The new resource is to be handled by some sort of inline
|
|
content.</li>
|
|
<li>The new resource is to be handled using a mechanism that does not
|
|
affect the browsing context.</li>
|
|
<li>The user <a
|
|
href="http://dev.w3.org/html5/spec/history.html#refused-to-allow-the-document-to-be-unloaded">refuses
|
|
to allow the document to be unloaded</a>.</li>
|
|
</ol>
|
|
</li>
|
|
<li>Immediately after the user agent <a
|
|
href="http://dev.w3.org/html5/spec/history.html#prompt-to-unload-a-document">prompts
|
|
to unload</a> the previous <a
|
|
href="http://dev.w3.org/html5/spec/infrastructure.html#document">document</a>,
|
|
record the current time as <a
|
|
href="#nt-navigation-start">navigationStart</a>.</li>
|
|
<li> Record the current navigation type in <a href="#nt-navigation-info-type">window.performance.navigation.type</a>
|
|
if it has not been set:
|
|
<ol style="list-style-type:lower-alpha;">
|
|
<li>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
|
|
<a href="http://dev.w3.org/html5/spec/Overview.html#dom-location-reload">location.reload()</a> method,
|
|
let the navigation type be <a href="#nt-navigation-info-type-navigate">TYPE_NAVIGATE</a>.</li>
|
|
<li>If the navigation was started either as a result of a
|
|
<a href="http://dev.w3.org/html5/spec/Overview.html#attr-meta-http-equiv-refresh">meta refresh</a>,
|
|
or the <a href="http://dev.w3.org/html5/spec/Overview.html#dom-location-reload">location.reload()</a>
|
|
method, or other equivalent actions, let the navigation type
|
|
be <a href="#nt-navigation-info-type-reload">TYPE_RELOAD</a>.</li>
|
|
<li>If the navigation was started as a result of
|
|
<a href="http://dev.w3.org/html5/spec/Overview.html#traverse-the-history">history traversal</a>,
|
|
let the navigation type be <a href="#nt-navigation-info-type-back-forward">TYPE_BACK_FORWARD</a>.</li>
|
|
<li>Otherwise, let the navigation type be <a href="#nt-navigation-info-type-navigate">TYPE_RESERVED</a>.</li>
|
|
</ol>
|
|
</li>
|
|
<li>If the current document and the previous document are from different
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">origins</a>,
|
|
set both <a href="#nt-unload-end">unloadEventStart</a> and
|
|
<a href="#nt-unload-end">unloadEventEnd</a> to 0 then go to step
|
|
<a href="#step-fetch-start">6</a>. Otherwise, record <a href="#nt-unload-end">unloadEventStart</a>
|
|
as the time immediately before the unload event.</li>
|
|
<li>Immediately after the unload event is completed,
|
|
record the current time as <a href="#nt-unload-end">unloadEventEnd</a>.</li>
|
|
<li id="step-fetch-start">If the new resource is to be fetched using HTTP GET
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or equivalent</a>,
|
|
immediately before a user agent checks with the <a
|
|
href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">
|
|
relevant application caches</a>, record the current time as
|
|
<a href="#nt-fetch-start">fetchStart</a>. Otherwise, immediately before a user agent starts the
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#fetching-resources">
|
|
fetching process</a>, record the current time as <a href="#nt-fetch-start">fetchStart</a>.</li>
|
|
<li>Let <a href="#nt-domain-lookup-start">domainLookupStart</a>, <a
|
|
href="#nt-domain-lookup-end">domainLookupEnd</a>, <a
|
|
href="#nt-connect-start">connectStart</a> and <a
|
|
href="#nt-connect-end">connectEnd</a> be the same value as <a
|
|
href="#nt-fetch-start">fetchStart</a>.</li>
|
|
<li>If the resource is fetched from the <a
|
|
href="http://dev.w3.org/html5/spec/offline.html#relevant-application-cache">relevant
|
|
application cache</a> or local resources, including the
|
|
<a href="http://www.ietf.org/rfc/rfc2616.txt">HTTP cache</a>,
|
|
go to step <a href="#step-request-start">13</a>.</li>
|
|
<li>If no domain lookup is required, go to step <a
|
|
href="#step-connect-start">11</a>. Otherwise, immediately before a user
|
|
agent starts the domain name lookup, record the time as
|
|
<a href="#nt-domain-lookup-start">domainLookupStart</a>. </li>
|
|
<li>Record the time as <a href="#nt-domain-lookup-end">domainLookupEnd</a>
|
|
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. </li>
|
|
<li id="step-connect-start">If a persistent transport connection is used to
|
|
fetch the resource, let <a href="#nt-connect-start">connectStart</a> and
|
|
<a href="#nt-connect-end">connectEnd</a> be the same value of
|
|
<a href="#nt-domain-lookup-end">domainLookupEnd</a>.
|
|
Otherwise, record the time as <a
|
|
href="#nt-connect-start">connectStart</a> immediately before initiating
|
|
the connection to the server and record the time as
|
|
<a href="#nt-connect-end">connectEnd</a> 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. </li>
|
|
<li>In step <a href="#step-connect-start">11</a>, a user agent should also
|
|
carry out these additional steps if it supports the
|
|
<a href="#nt-secure-connect-start">secureConnectionStart</a> attribute:
|
|
<ol>
|
|
<li>If the scheme of the current document is HTTPS, the user agent must
|
|
record the time as <a href="#nt-secure-connect-start">secureConnectionStart</a>
|
|
immediately before the handshake process to secure the connection.</li>
|
|
<li>If the scheme of the current document is not HTTPS, the user agent must
|
|
set the value of <a href="#nt-secure-connect-start">secureConnectionStart</a> to 0.</li>
|
|
</ol></li>
|
|
<li id="step-request-start">Immediately before a user agent starts sending
|
|
request for the document, record the current time as <a
|
|
href="#nt-request-start">requestStart</a>.</li>
|
|
<li id="step-response-start">Record the time as <a href="#nt-response-start">
|
|
responseStart</a> immediately after the user agent receives the first byte
|
|
of the response.</li>
|
|
<li id="step-response-end">Record the time as <a
|
|
href="#nt-response-end">responseEnd</a> immediately after receiving the
|
|
last byte of the response.
|
|
<p>Return to step <a href="#step-connect-start">11</a> if the user agent
|
|
fails to send the request or receive the entire response, and needs to
|
|
reopen the connection.</p>
|
|
|
|
<div class="example">
|
|
<div class="exampleHeader">Example</div>
|
|
<p>When <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1">persistent
|
|
connection</a> [<a href='#rfc2616'>RFC 2616</a>] is enabled, a user agent may first try to re-use an open
|
|
connect to send the request while the connection can be <a
|
|
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4">asynchronously
|
|
closed</a>. In such case, connectStart, connectEnd and requestStart should represent
|
|
timing information collected over the re-open connection. </p>
|
|
</div>
|
|
</li>
|
|
<li>If the fetched resource results in an HTTP redirect
|
|
<a href="http://dev.w3.org/html5/spec/fetching-resources.html#concept-http-equivalent-codes">or equivalent</a>,
|
|
then
|
|
<ol style="list-style-type:lower-alpha;">
|
|
<li>if the current document and the document that is redirected to are not from the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
set <a href="#nt-redirect-start">redirectStart</a>,
|
|
<a href="#nt-redirect-end">redirectEnd</a>,
|
|
<a href="#nt-unload-start">unloadEventStart</a>,
|
|
<a href="#nt-unload-end">unloadEventStart</a> and
|
|
<a href="#nt-navigation-info-redirect-count">redirectCount</a> to 0. Then,
|
|
return to step <a href="#step-fetch-start">6</a> with the new resource.</li>
|
|
<li>if there is previous redirect involving documents that are not from the
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a>,
|
|
set <a href="#nt-redirect-start">redirectStart</a>,
|
|
<a href="#nt-redirect-end">redirectEnd</a>,
|
|
<a href="#nt-unload-start">unloadEventStart</a>,
|
|
<a href="#nt-unload-end">unloadEventStart</a> and
|
|
<a href="#nt-navigation-info-redirect-count">redirectCount</a> to 0. Then,
|
|
return to step <a href="#step-fetch-start">6</a> with the new resource.</li>
|
|
<li>Increment <a href="#nt-navigation-info-redirect-count">redirectCount</a> by 1.</li>
|
|
<li>If the value of <a href="#nt-redirect-start">redirectStart</a> is 0,
|
|
let it be the value of <a href="#nt-fetch-start">fetchStart</a>.</li>
|
|
<li>Let <a href="#nt-redirect-end">redirectEnd</a> be the value of
|
|
<a href="#nt-response-end">responseEnd</a>.</li>
|
|
<li>Set all the attributes in window.performance.timing to 0 except
|
|
<a href="#nt-navigation-start">navigationStart</a>,
|
|
<a href="#nt-redirect-start">redirectStart</a>,
|
|
<a href="#nt-redirect-end">redirectEnd</a>,
|
|
<a href="#nt-unload-start">unloadEventStart</a> and
|
|
<a href="#nt-unload-end">unloadEventEnd</a>.</li>
|
|
<li>Return to step <a href="#step-fetch-start">6</a> with the new resource.</li>
|
|
</ol>
|
|
</li>
|
|
<li>Record the time as <a href="#nt-dom-loading">domLoading</a> immediately
|
|
before the user agent sets the <a
|
|
href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">current
|
|
document readiness</a> to "loading".</li>
|
|
<li>Record the time as <a href="#nt-dom-interactive">domInteractive</a>
|
|
immediately before the user agent sets the <a
|
|
href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">current
|
|
document readiness</a> to "interactive".</li>
|
|
<li>Record the time as <a
|
|
href="#nt-dom-content-event-start">domContentLoadedEventStart</a> immediately before the
|
|
user agent fires <a href="http://dev.w3.org/html5/spec/the-end.html#the-end">the
|
|
DOMContentLoaded event</a> at the document.</li>
|
|
<li>Record the time as <a
|
|
href="#nt-dom-content-event-end">domContentLoadedEventEnd</a> immediately after
|
|
<a href="http://dev.w3.org/html5/spec/the-end.html#the-end">the
|
|
DOMContentLoaded event</a> completes.</li>
|
|
<li>Record the time as <a href="#nt-dom-complete">domComplete</a>
|
|
immediately before the user agent sets the <a
|
|
href="http://dev.w3.org/html5/spec/dom.html#current-document-readiness">current
|
|
document readiness</a> to "complete".</li>
|
|
<li>Record the time as <a href="#nt-load-start">loadEventStart</a>
|
|
immediately before the user agent fires the load event.</li>
|
|
<li>Record the time as <a href="#nt-load-end">loadEventEnd</a>
|
|
immediately after the user agent completes the load event.</li>
|
|
</ol>
|
|
|
|
<p>Some user agents maintain the DOM structure of the document in memory
|
|
during navigation operations such as forward and backward. In those cases,
|
|
the window.performance.timing and window.performance.navigation objects must not
|
|
be altered during the navigation.</p>
|
|
|
|
<h3 id="garbage-collection"><span class="secno">5.2 </span>Garbage Collection</h3>
|
|
<p>
|
|
There are <a href="http://dev.w3.org/html5/spec/common-dom-interfaces.html#implied-strong-reference">
|
|
implied strong references</a> from the window object to its
|
|
window.performance.timing and window.performance.navigation objects.
|
|
</p>
|
|
|
|
<h3 id="mono-clock"><span class="secno">5.3 </span>The Monotonic Clock</h3>
|
|
<p>This section is non-normative.</p>
|
|
<p>The values of the timing attributes should monotonically increasing at the rate time actually passes at.
|
|
However, wallclock time can be adjusted by system users or other mechanisms such as
|
|
<a href="http://www.ietf.org/rfc/rfc5905.txt">NTP</a>.
|
|
Implementations that is purely based on the wallclock is prone to large jumps forwards and backwards
|
|
as the wallclock is adjusted, so the timing attributes can not guarantee to be monotonic.</p>
|
|
<p>To prevent wallclock adjustment from skewing the timing attributes, user agents are recommended to
|
|
record the wallclock time at the beginning of the navigation and define other timing attributes
|
|
in terms of a monotonic clock measuring time elapsed from the beginning of the navigation. </p>
|
|
|
|
<h2 id="privacy"><span class="secno">6 </span>Privacy</h2>
|
|
<p>This section is non-normative.</p>
|
|
|
|
<h3 id="info_disclosure"><span class="secno">6.1 </span>Information disclosure</h3>
|
|
<p>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
|
|
<a href="http://dev.w3.org/html5/spec/origin-0.html#origin">same origin</a> policy when
|
|
timing information involving the previous navigation is accessed.</p>
|
|
|
|
<p>The <a href="http://dev.w3.org/html5/spec/origin-0.html#relaxing-the-same-origin-restriction">
|
|
relaxed same origin policy</a> 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.</p>
|
|
|
|
<h3 id="cross-directory"><span class="secno">6.2 </span>Cross-directory access</h3>
|
|
<p>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.</p>
|
|
|
|
<h2 id="security"><span class="secno">7 </span>Security</h2>
|
|
<p>This section is non-normative.</p>
|
|
|
|
<h3 id="authentication"><span class="secno">7.1 </span>Detecting proxy servers</h3>
|
|
<p>In case a proxy is deployed between the user agent and the web server, the time interval
|
|
between the <a href="#nt-connect-start">connectStart</a> and the
|
|
<a href="#nt-connect-end">connectEnd</a> 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.</p>
|
|
|
|
<h3 id="readonly"><span class="secno">7.2 </span>Tampering by replacing timing objects</h3>
|
|
<p>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.</p>
|
|
|
|
<h2 id="references"><span class="secno">8 </span>References</h2>
|
|
|
|
<dl id='references-list'>
|
|
<dt><a name='rfc2119' id='rfc2119'>[IETF RFC 2119]</a></dt>
|
|
<dd>
|
|
<cite><a href='http://www.ietf.org/rfc/rfc2119.txt'>Key words for use in RFCs to Indicate Requirement Levels</a></cite>, Scott Bradner, Author. Internet Engineering Task Force, March 1997. Available at <a href='http://www.ietf.org/rfc/rfc2119.txt'>http://www.ietf.org/rfc/rfc2119.txt</a>.
|
|
</dd>
|
|
<dt><a name='rfc2616' id='rfc2616'>[IETF RFC 2616]</a></dt>
|
|
<dd>
|
|
<cite><a href='http://www.ietf.org/rfc/rfc2616.txt'>Hypertext Transfer Protocol -- HTTP/1.1</a></cite>, R. Fielding et al., Authors. Internet Engineering Task Force, June 1999. Available at <a href='http://www.ietf.org/rfc/rfc2616.txt'>http://www.ietf.org/rfc/rfc2616.txt</a>.
|
|
</dd>
|
|
<dt>[<a name="DOM3Core" id='DOM3Core'>DOM Level 3 Core</a>]</dt>
|
|
<dd>
|
|
<cite><a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407">Document Object Model Level 3 Core
|
|
Specification</a></cite>, A. Le Hors, et al., Editors. World
|
|
Wide Web Consortium, 7 April 2004. This version of the Document
|
|
Object Model Level 3 Core Recommendation is
|
|
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407. The <a class="normative" href="http://www.w3.org/TR/DOM-Level-3-Core/">latest version of
|
|
DOM Level 3 Core</a> is available at
|
|
http://www.w3.org/TR/DOM-Level-3-Core.
|
|
</dd>
|
|
<dt>[<a name="ECMA262" id="ECMA262">ECMA-262</a>]</dt><dd>
|
|
<cite><a href='http://www.ecma-international.org/publications/standards/Ecma-262.htm'>ECMAScript Language Specification</a></cite>, 5<sup>th</sup>
|
|
Edition. ECMA International, Standard
|
|
ECMA-262, December 2009. This version of the ECMAScript
|
|
Language is available from <a href='http://www.ecma-international.org/publications/standards/Ecma-262.htm'>http://www.ecma-international.org/publications/standards/Ecma-262.htm</a>.
|
|
<dt>[<a name="HTML5" id="HTML5">HTML5</a>]</dt>
|
|
<dd><cite><a href='http://www.w3.org/TR/html5/'>HTML5</a></cite>, Ian Hickson, Editor. World Wide Web Consortium, May 2011. This version of the HTML5 is available from <a href='http://www.w3.org/TR/html5/'>http://www.w3.org/TR/html5/</a>. The <a href='http://dev.w3.org/html5/spec/'>latest editor's draft</a> is available at http://dev.w3.org/html5/spec/.</dd>
|
|
</dl>
|
|
|
|
<h2 class="no-num" id="acknowledgements">Acknowledgements</h2>
|
|
|
|
<p>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, Jason Sobel, Jason Weber, Jonas Sicking, Kyle Scholz,
|
|
Lenny Rachitsky, Nic Jansma, Richard Rabbat, Sergey Novikov, Sigbjorn Vik,
|
|
Steve Souders, Tony Gentilcore for their reviews and feedback.</p>
|
|
</body>
|
|
</html>
|