W3C

ナビの計時 — Navigation Timing Level 2

編集者草案

この日本語訳は非公式な文書です…
この文書についての詳細
索引など

要約

この仕様は、 web アプリが文書のナビに関する完全な計時情報にアクセスするためのインタフェースを定義する。 This specification defines an interface for web applications to access the complete timing information for navigation of a document.

この文書の位置付け

これは、 編集者草案の公な複製です… 【以下、この節の他の内容は,W3C 日本語訳 共通ページこの文書についての詳細に移譲。】

Navigation Timing 2 は、 その最初のバージョンである [NAVIGATION-TIMING] を置き換えるものであり、 次に挙げる変更を含んでいます: Navigation Timing 2 replaces the first version of [NAVIGATION-TIMING] and includes the following changes:

1. 序論

この節は規範的ではない。This section is non-normative.

web アプリの処理能特性の測定法は、 web アプリをより高速にするために重要な側面になる。 [JSMEASURE] などの JavaScript に基づく仕組みは、 アプリにおける利用者の待ち時間( latency )測定用の包括的な手段を供せる一方で、 多くの事例で,それらは端点間における待ち時間の完全なあるいは詳細な様相を供せない。 例えば,次の JavaScript は、 ページが全部的に load されるまでの時間を,ごく素朴に測定しようと試みる: Accurately measuring performance characteristics of web applications is an important aspect of making web applications faster. While JavaScript-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 or detailed end-to-end latency picture. For example, the following JavaScript shows a naive attempt to measure the time it takes to fully load a page:

<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>

上のスクリプトは head タグ内の最初の JavaScript コードが実行されて以降から,ページが load されるまでの時間は計算するが、 サーバからページを得るために要した時間や, ページの初期化 lifecycle についての情報は与えない。 The above 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, or the initialization lifecycle of the page.

この仕様は、 文書のナビに関係する高分解能な処理能計量データを格納する/検索取得するための, [PERFORMANCE-TIMELINE-2] に関与する PerformanceNavigationTiming インタフェースを定義する。 PerformanceNavigationTiming インタフェースは [HR-TIME] を利用するので、 すべての時刻値は, 当のエントリに関連する設定群オブジェクト時刻起点を基準に測定される。 【したがって、 PerformanceNavigationTiming インタフェースが返す時刻値 0 は,時刻起点を表すことになる。】 This specification defines the PerformanceNavigationTiming interface which participates in the [PERFORMANCE-TIMELINE-2] to store and retrieve high resolution performance metric data related to the navigation of a document. As the PerformanceNavigationTiming interface uses [HR-TIME], all time values are measured with respect to the time origin of the entry's relevant settings object.

例えば,HTTP 応答の終了がナビの開始から 100ms 後であったとするなら、 PerformanceNavigationTiming のデータは次の様になるであろう: For example, if we know that the response end occurs 100ms after the start of navigation, the PerformanceNavigationTiming data could look like so:

startTime:           0.000  /* 
ナビ要請の開始時刻
start time of the navigation request */
responseEnd:       100.000  /* 
最後のバイトが受信された高分解能な時刻
high resolution time of last received byte */

文書のナビに関係する正確な計時データを得るために, PerformanceNavigationTiming インタフェースを利用する例を次のスクリプトに示す: The following script shows how a developer can use the PerformanceNavigationTiming interface to obtain accurate timing data related to the navigation of the document:

<script>
function showNavigationDetails() {
  /* 
最初のエントリを取得する
Get the first entry */
  const [entry] = performance.getEntriesByType("navigation");
  /* 
結果を開発者コンソール内に表の形で示す
Show it in a nice table in the developer console */
  console.table(entry.toJSON());
}
</script>
<body onload="showNavigationDetails()">
【 利用中の UA で、 このスクリプトに等価な処理を
(結果はコンソールではなく,ここに示される)
【 他ページでも利用できるブックマークレット(結果はコンソールに示される) 】【 レベル 1 実装用のものもある 】

2. 各種用語

【 この節の内容うち一部は省略する。 】 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.

【この仕様の API の記述に現れる】 現在の文書current document )は、 これ°関連する大域オブジェクトである】window結び付けられた文書を指す。 The term current document refers to the document associated with the Window object's newest Document object.

【 加えて, “前文書” ( previous document )は、 現在の文書へナビゲートされる前の時点で,同じナビ可能にて作動中な文書であったものを指す(もしあれば)。 】

この仕様を通して、 時刻は,文書のナビの開始からミリ秒数で測定される。 例えば,文書のナビの開始は、 時刻 0 で生じる。 語 “〜の時刻” は、[ 文書のナビの開始から その時点までに経過したミリ秒数 ]による時刻を指す。 この[ 時刻の定義 ]は、 [HR-TIME] に基づく。 Throughout this work, all time values are measured in milliseconds since the start of navigation of the document. For example, the start of navigation of the document occurs at time 0. The term current time refers to the number of milliseconds since the start of navigation of the document until the current moment in time. This definition of time is based on [HR-TIME] specification.

3. ナビの計時

3.1. PerformanceEntry インタフェースとの関係

