Listen to DOMDocElementInserted in DevToolsFrameChild to create targets we couldn't create as a result of DOMWindowCreated
Categories
(DevTools :: Framework, task, P1)
Tracking
(firefox96 fixed)
Tracking | Status | |
---|---|---|
firefox96 | --- | fixed |
People
(Reporter: nchevobbe, Assigned: ochameau)
References
Details
(Whiteboard: dt-perf-stability-mvp)
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
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
.
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
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.
Updated•3 years ago
|
Comment 4•3 years ago
|
||
bugherder |
Description
•