MCPcopy
hub / github.com/ampproject/amphtml / getTimingDataSync

Function getTimingDataSync

src/service/variable-source.js:120–138  ·  view source on GitHub ↗
(win, startEvent, endEvent)

Source from the content-addressed store, hash-verified

118 * if it is not yet available, or value as string
119 */
120export function getTimingDataSync(win, startEvent, endEvent) {
121 const timingInfo = win['performance'] && win['performance']['timing'];
122 if (!timingInfo || timingInfo['navigationStart'] == 0) {
123 // Navigation timing API is not supported.
124 return;
125 }
126
127 const metric =
128 endEvent === undefined
129 ? timingInfo[startEvent]
130 : timingInfo[endEvent] - timingInfo[startEvent];
131
132 if (!isFiniteNumber(metric) || metric < 0) {
133 // The metric is not supported.
134 return;
135 } else {
136 return metric;
137 }
138}
139
140/**
141 * Returns navigation information from the current browsing context.

Callers 5

setTimingResolver_Method · 0.90
initializeMethod · 0.90
initializeMethod · 0.90
getTimingDataAsyncFunction · 0.85

Calls 1

isFiniteNumberFunction · 0.90

Tested by

no test coverage detected