Closed Bug 1588730 Opened 1 year ago Closed 1 year ago

Ensure passing the form to Fronts before notifying about their creation

Categories

(DevTools :: Framework, enhancement)

enhancement
Not set
normal

Tracking

(firefox71 fixed)

RESOLVED FIXED
Firefox 71
Tracking Status
firefox71 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Front's form is currently passed after calling parentFront.manage(front):
https://searchfox.org/mozilla-central/rev/17756e2a5c180d980a4b08d99f8cc0c97290ae8d/devtools/shared/protocol/types.js#336-344

        parentFront.manage(front);
      }

      // When the type `${name}#actorid` is used, `v` is a string refering to the
      // actor ID. We only set the actorID just before and so do not need anything else.
      if (detail != "actorid") {
        v = identityWrite(v);
        front.form(v, ctx);
      }

But we do notify about the fronts from within Front.manage:
https://searchfox.org/mozilla-central/rev/17756e2a5c180d980a4b08d99f8cc0c97290ae8d/devtools/shared/protocol/Front.js#79-96

  async manage(front) {
    if (!front.actorID) {
      throw new Error(
        "Can't manage front without an actor ID.\n" +
          "Ensure server supports " +
          front.typeName +
          "."
      );
    }
    super.manage(front);

    if (typeof front.initialize == "function") {
      await front.initialize();
    }

    // Call listeners registered via `onFront` method
    this._frontListeners.emit(front.typeName, front); // <==== Right here
  }

We should ensure calling front.form(v) before this._frontListeners.emit(front.typeName, front);, so that when we notify about the fronts being just created, their typical attributes polulated out of the form are already set.

I thought I would contribute to this test.
As it doesn't involve any child actor, I'm not, but this cleanup is still valuable.

You can listen for fronts creation via parentFront.onFront(typeName, callback).
For now, we were calling callback before we pass the form to Front.
This leads to empty attributes as the Front doesn't have access to any data.

Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED
Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ad24c0afefd4
Convert test_protocol_simple to async/await. r=jdescottes
https://hg.mozilla.org/integration/autoland/rev/b2a798629bd6
Ensure calling form() before calling notifying onFront listeners. r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 71
You need to log in before you can comment on or make changes to this bug.