Bug 1462605 - PerformanceNavigationTiming.name must be the value of the address of the current document, r=valentin

This commit is contained in:
Andrea Marchesini 2018-05-18 16:20:19 +02:00
parent 828b2d9eef
commit 5840b63b8a
3 changed files with 44 additions and 12 deletions

View File

@ -12,6 +12,35 @@
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,
@ -293,7 +322,10 @@ PerformanceMainThread::EnsureDocEntry()
timing->SetPropertiesFromHttpChannel(httpChannel);
}
mDocEntry = new PerformanceNavigationTiming(Move(timing), this);
nsAutoString name;
GetURLSpecFromChannel(mChannel, name);
mDocEntry = new PerformanceNavigationTiming(Move(timing), this, name);
}
}
@ -307,9 +339,12 @@ PerformanceMainThread::CreateDocumentEntry(nsITimedChannel* aChannel)
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

View File

@ -30,12 +30,13 @@ public:
// performance.timing object for which timestamps are absolute and has a
// zeroTime initialized to navigationStart
PerformanceNavigationTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming,
Performance* aPerformance)
: PerformanceResourceTiming(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
{

View File

@ -1,5 +1 @@
prefs: [privacy.reduceTimerPrecision:false]
[nav2_test_redirect_server.html]
[Navigation Timing 2 WPT]
expected: FAIL