Skip to content

Commit

Permalink
Bug 1462879 - Update the channel properties before notify, r=valentin
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed May 24, 2018
1 parent f87bd4e commit 5cf7331
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
12 changes: 10 additions & 2 deletions dom/performance/PerformanceMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,17 @@ PerformanceMainThread::CreateNavigationTimingEntry()
void
PerformanceMainThread::QueueNavigationTimingEntry()
{
if (mDocEntry) {
QueueEntry(mDocEntry);
if (!mDocEntry) {
return;
}

// Let's update some values.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
if (httpChannel) {
mDocEntry->UpdatePropertiesFromHttpChannel(httpChannel);
}

QueueEntry(mDocEntry);
}

void
Expand Down
4 changes: 3 additions & 1 deletion dom/performance/PerformanceMainThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
namespace mozilla {
namespace dom {

class PerformanceNavigationTiming;

class PerformanceMainThread final : public Performance
, public PerformanceStorage
{
Expand Down Expand Up @@ -84,7 +86,7 @@ class PerformanceMainThread final : public Performance

void DispatchBufferFullEvent() override;

RefPtr<PerformanceEntry> mDocEntry;
RefPtr<PerformanceNavigationTiming> mDocEntry;
RefPtr<nsDOMNavigationTiming> mDOMTiming;
nsCOMPtr<nsITimedChannel> mChannel;
RefPtr<PerformanceTiming> mTiming;
Expand Down
6 changes: 6 additions & 0 deletions dom/performance/PerformanceNavigationTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ PerformanceNavigationTiming::RedirectCount() const
{
return mTimingData->GetRedirectCount();
}

void
PerformanceNavigationTiming::UpdatePropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel)
{
mTimingData->SetPropertiesFromHttpChannel(aHttpChannel);
}
3 changes: 3 additions & 0 deletions dom/performance/PerformanceNavigationTiming.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class PerformanceNavigationTiming final
NavigationType Type() const;
uint16_t RedirectCount() const;

void
UpdatePropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel);

private:
~PerformanceNavigationTiming() {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h1>Description</h1>
var entries = entryList.getEntries();
assert_equals(entries[0].entryType, "navigation",
"Expected entryType to be: navigation.");
assert_equals(entries[0].name, "http://web-platform.test:8001/navigation-timing/nav2_test_attributes_values.html");
assert_equals(entries[0].name, window.location.toString());
assert_equals(entries[0].startTime, 0,
"Expected startTime to be: 0.");
assert_equals(entries[0].duration, entries[0].loadEventEnd,
Expand All @@ -93,8 +93,8 @@ <h1>Description</h1>
// running this test.
assert_true(entries[0].transferSize > entries[0].encodedBodySize,
"Expected transferSize to be greater than encodedBodySize in uncached navigation.");
assert_equals(entries[0].encodedBodySize, 5328);
assert_equals(entries[0].decodedBodySize, 5328);
assert_equals(entries[0].encodedBodySize, 5272);
assert_equals(entries[0].decodedBodySize, 5272);
verifyTimingEventOrder(entries[0], navTiming2EventOrder1);
// Verify if the reported timing is not that different
// from what is reported by Navigation Timing 1.
Expand Down

0 comments on commit 5cf7331

Please sign in to comment.