PerformanceNavigationTiming インタフェースは、 次に挙げる[ PerformanceEntry インタフェースの属性 ]を拡張する: PerformanceNavigationTiming interface extends the following attributes of PerformanceEntry interface:

  • entryType 取得子手続きは :RETURN "navigation" The entryType getter step is to return the DOMString "navigation".
  • startTime 取得子手続きは :RETURN DOMHighResTimeStamp 値 0 The startTime getter step is to return a DOMHighResTimeStamp with a time value of 0.
  • duration 取得子手続きは :RETURNこれ°startTime からこれ°loadEventEnd までの時間差 ]に等しい DOMHighResTimeStampThe duration getter step is to return a DOMHighResTimeStamp equal to the difference between loadEventEnd and this's startTime.

注記: PerformanceNavigationTiming を実装する UA は、 そのサポートを開発者が検出できるよう,window 文脈用の supportedEntryTypes 内に "navigation" を含める必要がある。 Note A user agent implementing PerformanceNavigationTiming would need to include "navigation" in supportedEntryTypes for Window contexts. This allows developers to detect support for Navigation Timing.

3.2. PerformanceResourceTiming インタフェースとの関係

PerformanceNavigationTiming インタフェースは、 次に挙げる[ PerformanceResourceTiming インタフェースの属性 ]を拡張する: PerformanceNavigationTiming interface extends the following attributes of the PerformanceResourceTiming interface:

  • redirectStart 取得子手続きは: The redirectStart getter steps are to perform the following steps:

    1. IFこれ°リダイレクト回数 0 ] :RETURN 0 If this's [=PerformanceNavigationTiming/redirect count] is 0, return 0.
    2. RETURN これ°redirectStart PerformanceResourceTimingredirectStart 取得子手続き() 】 Otherwise return this's redirectStart.
  • redirectEnd 取得子手続きは: The redirectEnd getter steps are to perform the following steps:

    1. IFこれ°リダイレクト回数 0 ] :RETURN 0 If this's [=PerformanceNavigationTiming/redirect count] is 0, return 0.
    2. RETURN これ°redirectEnd PerformanceResourceTimingredirectEnd 取得子手続き() 】 Otherwise return this's redirectEnd.
  • workerStart 取得子手続きは: The workerStart getter steps are to perform the following steps:

    1. worker 計時 :← これ°service worker 計時 Let workerTiming be this's service worker timing.
    2. IFworker 計時 null ] :RETURN これ°の prototype の workerStart 取得子手続き() If workerTiming is null, then return this's prototype's workerStart.
    3. RETURN worker 計時開始時刻 Return workerTiming's start time.

    注記: workerStartPerformanceResourceTiming にて公開されるが、 ナビ計時における その意味は異なる — ナビは、 下位リソースと違って, service worker の[ 作動化/稼働 ]を誘発し得るので。 ナビ計時の文脈における workerStart は、 当の worker が作動化されるか開始される直前に測定された時刻印を返す。 精確な定義は、 [service-workers] を見よ。 Note Though workerStart is exposed in PerformanceResourceTiming, it has a different meaning in Navigation Timing, as unlike subresources, a navigation may trigger the activation or running of a service worker. In the context of Navigation Timing, workerStart returns the timestamp measured just before the worker has been activated or started. See [service-workers] for a precise definition.

  • fetchStart 取得子手続きは: The workerStart getter steps are to perform the following steps:

    1. worker 計時 :← これ°service worker 計時 Let workerTiming be this's service worker timing.
    2. IFworker 計時 null ] :RETURN これ°の prototype の fetchStart 取得子手続き() If workerTiming is null, then return this's prototype's fetchStart.
    3. RETURN worker 計時fetch イベント配送時刻 Return workerTiming's fetch event dispatch time.

    注記: service worker がナビの一部として利用される場合、 ナビ計時における fetchStart の意味は, PerformanceResourceTiming における それと異なる。 それは、[ service worker に向けて FetchEvent が配送される直前 ]に測定された時刻印を返す。 現在の文書のナビ計時エントリにおける[ workerStartfetchStart の時間差 ]を利用すれば、 当の worker が[ 初期化される/作動化される ]までにかかった およその時間を決定できる。 精確な定義は、 [service-workers] を見よ。 Note When a service worker is used as part of the navigation, The fetchStart overload holds a different meaning than the meaning in PerformanceResourceTiming. It returns the timestamp measured right before the FetchEvent is dispatched for the service worker. The time difference between workerStart and fetchStart in the document's navigation timing entry can be used to determine roughly how long it took for the worker to be initialized or activated. See [service-workers] for a precise definition.

注記: 処理能時列線に含められるのは、 現在の文書を与えるリソースに限られる — 処理能時列線内にある PerformanceNavigationTiming オブジェクトは 1 個に限られる。 Note Only the current document resource is included in the performance timeline; there is only one PerformanceNavigationTiming object in the performance timeline.

3.3. PerformanceNavigationTiming インタフェース

注記: HTTP キャッシュ [RFC7234] を検査して,そこから内容を検索取得することは、 fetch 処理の一部を成す。 それは、[ requestStart, responseStart, responseEnd ]属性が受け持つ。 Note Checking and retrieving contents from the HTTP cache [RFC7234] is part of the fetching process. It's covered by the requestStart, responseStart and responseEnd attributes.

