Account for the case when there are no resource timings

BUG=

Review URL: https://chromiumcodereview.appspot.com/23971004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221502 0039d316-1c4b-4281-b951-d872f2087c98
parent a2f5a48c
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
* timings for resources such as images and script files, and it includes * timings for resources such as images and script files, and it includes
* resources requested via XMLHttpRequest. * resources requested via XMLHttpRequest.
* *
*
* @return {number} The time since either the load event, or the last * @return {number} The time since either the load event, or the last
* the last resource was received after the load event. If the load * the last resource was received after the load event. If the load
* event hasn't yet happened, return 0. * event hasn't yet happened, return 0.
...@@ -65,7 +64,10 @@ ...@@ -65,7 +64,10 @@
// so we must also get load time in the same terms. // so we must also get load time in the same terms.
var timing = window.performance.timing; var timing = window.performance.timing;
var loadTime = timing.loadEventEnd - timing.navigationStart; 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() - loadTime;
} }
return window.performance.now() - lastEntry.responseEnd; return window.performance.now() - lastEntry.responseEnd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment