Bug 1810009 - [devtools] Avoid firing DOCUMENT_EVENT will-navigate for non-top-level targets. r=devtools-reviewers,jdescottes

The legacy listener was explicitely avoiding emitting this event for non top-level targets.
It seems like all frontend code listening to will-navigate ignore the event is targetFront.isTopLevel is false,
so it looks like no code would expect these event.
So let's try to avoid emitting them if they aren't used by anyone.
(and can be confusing/buggy in the context of the browser toolbox)

Differential Revision: https://phabricator.services.mozilla.com/D166769
This commit is contained in:
Alexandre Poirot 2023-01-17 01:01:14 +00:00
Родитель 5a30a1e071
Коммит 5e721345b9
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -120,12 +120,18 @@ class ParentProcessDocumentEventWatcher {
return;
}
// Ignore remote iframe targets which are restoring from the bfcache.
// onStateChange is called before the related target is instantiated
// and this isn't quite a navigation, we will respawn a new target.
// Only emit will-navigate for top-level targets.
if (
this.watcherActor.sessionContext.type == "all" &&
browsingContext.isContent
) {
// Never emit will-navigate for content browsing contexts in the Browser Toolbox.
// They might verify `browsingContext.top == browsingContext` because of the chrome/content
// boundary, but they do not represent a top-level target for this DevTools session.
return;
}
const isTopLevel = browsingContext.top == browsingContext;
const isRestoring = flag & Ci.nsIWebProgressListener.STATE_RESTORING;
if (!isTopLevel && isRestoring) {
if (!isTopLevel) {
return;
}