[Exposed=Window]
interface PerformanceNavigationTiming : PerformanceResourceTiming {
    readonly attribute DOMHighResTimeStamp unloadEventStart;
    readonly attribute DOMHighResTimeStamp unloadEventEnd;
    readonly attribute DOMHighResTimeStamp domInteractive;
    readonly attribute DOMHighResTimeStamp domContentLoadedEventStart;
    readonly attribute DOMHighResTimeStamp domContentLoadedEventEnd;
    readonly attribute DOMHighResTimeStamp domComplete;
    readonly attribute DOMHighResTimeStamp loadEventStart;
    readonly attribute DOMHighResTimeStamp loadEventEnd;
    readonly attribute NavigationTimingType type;
    readonly attribute unsigned short redirectCount;
    readonly attribute DOMHighResTimeStamp criticalCHRestart;
    readonly attribute NotRestoredReasons? notRestoredReasons;
    [Default] object toJSON();
};

PerformanceNavigationTiming オブジェクトには、 次に挙げるものが結び付けられる:

  • 文書 load 計時文書 load 計時情報 A PerformanceNavigationTiming has an associated document load timing info document load timing.
  • 前文書の unload 計時文書 unload 計時情報 A PerformanceNavigationTiming has an associated document unload timing info previous document unload timing.
  • リダイレクト回数整数 A PerformanceNavigationTiming has an associated number redirect count.
  • ナビ種別NavigationTimingTypeA PerformanceNavigationTiming has an associated NavigationTimingType navigation type.
  • Critical-CH restart 時刻DOMHighResTimeStampA PerformanceNavigationTiming has an associated DOMHighResTimeStamp Critical-CH restart time.

    【 Critical-CH は、 HTTP ヘッダ名 — 参考: 仕様, MDN

  • 復旧されない事由群NotRestoredReasons オブジェクト A PerformanceNavigationTiming has an associated NotRestoredReasons not restored reasons.
  • service worker 計時 null /service worker 計時情報 A PerformanceNavigationTiming has an associated null or service worker timing info service worker timing.

unloadEventStart 取得子手続きは :RETURN これ°前文書の unload 計時unload イベント開始時刻 The unloadEventStart getter steps are to return this's previous document unload timing's unload event start time.

注記: 前文書は在る, かつ それは現在の文書同一生成元である場合、 この時刻印は,UA が前文書の unload イベントを — 文書を unload する手続きの中で — 開始する直前に測定される。 他の場合、 この属性は 0 を返すことになる。 Note If the previous document and the current document have the same origin, this timestamp is measured 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 will return zero.

unloadEventEnd 取得子手続きは :RETURN これ°前文書の unload 計時unload イベント終了時刻 The unloadEventEnd getter steps are to return this's previous document unload timing's unload event end time.

注記: 前文書は在る, かつ それは現在の文書同一生成元である場合、 この時刻印は,UA が前文書の unload イベントを — 文書を unload する手続きの中で — 取り扱った直後に測定される。 他の場合、 この属性は 0 を返すことになる。 Note If the previous document and the current document have the same origin, this timestamp is measured immediately after the user agent handles 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 will return zero.

domInteractive 取得子手続きは :RETURN これ°文書 load 計時DOM 対話的時刻 The domInteractive getter steps are to return this's document load timing's DOM interactive time.

注記: この時刻印は、 UA が現在の文書現在の準備度を "interactive" に設定する前に測定される。 Note This timestamp is measured before the user agent sets the current document readiness to "interactive".

domContentLoadedEventStart 取得子手続きは :RETURN これ°文書 load 計時DOMContentLoaded イベント開始時刻 The domContentLoadedEventStart getter steps are to return this's document load timing's DOM content loaded event start time.

注記: この時刻印は、 UA が現在の文書に向けて DOMContentLoaded イベントを配送する直前に測定される。 Note This timestamp is measured before the user agent dispatches the DOMContentLoaded event.

domContentLoadedEventEnd 取得子手続きは :RETURN これ°文書 load 計時DOMContentLoaded イベント終了時刻 The domContentLoadedEventEnd getter steps are to return this's document load timing's DOM content loaded event end time.

注記: この時刻印は、 UA が現在の文書に対する DOMContentLoaded イベントの取り扱いを完了した直後に測定される。 Note This timestamp is measured after the user agent completes handling of the DOMContentLoaded event.

domComplete 取得子手続きは :RETURN これ°文書 load 計時DOM 完了時刻 The domComplete getter steps are to return this's document load timing's DOM complete time.

注記: この時刻印は、 UA が現在の文書現在の準備度を "complete" に設定する前に測定される。 精確な定義は、 現在の準備度を見よ。 Note This timestamp is measured before the user agent sets the current document readiness to "complete". See document readiness for a precise definition.

loadEventStart 取得子手続きは :RETURN これ°文書 load 計時load イベント開始時刻 The loadEventStart getter steps are to return this's document load timing's load event start time.

注記: この時刻印は、 UA が現在の文書に向けて load イベントを配送する直前に測定される。 Note This timestamp is measured before the user agent dispatches the load event for the document.

loadEventEnd 取得子手続きは :RETURN これ°文書 load 計時load イベント終了時刻 The loadEventEnd getter steps are to return this's document load timing's load event end time.

注記: この時刻印は、 UA が現在の文書に対する load イベントの取り扱いを完了した後に測定される。 Note This timestamp is measured after the user agent completes handling the load event for the document.

type 取得子手続きは :RETURN これ°ナビ種別 The type getter steps are to run the this's navigation type.

注記: refresh pragma 指令を利用する類いの,クライアント側リダイレクトは、 この仕様においては HTTP リダイレクトとは見なされない。 そのような事例では、 type 属性は適切な値を返すべきである — [ 現在のページを reload している場合は "reload" / 新たな URL へナビゲートしている場合は "navigate" ]など。 Note Client-side redirects, such as those using the Refresh pragma directive, are not considered HTTP redirects by this spec. In those cases, the type attribute SHOULD return appropriate value, such as reload if reloading the current page, or navigate if navigating to a new URL.

redirectCount 取得子手続きは :RETURN これ°リダイレクト回数 The redirectCount getter steps are to return this's redirect count.

criticalCHRestart 取得子手続きは :RETURN これ°Critical-CH restart 時刻 The criticalCHRestart getter steps are to return this's Critical-CH restart time.

注記: criticalCHRestart は、 0 でないならば,[ navigationStarttimeOrigin, unloadEventStart, unloadEventEnd ]以外の時刻印より前になる — それは、[ ナビのリダイレクションを成す部分が restart した時点 ]をマークするので。 If criticalCHRestart is not 0 it will be before all other timestamps except for navigationStart, unloadEventStart, and unloadEventEnd. This is because it marks the moment the redirection part of the navigation was restarted.

notRestoredReasons 取得子手続きは :RETURN これ°復旧されない事由群 The notRestoredReasons getter steps are to return this's not restored reasons.

toJSON() メソッドは、 これ°用の既定の toJSON 手続きを走らす。 The toJSON() method runs the default toJSON steps for this.

3.3.1. NavigationTimingType 列挙

enum NavigationTimingType {
    "navigate",
    "reload",
    "back_forward",
    "prerender"
};

各種 値は、 以下の定義に従う: The values are defined as follows:

"navigate"
当のナビにおける履歴取り扱いのふるまいは[ "push""replace" ]に設定されていて、 当のナビは prerender ヒント [RESOURCE-HINTS] により起動されてはいない。 Navigation where the history handling behavior is set to "default" or "replace" and the navigation was not initiated by a prerender hint [RESOURCE-HINTS].
"reload"
当のナビは、 当のナビ可能読み込み直したNavigation where the navigable was reloaded.
"back_forward"
当のナビは、 履歴から適用されたNavigation that's applied from history.
"prerender"
当のナビは、 prerender ヒント [RESOURCE-HINTS] により起動された。 Navigation initiated by a prerender hint [RESOURCE-HINTS].

注記: 上の列挙値 "back_forward" は Web IDL が推奨する列挙値の形式に整合していないが、 出荷済み実装との後方互換性を保つため,変更するわけにはいかない。 [WebIDL] Note The format of the above enumeration value is inconsistent with the WebIDL recommendation for formatting of enumeration values. Unfortunately, we are unable to change it due to backwards compatibility issues with shipped implementations. [WebIDL]

4. ナビ計時属性

【 この節は規範的ではない。 (この節の原文のタイトルは “処理モデル” であるが、 処理モデルは,各種 “計時情報” として他の仕様( [FETCH], [HTML] など)に統合された。) 】 4. Process4.1. Processing Model

PerformanceNavigationTiming インタフェースにて定義される計時属性を次の図式に示す。 括弧内の属性は、 同一生成元でない文書を孕むナビでは可用でない。 Figure 1 This figure illustrates the timing attributes defined by the PerformanceNavigationTiming interface. Attributes in parenthesis indicate that they may not be available for navigations involving documents from different origins.
(時間は下に向かって進行する。) startTime 0 になる
リダイレクト 〜 応答: [RESOURCE-TIMING] による図式を見よ ← ( unloadEventStart ) unload イベントの処理(応答と並列的) ← ( unloadEventEnd )
domInteractive domContentLoadedEventStart 処理 domContentLoadedEventEnd domComplete loadEventStart load loadEventEnd

【 原文では,[ リダイレクト 〜 応答 ]の箇所にも PerformanceResourceTiming [RESOURCE-TIMING] に定義される各属性が記されているが、 その仕様の図式と重複するので,和訳では省略する。 】【 この訳では、 原文の図式( SVG )を HTML と CSS による等価な図式に差し替えている。 】

5. ナビ計時エントリの作成法

文書には、 ナビ計時エントリ が結び付けられ,初期時には ε (未設定)とする。 Each document has an associated navigation timing entry, initially unset.

ナビ計時エントリを作成する アルゴリズムは、 所与の :文書 文書, fetch 計時情報 fetch 計時, 整数 リダイレクト回数, NavigationTimingType ナビ種別, null /service worker 計時情報 service worker 計時, 文字列 キャッシュモード, DOMHighResTimeStamp Critical-CH restart , 応答本体情報 本体情報 に対し: To create the navigation timing entry for Document document, given a fetch timing info fetchTiming, a number redirectCount, a NavigationTimingType navigationType, a null or service worker timing info serviceWorkerTiming, a DOMString cacheMode, a DOMHighResTimeStamp criticalCHRestart, and a response body info bodyInfo, do the following:

  1. 大域オブジェクト :← 文書関連する大域オブジェクト Let global be document's relevant global object.
  2. realm :← 大域オブジェクトrealm
  3. ナビ計時エントリ :← 新たなオブジェクト( PerformanceNavigationTiming, realm ) Let navigationTimingEntry be a new PerformanceNavigationTiming object in global's realm.
  4. リソース計時エントリを設定しておく( ↓ ) :ナビ計時エントリ, "navigation", 文書URL , fetch 計時, キャッシュモード, 本体情報 Setup the resource timing entry for navigationTimingEntry given "navigation", document's URL, fetchTiming, cacheMode, and bodyInfo.
  5. 復旧されない事由群 :← NotRestoredReasons オブジェクトを作成する( 文書の復旧されない事由群( 文書 )【, realm )
  6. ナビ計時エントリ の :文書 load 計時文書load 計時情報, 前文書の unload 計時文書前文書の unload 計時情報, リダイレクト回数リダイレクト回数, ナビ種別ナビ種別, service worker 計時service worker 計時, Critical-CH restart 時刻Critical-CH restart , 復旧されない事由群復旧されない事由群 Set navigationTimingEntry's document load timing to document's load timing infoSet navigationTimingEntry's previous document unload timing to document's previous document unload timing.Set navigationTimingEntry's redirect count to redirectCount.Set navigationTimingEntry's navigation type to navigationType.Set navigationTimingEntry's service worker timing to serviceWorkerTiming.↓ Set document's navigation timing entry to navigationTimingEntry.Set navigationTimingEntry's Critical-CH restart time to criticalCHRestart.Set navigationTimingEntry's not restored reasons to the result of creating a NotRestoredReasons object given document's not restored reasons.
  7. 文書ナビ計時エントリナビ計時エントリ
  8. 大域オブジェクト 【の処理能エントリバッファマップ[ "navigation" ] 】処理能エントリバッファナビ計時エントリ を追加する add navigationTimingEntry to global's performance entry buffer.

ナビ計時をキューする アルゴリズムは、 所与の ( 文書 文書 ) に対し :処理能エントリをキューする( 文書ナビ計時エントリ ) To queue the navigation timing entry for Document document, queue document's navigation timing entry.

プライバシーの考慮点

この節は規範的ではない。This section is non-normative.

情報の流出 5.1.1. Information disclosure
注意深く細工された計時攻撃の利用により、 末端利用者による[ 閲覧/行動 ]の履歴が流出する可能性がある。 一例として、 unload 時刻から前のページの unload ハンドラに要した時間が明らかにされ,利用者のログイン状態°の推定に利用され得る。 これらの攻撃は、 文書を unload するときに — 新たなページでセッション履歴を更新する アルゴリズム [HTML] の中で — 同一生成元の検査を施行することにより軽減される。 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 check algorithm when unloading a document, as detailed in the HTML spec.
緩い同一生成元施策は、 文書間に渡る,未承認の訪問に対する十分な保護を供さない。 共有ホストにおいては、 信頼できない第三者主体が,同じ IP アドレスの異なるポート上で HTTP サーバをホストし得る。 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.
ディレクトリ間をまたがるアクセス 5.1.2. Cross-directory access
同じホスト名を共有する異なるページ — 例えば、 同じサイトにホストされている,利用者が生成した内容を伴う, 異なる作者による内容 — は、 パス名に基いてアクセスを制約するような特能がないため,同一生成元から来たものと見なされる。 これらのページ間のナビに際しては、 後のページから,リダイレクションや unload イベントに対する計時など,前のページの計時情報へのアクセスが可能になる。 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.

セキュリティの考慮点

この節は規範的ではない。This section is non-normative.

PerformanceNavigationTiming インタフェースは、 前文書についての計時情報を現在の文書に公開する。 PerformanceNavigationTiming の属性のうち,前文書の情報を含むものへのアクセスを制限するため、 前文書を unload するときに — 新たなページでセッション履歴を更新する アルゴリズム [HTML] の中で — 同一生成元施策が施行され,【失敗した場合は】前文書に関係する属性は 0 に設定される。 The PerformanceNavigationTiming interface exposes timing information about the previous document to the current document. To limit the access to PerformanceNavigationTiming attributes which include information on the previous document, the previous document unloading algorithm enforces the same origin policy and attributes related to the previous document are set to zero.

プロキシサーバの検出法 5.2.1. Detecting proxy servers
UA と web サーバとの間にプロキシが配備されている場合、 connectStart 属性と connectEnd 属性との間の時区間は、 web サーバではなく,プロキシと UA との間の待ち時間を示すものになる。 それにより、 web サーバは,プロキシの存在を推定できる可能性がある。 SOCKS プロキシについては、 この時区間にはプロキシ認証に要した時間とプロキシが web サーバへの接続に要した時間も含まれ,プロキシの検出を難しくする。 HTTP プロキシの場合、 UA はプロキシサーバについての知識を一切持たないこともあるので、 この攻撃を常に軽減できるとは限らない。 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.

廃用

