Closed Bug 1613140 Opened 4 years ago Closed 4 years ago

transferSize on PerformanceNavigationTiming is not available till after window.onload

Categories

(Core :: DOM: Core & HTML, defect, P2)

72 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla75
Tracking Status
firefox75 --- fixed

People

(Reporter: abhishek.c.ghosh, Assigned: valentin)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36

Steps to reproduce:

Tried to obtain the values for transferSize, encodedBodySize and decodedBodySize values for the main document request ("navigation" resource) on DOMContentLoaded and window.load

Demo: https://8gbhu.csb.app/

Actual results:

It seems that the transferSize, encodedBodySize and decodedBodySize values for the main document request ("navigation") is not available till after an async function call after window.onload and incorrectly reports as 0 on events like DOMContentLoaded and window.onload

This is a bit unexpected since intuitively transferSize should have been available as soon as the responseEnd for the main document request was complete. That is also my limited understanding from the spec: https://www.w3.org/TR/resource-timing-2/#sec-process (see point 19.2).

Expected results:

I'm curious why aren't the values available sooner?

transferSize and associated values for the main document navigation resource should have been available right after the response for the main document, such that it can be accessed correctly on events like DOMContentLoaded.

As a side-note/comparison, Chromium seems to exhibit this behaviour.

Although I filed this on Bugzilla from this UA (Chrome, mentioned above): Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36, the actual bug is reproducible on this UA (Firefox): Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:72.0) Gecko/20100101 Firefox/72.0

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

baku: Could you take a look or redirect this ni to proper person?

Flags: needinfo?(amarchesini)
Flags: needinfo?(amarchesini) → needinfo?(valentin.gosu)

So, the attributes are updated via the following calls:

PerformanceNavigationTiming::UpdatePropertiesFromHttpChannel -> PerformanceMainThread::QueueNavigationTimingEntry -> nsPIDOMWindowInner::QueuePerformanceNavigationTiming -> nsDocumentViewer::LoadComplete -> nsDocShell::EndPageLoad -> nsDocShell::OnStateChange

However, the onload handlers are sent from Document::EndLoad - I think it might make sense to call nsPIDOMWindowInner::QueuePerformanceNavigationTiming from there, but I'm not super sure that it's the correct solution.
In any case, I'll submit the patch for review + WPT tests.

Assignee: nobody → valentin.gosu
Flags: needinfo?(valentin.gosu)
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P2
Pushed by valentin.gosu@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/e9172bdcb507
Call QueuePerformanceNavigationTiming from Document::EndLoad() r=baku
https://hg.mozilla.org/integration/autoland/rev/642b10191ecb
Add WPT that the size attributes for PerformanceNavigationTiming have been updated during DOMContentLoaded/onload r=baku
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/21725 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
Upstream PR merged by moz-wptsync-bot
Regressions: 1653165
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: