Closed Bug 1093730 Opened 8 years ago Closed 8 years ago

Add DevTools toolbox API for getPanelWhenReady

Categories

(DevTools :: Framework, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 37

People

(Reporter: bgrins, Assigned: bgrins)

Details

Attachments

(2 files, 1 obsolete file)

We have toolbox.on("jsdebugger-ready", (e, panel) => { }) and toolbox.getPanel("jsdebugger").  These are two different ways to get a reference to a panel, depending on whether it has been loaded already or not.

But it's sort of awkward to get ahold of the the panel regardless of whether it is already loaded.  It looks something like this:

  let panel = toolbox.getPanel("jsdebugger");
  if (panel) {
    panelReady(panel);
  } else {
    toolbox.on("jsdebugger-ready", (e, panel) => panelReady(panel);
  }

  function panelReady(panel) {
    console.log("Panel ready", panel);
  }

It seems that this logic should be handled from the toolbox level, and have it expose an API like:

  // Returns a promise that resolves with the panel either immediately if it is
  // already available, or once it is ready.
  toolbox.getPanelWhenReady(panelName);

This sample from above could then be simplified to:

  toolbox.getPanelWhenReady("jsdebugger").then(panel => {
    console.log("Panel ready", panel);
  });
Attached patch getPanelWhenReady-WIP.patch (obsolete) — Splinter Review
Assignee: nobody → bgrinstead
Status: NEW → ASSIGNED
Attachment #8532613 - Attachment is obsolete: true
Attachment #8533427 - Flags: review?(jryans)
Attachment #8533428 - Flags: review?(jryans)
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/210fcdc74cde
https://hg.mozilla.org/mozilla-central/rev/3368df73756b
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 37
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.