この節では、 以前に [NAVIGATION-TIMING] レベル 1 にて導入された[ 属性, インタフェース ]を定義し,後方互換性のために ここに保つ。 作者には、 以下のインタフェースを利用するべきでない — 新たな PerformanceNavigationTiming インタフェースを利用することを強く勧める。 変更点と改善点の要約を見よ。 This section defines attributes and interfaces previously introduced in [NAVIGATION-TIMING] Level 1 and are kept here for backwards compatibility. Authors should not use the following interfaces and are strongly advised to use the new PerformanceNavigationTiming interface—see summary of changes and improvements.

【この訳( レベル 1 )に特有な表記規約】

この節にて原文が参照する HTTP 用語は,過去の HTTP 仕様 [RFC2616] を参照しているが、 この訳では,最新な HTTP 仕様( RFC 9110 〜 9112 )の等価な記述を参照することにする。

用語 “前文書( previous document )” は、 現在の文書へナビゲートされる前の時点で,当のナビ可能にて作動中な文書であったものを指す(明確には定義されていない)。

以下における 局所キャッシュ等 は、[ HTTP キャッシュ/局所リソース ]を指す総称である。

PerformanceTiming インタフェース

[Exposed=Window]
interface PerformanceTiming {
  readonly attribute unsigned long long navigationStart;
  readonly attribute unsigned long long unloadEventStart;
  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 secureConnectionStart;
  readonly attribute unsigned long long requestStart;
  readonly attribute unsigned long long responseStart;
  readonly attribute unsigned long long responseEnd;
  readonly attribute unsigned long long domLoading;
  readonly attribute unsigned long long domInteractive;
  readonly attribute unsigned long long domContentLoadedEventStart;
  readonly attribute unsigned long long domContentLoadedEventEnd;
  readonly attribute unsigned long long domComplete;
  readonly attribute unsigned long long loadEventStart;
  readonly attribute unsigned long long loadEventEnd;
  [Default] object toJSON();
};
【 利用中の UA で、 このページについて,これらの属性値を (括弧内は navigationStart からの時間差) 】
(結果はコンソールではなく,ここに示される)

【 他ページでも利用できるブックマークレット(結果はコンソールに示される) 】【 レベル 2 実装用のものもある 】

注記: この節に定義されるすべての時刻値は、 1970 年 1 月 1 日, 午前 0 時( UTC )からミリ秒数で測定される。 Note All time values defined in this section are measured in milliseconds since midnight of January 1, 1970 (UTC).

