Closed Bug 1730154 Opened 3 years ago Closed 3 years ago

Listen to DOMDocElementInserted in DevToolsFrameChild to create targets we couldn't create as a result of DOMWindowCreated

Categories

(DevTools :: Framework, task, P1)

task

Tracking

(firefox96 fixed)

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: nchevobbe, Assigned: ochameau)

References

Details

(Whiteboard: dt-perf-stability-mvp)

Attachments

(1 file)

After writing an initial patch for Bug 1685500, I encountered an issue running a test.
The test document is a page with a same origin iframe.
It opens netmonitor, check the "Disable Cache" checkbox and reload the page.
At this point, I'm getting a target for the top-level document, but not for the same-origin iframe.

What seems to happen is that when we're getting the DOMWindowCreated event for the document, it's still flagged as an initial document, so we ignore it.
But we never get another DOMWindowCreated event after, and so the target is never created.
The document simply seems to be reused/swapped (I don't know what the terminology is here)

That's something Nika told me (a couple months back) could happen, but I wasn't able to reproduce with remote frames.

The solution is to listen to DOMDocElementInserted, at which point the document isn't flagged as initial anymore.
However, we can't simply switch from DOMWindowCreated to DOMDocElementInserted: the latter fires a bit too late and make us miss early resources (luckily we have tests breaking, demonstrating the issue).

What seems like a reasonable solution is to listen to both events, and only create a target from DOMDocElementInserted if we didn't had the chance of creating one when we received DOMWindowCreated.

Type: defect → task
Priority: -- → P1
Assignee: nchevobbe → poirot.alex

When loading an iframe in the same origin/process, we end up with an edge case.
A first "initial" about:blank document is created to bootstrap the iframe.
A DOMWindowCreated event is fired and its document.isInitialDocument is true.
If no URL is set on the iframe, it stops there and we won't create any target for this special document.
(As we ignore DOMWindowCreated events when document.isInitialDocument is true)

Then, if an URL is set on the iframe, we don't create any new WindowGlobal,
instead we will reuse the about:blank's document's one.
It means that there won't be any new DOMWindowCreated event.

Fortunately, there is a DOMDocElementInserted fired, which we can listen here.
We can then instantiate a target actor and that, only if no target was previously created
by a previous DOMWindowCreated. In all other cases, we would receive a DOMWindowCreated
with document.isInitialDocument set to false.

Attachment #9248909 - Attachment description: Bug 1730154 - [devtools] Create targets for same-process iframe documents. → Bug 1730154 - [devtools] Create targets for iframes reusing the initial about:blank WindowGlobal.
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7a9982343046 [devtools] Create targets for iframes reusing the initial about:blank WindowGlobal. r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: