|
@@ -0,0 +1,131 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Andrea Marchesini <amarchesini@mozilla.com>
|
|
|
+# Date 1526653219 -7200
|
|
|
+# Node ID cbc132bb5984f025f5a6233d55a937a13358c8bc
|
|
|
+# Parent 280f46f1457c77387d111a2e42f4db88dd000c05
|
|
|
+Bug 1462605 - PerformanceNavigationTiming.name must be the value of the address of the current document, r=valentin
|
|
|
+
|
|
|
+diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
|
|
|
+--- a/dom/performance/PerformanceMainThread.cpp
|
|
|
++++ b/dom/performance/PerformanceMainThread.cpp
|
|
|
+@@ -7,16 +7,45 @@
|
|
|
+ #include "PerformanceMainThread.h"
|
|
|
+ #include "PerformanceNavigation.h"
|
|
|
+ #include "mozilla/dom/DOMPrefs.h"
|
|
|
+ #include "nsICacheInfoChannel.h"
|
|
|
+
|
|
|
+ namespace mozilla {
|
|
|
+ namespace dom {
|
|
|
+
|
|
|
++namespace {
|
|
|
++
|
|
|
++void
|
|
|
++GetURLSpecFromChannel(nsITimedChannel* aChannel, nsAString& aSpec)
|
|
|
++{
|
|
|
++ aSpec.AssignLiteral("document");
|
|
|
++
|
|
|
++ nsCOMPtr<nsIChannel> channel = do_QueryInterface(aChannel);
|
|
|
++ if (!channel) {
|
|
|
++ return;
|
|
|
++ }
|
|
|
++
|
|
|
++ nsCOMPtr<nsIURI> uri;
|
|
|
++ nsresult rv = channel->GetURI(getter_AddRefs(uri));
|
|
|
++ if (NS_WARN_IF(NS_FAILED(rv)) || !uri) {
|
|
|
++ return;
|
|
|
++ }
|
|
|
++
|
|
|
++ nsAutoCString spec;
|
|
|
++ rv = uri->GetSpec(spec);
|
|
|
++ if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
++ return;
|
|
|
++ }
|
|
|
++
|
|
|
++ aSpec = NS_ConvertUTF8toUTF16(spec);
|
|
|
++}
|
|
|
++
|
|
|
++} // anonymous
|
|
|
++
|
|
|
+ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread)
|
|
|
+
|
|
|
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
|
|
|
+ Performance)
|
|
|
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming,
|
|
|
+ mNavigation,
|
|
|
+ mDocEntry)
|
|
|
+ tmp->mMozMemory = nullptr;
|
|
|
+@@ -288,33 +317,39 @@ PerformanceMainThread::EnsureDocEntry()
|
|
|
+ UniquePtr<PerformanceTimingData> timing(
|
|
|
+ new PerformanceTimingData(mChannel, nullptr, 0));
|
|
|
+
|
|
|
+ nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
|
|
+ if (httpChannel) {
|
|
|
+ timing->SetPropertiesFromHttpChannel(httpChannel);
|
|
|
+ }
|
|
|
+
|
|
|
+- mDocEntry = new PerformanceNavigationTiming(std::move(timing), this);
|
|
|
++ nsAutoString name;
|
|
|
++ GetURLSpecFromChannel(mChannel, name);
|
|
|
++
|
|
|
++ mDocEntry = new PerformanceNavigationTiming(std::move(timing), this, name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ PerformanceMainThread::CreateDocumentEntry(nsITimedChannel* aChannel)
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aChannel);
|
|
|
+ MOZ_ASSERT(!mDocEntry, "mDocEntry should be null.");
|
|
|
+
|
|
|
+ if (!nsContentUtils::IsPerformanceNavigationTimingEnabled()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
++ nsAutoString name;
|
|
|
++ GetURLSpecFromChannel(aChannel, name);
|
|
|
++
|
|
|
+ UniquePtr<PerformanceTimingData> timing(
|
|
|
+ new PerformanceTimingData(aChannel, nullptr, 0));
|
|
|
+- mDocEntry = new PerformanceNavigationTiming(Move(timing), this);
|
|
|
++ mDocEntry = new PerformanceNavigationTiming(Move(timing), this, name);
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ PerformanceMainThread::GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval)
|
|
|
+ {
|
|
|
+ // We return an empty list when 'privacy.resistFingerprinting' is on.
|
|
|
+ if (nsContentUtils::ShouldResistFingerprinting()) {
|
|
|
+ aRetval.Clear();
|
|
|
+diff --git a/dom/performance/PerformanceNavigationTiming.h b/dom/performance/PerformanceNavigationTiming.h
|
|
|
+--- a/dom/performance/PerformanceNavigationTiming.h
|
|
|
++++ b/dom/performance/PerformanceNavigationTiming.h
|
|
|
+@@ -25,22 +25,23 @@ class PerformanceNavigationTiming final
|
|
|
+ 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
|
|
|
+ PerformanceNavigationTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming,
|
|
|
+- Performance* aPerformance)
|
|
|
+- : PerformanceResourceTiming(std::move(aPerformanceTiming), aPerformance,
|
|
|
+- NS_LITERAL_STRING("document")) {
|
|
|
+- SetEntryType(NS_LITERAL_STRING("navigation"));
|
|
|
+- SetInitiatorType(NS_LITERAL_STRING("navigation"));
|
|
|
+- }
|
|
|
++ Performance* aPerformance,
|
|
|
++ const nsAString& aName)
|
|
|
++ : PerformanceResourceTiming(Move(aPerformanceTiming), aPerformance, aName)
|
|
|
++ {
|
|
|
++ SetEntryType(NS_LITERAL_STRING("navigation"));
|
|
|
++ SetInitiatorType(NS_LITERAL_STRING("navigation"));
|
|
|
++ }
|
|
|
+
|
|
|
+ DOMHighResTimeStamp Duration() const override
|
|
|
+ {
|
|
|
+ return nsRFPService::ReduceTimePrecisionAsMSecs(LoadEventEnd() - StartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ DOMHighResTimeStamp StartTime() const override
|
|
|
+ {
|