navigationStart
前文書があるならば UA が前文書に対し unload を prompt し終えた直後の時刻 / 他の場合は 現在の文書が作成された時刻を返すものとする。 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.
注記: この属性は、 PerformanceNavigationTiming 用には定義されていない。 作者は、 代わりに timeOrigin を利用して,等価な時刻印を得れる。 Note This attribute is not defined for PerformanceNavigationTiming. Instead, authors can use timeOrigin to obtain an equivalent timestamp.
unloadEventStart
前文書がある, かつ 前文書と現在の文書が同一生成元に属する場合は,UA が前文書の unload イベントを開始する直前の時刻 / 他の場合は 0 を返すものとする。 If the previous document and the current document have the same origin, 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
前文書はある, かつ 前文書と現在の文書が同一生成元に属する, かつ 前文書の unload イベントは完了している 場合は,UA が そのイベントを終えた直後の時刻 / 他の場合は 0 を返すものとする。 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 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 or the unload is not yet completed, this attribute must return zero.
ナビゲート時に HTTP リダイレクトがあって, かつ その中に同一生成元に属さない HTTP リダイレクトがある場合、[ unloadEventStart, unloadEventEnd ]とも 0 を返すものとする。 If there are HTTP redirects when navigating and not all the redirects are from the same origin, both PerformanceTiming.unloadEventStart and PerformanceTiming.unloadEventEnd must return zero.
redirectStart
ナビゲート時に HTTP リダイレクトがあって, かつ すべての HTTP リダイレクト同一生成元に属する場合は, fetchStart と同じ値 / 他の場合は 0 を返すものとする。 If there are HTTP redirects when navigating and if all the redirects 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
ナビゲート時に HTTP リダイレクトがあって, かつ すべての HTTP リダイレクト同一生成元に属する場合は,その最後のリダイレクトを成す応答の最後のバイトを受信した直後の時刻 / 他の場合は 0 を返すものとする。 If there are HTTP redirects when navigating and all redirects 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
GET 要請メソッドを利用して新たなリソースが fetch された場合は,UA が HTTP キャッシュの検査を開始する直前の時刻 / 他の場合は UA がリソースの fetch を開始した時刻 を返すものとする。 If the new resource is to be fetched using a "GET" request method, fetchStart must return the time immediately before the user agent starts checking the HTTP cache. Otherwise, it must return the time when the user agent starts fetching the resource.
domainLookupStart
現在の文書のドメイン名検索を開始する直前の時刻を返すものとする。 持続的な接続が利用されている,または 現在の文書が局所キャッシュ等から検索取得されている場合、 この属性は fetchStart と同じ値を返すものとする。 This attribute must return the time immediately before the user agent starts the domain name lookup for the current document. If a persistent connection [RFC2616] is used or the current document is retrieved from the HTTP cache or local resources, this attribute must return the same value as PerformanceTiming.fetchStart.
domainLookupEnd
UA が現在の文書に対するドメイン名検索を終えた直後の時刻を返すものとする。 持続的な接続が利用されている,または 現在の文書が局所キャッシュ等から検索取得されている場合、 この属性は fetchStart と同じ値を返すものとする。 This attribute must return the time immediately after the user agent finishes the domain name lookup for the current document. If a persistent connection [RFC2616] is used or the current document is retrieved from the HTTP cache or local resources, this attribute must return the same value as PerformanceTiming.fetchStart.
注記: HTTP キャッシュからの内容の 検査と検索取得は fetch 処理の一部である。 それは、[ requestStart, responseStart, responseEnd ]属性が受け持つ。 Note Checking and retrieving contents from the HTTP cache [RFC2616] is part of the fetching process. It's covered by the PerformanceTiming.requestStart, PerformanceTiming.responseStart and PerformanceTiming.responseEnd attributes.
注記: UA がキャッシュ内にドメイン情報をすでに持っている場合、[ domainLookupStart, domainLookupEnd ]は,順に,UA によるキャッシュからのドメインデータの検索取得を[ 開始, 終了 ]した時刻を表現する。 Note 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
UA が文書を検索取得するためにサーバへの接続を確立し始める直前の時刻を返すものとする。 持続的な接続が利用されている,または 現在の文書が局所キャッシュ等から検索取得されている場合、 この属性は domainLookupEnd と同じ値を返すものとする。 This attribute must return the time immediately before the user agent start establishing the connection to the server to retrieve the document. If a persistent connection [RFC2616] is used or the current document is retrieved from the HTTP cache or local resources, this attribute must return value of PerformanceTiming.domainLookupEnd.
connectEnd
UA が文書を検索取得するためのサーバへの接続を確立し終えた直後の時刻を返すものとする。 持続的な接続が利用されている,または 現在の文書が局所キャッシュ等から検索取得されている場合、 この属性は domainLookupEnd と同じ値を返すものとする。 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 persistent connection [RFC2616] is used or the current document is retrieved from the HTTP cache or local resources, this attribute must return the value of PerformanceTiming.domainLookupEnd.
トランスポート接続が失敗し, かつ UA が接続を再び開いた場合、[ connectStart, connectEnd ]は,新たな接続に対応する値を返すべきである。 If the transport connection fails and the user agent reopens a connection, PerformanceTiming.connectStart and PerformanceTiming.connectEnd should return the corresponding values of the new connection.
connectEnd には、 SSL ハンドシェイクや SOCKS 認証も含めて,トランスポート接続を確立するのに要した時間も含めるものとする。 PerformanceTiming.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
この属性のサポートは任意選択である。 UA は、 この属性を可用にしない場合は, undefined を返すものとする。 可用にする場合、[[ 現在のページの URL スキーム [URL] "https" ]ならば 現在の接続をセキュアにするためのハンドシェイク処理を開始する直前の時刻 / 他の場合は 0 ]を返すものとする。 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 [URL] 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
UA が,現在の文書を[ サーバから, または局所キャッシュ等から ]得るために 要請を開始した直前の時刻を返すものとする。 This attribute must return the time immediately before the user agent starts requesting the current document from the server, or from the HTTP cache or from local resources.
要請を送信した後にトランスポート接続が失敗して, UA が接続を再び開いて要請を送信し直していた場合、 requestStart は,新たな要請に対応している値を返すべきである。 If the transport connection fails after a request is sent and the user agent reopens a connection and resend the request, PerformanceTiming.requestStart should return the corresponding values of the new request.

注記: このインタフェースには requestEnd のような類いの,要請の送信の完了を表現する属性は含まれていない: Note This interface does not include an attribute to represent the completion of sending the request, e.g., requestEnd.

  • UA からの要請の送信の完了は、 (その種の属性の便益のほとんどを占める)ネットワークトランスポートにおける対応する完了­時刻を常に指示するとは限らない。 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.
  • 一部の UA においては、 HTTP 層のカプセル化に因り, 要請の送信を実際に完了した時刻を決定するのにコストがかかる。 Some user agents have high cost to determine the actual completion time of sending the request due to the HTTP layer encapsulation.
responseStart
UA がサーバからの, または局所キャッシュ等からの,応答の最初のバイトを受信した直後の時刻を返すものとする。 This attribute must return the time immediately after the user agent receives the first byte of the response from the server, or from the HTTP cache or from local resources.
responseEnd
UA が 現在の文書の最後のバイトを受信した直後の時刻と, トランスポート接続が閉じらる直前の時刻のうち,早い方を返すものとする。 ここでの文書は、[ サーバ, 局所キャッシュ等 ]いずれかから受信されたものも含まれる。 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, the HTTP cache or from local resources.
domLoading
UA が文書の現在の準備度を "loading" に設定する直前の時刻を返すものとする。 This attribute must return the time immediately before the user agent sets the current document readiness to "loading".
既存の UA 内で文書が いつ作成されたかの違いに因り,この属性が返す値は実装に特有であり、 有意義な計量に利用されるべきではない。 Due to differences in when a Document object is created in existing user agents, the value returned by the domLoading is implementation specific and should not be used in meaningful metrics.
domInteractive
UA が文書の現在の準備度を "interactive" に設定する直前の時刻を返すものとする。 This attribute must return the time immediately before the user agent sets the current document readiness to "interactive".
domContentLoadedEventStart
UA が文書に向けて DOMContentLoaded イベントを発火する直前の時刻を返すものとする。 This attribute must return the time immediately before the user agent fires the DOMContentLoaded event at the Document.
domContentLoadedEventEnd
文書の DOMContentLoaded イベント が完了した直後の時刻を返すものとする。 This attribute must return the time immediately after the document's DOMContentLoaded event completes.
domComplete
UA が文書の現在の準備度を "complete" に設定する直前の時刻を返すものとする。 This attribute must return the time immediately before the user agent sets the current document readiness to "complete".
文書の現在の準備度が複数回にわたり同じ状態に変化した場合、 domLoading, domInteractive, domContentLoadedEventStart, domContentLoadedEventEnd, domComplete は、 最初に生じた 文書の現在の準備度の変化に対応している時刻を返すものとする。 If the current document readiness changes to the same state multiple times, PerformanceTiming.domLoading, PerformanceTiming.domInteractive, PerformanceTiming.domContentLoadedEventStart, PerformanceTiming.domContentLoadedEventEnd and PerformanceTiming.domComplete must return the time of the first occurrence of the corresponding document readiness change.
loadEventStart
現在の文書に load イベントが発火される直前の時刻を返すものとする。 load イベントがまだ発火されていないときには、 0 を返すものとする。 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.
loadEventEnd
現在の文書の load イベントの発火が完了した時刻を返すものとする。 load イベントがまだ発火されていない, またはまだ完了していないときには、 0 を返すものとする。 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.
toJSON
これ°用の既定の toJSON 手続きを走らす。 Runs the default toJSON steps for this.

PerformanceNavigation インタフェース

[Exposed=Window]
interface PerformanceNavigation {
  const unsigned short TYPE_NAVIGATE = 0;
  const unsigned short TYPE_RELOAD = 1;
  const unsigned short TYPE_BACK_FORWARD = 2;
  const unsigned short TYPE_RESERVED = 255;
  readonly attribute unsigned short type;
  readonly attribute unsigned short redirectCount;
  [Default] object toJSON();
};
TYPE_NAVIGATE
当のナビにおける履歴取り扱いのふるまいは[ "push""replace" ]に設定されている。 Navigation where the history handling behavior is set to "default" or "replace".
TYPE_RELOAD
当のナビにおける履歴取り扱いのふるまい再読み込み に設定されている。 【この記述は、過去の HTML 仕様に基づく — "reload" を見よ。】 Navigation where the history handling behavior is set to "reload".
TYPE_BACK_FORWARD
当のナビにおける履歴取り扱いのふるまいエントリ更新 に設定されている。 【この記述は、過去の HTML 仕様に基づく — "back_forward" を見よ。】 Navigation where the history handling behavior is set to "entry update".
TYPE_RESERVED
上で定義されない任意の種別のナビ。 Any navigation types not defined by values above.
type
現在の閲覧文脈における最後の非リダイレクトナビの種別を,上に挙げた定数値のいずれかとして返すものとする。 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.
注記: refresh pragma 指令を利用する類いの,クライアント側によるリダイレクトは、 この仕様においては HTTP リダイレクトとは見なされない。 それらの場合,この属性は、[ 現在のページを reload している場合は TYPE_RELOAD / 新たな URL へナビゲートしている場合は TYPE_NAVIGATE ]など,適切な値を返すべきである。 Note Client-side redirects, such as those using the Refresh pragma directive, are not considered HTTP redirects by this spec. In those cases, the type attribute should return appropriate value, such as TYPE_RELOAD if reloading the current page, or TYPE_NAVIGATE if navigating to a new URL.
redirectCount
現在の閲覧文脈の下での,最後の非リダイレクトナビからのリダイレクト回数を返すものとする。 [ そのようなリダイレクトは無い, または 行先文書と同一生成元に属さないリダイレクトがある ]場合、 0 を返すものとする。 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.
toJSON
これ°用の既定の toJSON 手続きを走らす。 Runs the default toJSON steps for this.

Performance インタフェースに対する拡張

[Exposed=Window]
partial interface Performance {
  [SameObject]
  readonly attribute PerformanceTiming timing;
  [SameObject]
  readonly attribute PerformanceNavigation navigation;
};

Performance インタフェースは [PERFORMANCE-TIMELINE-2] にて定義される。 The Performance interface is defined in [PERFORMANCE-TIMELINE-2].

timing
最後の非リダイレクト ナビ以降の閲覧文脈に関係する計時情報を表現する。 The timing attribute represents the timing information related to the browsing contexts since the last non-redirect navigation.\
この属性は PerformanceTiming インタフェースにより定義される。 This attribute is defined by the PerformanceTiming interface.
navigation
この属性は PerformanceNavigation インタフェースにより定義される。 The navigation attribute is defined by the PerformanceNavigation interface.

謝辞

貢献された次の方々に感謝する:

Thanks to Anne Van Kesteren, Arvind Jain, Boris Zbarsky, Jason Weber, Jonas Sicking, James Simonsen, Karen Anderson, Nic Jansma, Philippe Le Hegaret, Steve Souders, Todd Reifsteck, Tony Gentilcore, William Chan and Zhiheng Wang for their contributions to this work.