Bug 1403926 - Make the PerformanceNavigationTiming timestamps be relative to startTime r=baku
MozReview-Commit-ID: 7lvSsde9dzh
--- a/dom/performance/PerformanceMainThread.cpp
+++ b/dom/performance/PerformanceMainThread.cpp
@@ -309,17 +309,19 @@ PerformanceMainThread::CreationTime() co
return GetDOMTiming()->GetNavigationStart();
}
void
PerformanceMainThread::EnsureDocEntry()
{
if (!mDocEntry && nsContentUtils::IsPerformanceNavigationTimingEnabled()) {
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
- mDocEntry = new PerformanceNavigationTiming(Timing(), this,
+ RefPtr<PerformanceTiming> timing =
+ new PerformanceTiming(this, mChannel, nullptr, 0);
+ mDocEntry = new PerformanceNavigationTiming(timing, this,
httpChannel);
}
}
void
PerformanceMainThread::GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval)
{
--- a/dom/performance/PerformanceNavigationTiming.h
+++ b/dom/performance/PerformanceNavigationTiming.h
@@ -19,16 +19,20 @@ namespace dom {
// https://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming
class PerformanceNavigationTiming final
: public PerformanceResourceTiming
{
public:
NS_DECL_ISUPPORTS_INHERITED
+ // Note that aPerformanceTiming must be initalized with zeroTime = 0
+ // so that timestamps are relative to startTime, as opposed to the
+ // performance.timing object for which timestamps are absolute and has a
+ // zeroTime initialized to navigationStart
explicit PerformanceNavigationTiming(PerformanceTiming* aPerformanceTiming,
Performance* aPerformance,
nsIHttpChannel* aChannel)
: PerformanceResourceTiming(aPerformanceTiming, aPerformance,
NS_LITERAL_STRING("document"), aChannel) {
SetEntryType(NS_LITERAL_STRING("navigation"));
SetInitiatorType(NS_LITERAL_STRING("navigation"));
}