Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: tools/perf/metrics/speedindex.js

Issue 23971004: Account for the case when there are no resource timings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/speedindex.js
diff --git a/tools/perf/metrics/speedindex.js b/tools/perf/metrics/speedindex.js
index b58b704e42e9d38f8f2bc0eef43a2ebe0455a412..c64f38b1667be1901935f3ec6afb6b9cc3a8f2a5 100644
--- a/tools/perf/metrics/speedindex.js
+++ b/tools/perf/metrics/speedindex.js
@@ -44,7 +44,6 @@
* timings for resources such as images and script files, and it includes
* resources requested via XMLHttpRequest.
*
- *
* @return {number} The time since either the load event, or the last
* the last resource was received after the load event. If the load
* event hasn't yet happened, return 0.
@@ -65,7 +64,10 @@
// so we must also get load time in the same terms.
var timing = window.performance.timing;
var loadTime = timing.loadEventEnd - timing.navigationStart;
- if (loadTime > lastEntry.responseEnd) {
+
+ // If there have been no resource timing entries, or the last entry was
+ // before the load event, then return the time since the load event.
+ if (!lastEntry || lastEntry.responseEnd < loadTime) {
return window.performance.now() - loadTime;
}
return window.performance.now() - lastEntry.responseEnd;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698