Closed Bug 1704806 Opened 3 years ago Closed 3 years ago

dom-loading DOCUMENT_EVENT is duplicated in case of server side target switching

Categories

(DevTools :: Framework, defect, P3)

defect

Tracking

(firefox90 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

Details

Attachments

(1 file)

While working on bug 1702511, I was having duplicated dom-loading event when running devtools/client/webconsole/test/browser/browser_webconsole_persist.js.

That's because the DocumentEventWatcher may be instantiated before the target actor is attached.
So that a first dom-loading will be forced from here:
https://searchfox.org/mozilla-central/source/devtools/server/actors/webconsole/listeners/document-events.js#30-36

  listen() {
    EventEmitter.on(this.targetActor, "window-ready", this.onWindowReady);
    this.onWindowReady({
      window: this.targetActor.window,
      isTopLevel: true,
      // Flag the very first dom-loading event, which is about the top target and may come
      // after some other already existing resources.
      shouldBeIgnoredAsRedundantWithTargetAvailable: true,
    });
  },

We emit a fake window-ready for the current top level document.
But if the target isn't attached yet and is attached right after, another window-ready will be fired by the TargetActor itself, from here:
https://searchfox.org/mozilla-central/rev/3de2db87f3c9001ae478318d47a2ca3427574382/devtools/server/actors/targets/browsing-context.js#1669-1671

    // Dispatch the _windowReady event on the targetActor for pre-existing windows
    for (const win of this._getWindowsInDocShell(docShell)) {
      this._targetActor._windowReady(win);

(this code is called when the target actor is attached)

Note that bug 1704805 is required in order to easily reproduce this issue in the added test. Without this, the target actor is already attached by the time we start the DOCUMENT_EVENT watcher.

Assignee: nobody → poirot.alex
Blocks: 1704811
Attachment #9215444 - Attachment description: Bug 1704806 - Fix duplicated dom-loading event in case of server side target switching. → Bug 1704806 - [devtools] Fix duplicated dom-loading event in case of server side target switching.
Severity: -- → S3
Priority: -- → P3
Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5de21b75b2e9
[devtools] Fix duplicated dom-loading event in case of server side target switching. r=nchevobbe
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: