(win, startEvent, endEvent)
| 118 | * if it is not yet available, or value as string |
| 119 | */ |
| 120 | export 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. |
no test coverage detected