Open Bug 1452678 Opened 2 years ago Updated 2 years ago

Use devtools/shared/link everywhere where we open links in a tab

Categories

(DevTools :: General, enhancement)

enhancement
Not set

Tracking

(Not tracked)

People

(Reporter: ochameau, Unassigned)

References

(Blocks 1 open bug)

Details

Bug 1444301 just introduced an helper module to easily open a link:
https://searchfox.org/mozilla-central/source/devtools/client/shared/link.js

Which can be used like this:
  const {openLink} = require("devtools/client/shared/link");
  ...
  openLink("https://developer.mozilla.org/docs/Tools", toolbox);

The dependency on toolbox object may be dropped per bug 1444301 comment 74.

Today, there is about 20 occurences where we manually call openUILink:
  https://searchfox.org/mozilla-central/search?q=openUILinkIn(&case=false&regexp=false&path=devtools
Summary: Use devtools/shared/link → Use devtools/shared/link everywhere where we open links in a tab
After Bug https://bugzilla.mozilla.org/show_bug.cgi?id=1374741, 

they were all renamed to openWebLinkIn https://searchfox.org/mozilla-central/search?q=openWebLinkIn&case=false&regexp=false&path=devtools

(but sadly devtools/client/shared/link must have missed the migration patch)
See Also: → 1374741
And openTrustedLink as well.
https://searchfox.org/mozilla-central/search?q=openWebLinkIn&case=false&regexp=false&path=devtools

Should we complexify the module to handle both? And to support the relatedToCurrent argument (which allows to open a new tab next to the current tab instead of as the last one)
Probably worth exposing both openWebLink and openTrustedLink versions, to match the underlying browser APIs.  The main benefit of this link module to me is centralizing the boilerplate to find these functions from a DevTools context.

(Could also add relatedToCurrent if we have a need for it.)
Depends on: 1453495
Looks like it broke already.
(Bug 1453423 is handling the immediate breakage here, hopefully landing soon.)
Severity: normal → enhancement
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.