Bug 1444816 - Use navigation start time in the case where the refresh driver's time stamp is behind from the start time to avoid negative timelime time at the very beginning of document load. r=birtles

MozReview-Commit-ID: GTnDNRMAWNQ

--HG--
extra : rebase_source : c741ffdd9b90bf1e11ebc3dfc462b60e032aa2f4
This commit is contained in:
Hiroyuki Ikezoe 2018-07-25 09:41:14 +09:00
Родитель 580f683896
Коммит ba664f7542
3 изменённых файлов: 18 добавлений и 13 удалений

Просмотреть файл

@ -91,17 +91,22 @@ DocumentTimeline::GetCurrentTimeStamp() const
? refreshTime
: mLastRefreshDriverTime;
nsDOMNavigationTiming* timing = mDocument->GetNavigationTiming();
// If we don't have a refresh driver and we've never had one use the
// timeline's zero time.
if (result.IsNull()) {
nsDOMNavigationTiming* timing = mDocument->GetNavigationTiming();
if (timing) {
result = timing->GetNavigationStartTimeStamp();
// Also, let this time represent the current refresh time. This way
// we'll save it as the last refresh time and skip looking up
// navigation timing each time.
refreshTime = result;
}
// In addition, it's possible that our refresh driver's timestamp is behind
// from the navigation start time because the refresh driver timestamp is
// sent through an IPC call whereas the navigation time is set by calling
// TimeStamp::Now() directly. In such cases we also use the timeline's zero
// time.
if (timing &&
(result.IsNull() ||
result < timing->GetNavigationStartTimeStamp())) {
result = timing->GetNavigationStartTimeStamp();
// Also, let this time represent the current refresh time. This way
// we'll save it as the last refresh time and skip looking up
// navigation start time each time.
refreshTime = result;
}
if (!refreshTime.IsNull()) {

Просмотреть файл

@ -27,8 +27,8 @@ test(function() {
});
async_test(function(t) {
assert_greater_than(document.timeline.currentTime, 0,
'document.timeline.currentTime is positive');
assert_greater_than_equal(document.timeline.currentTime, 0,
'document.timeline.currentTime is positive or zero');
// document.timeline.currentTime should be set even before document
// load fires. We expect this code to be run before document load and hence
// the above assertion is sufficient.

Просмотреть файл

@ -10,8 +10,8 @@
'use strict';
async_test(t => {
assert_true(document.timeline.currentTime > 0,
'The current time is initially is positive');
assert_greater_than_equal(document.timeline.currentTime, 0,
'The current time is initially is positive or zero');
// document.timeline.currentTime should be set even before document
// load fires. We expect this code to be run before document load and hence
// the above assertion is sufficient.