Open Bug 1709292 Opened 3 years ago Updated 3 years ago

Expose a single API to check for watcher support

Categories

(DevTools :: General, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: jdescottes, Unassigned)

References

Details

We expose two APIs in devtools to check for watcher support:

  • hasTargetWatcherSupport
  • hasResourceWatcherSupport

https://searchfox.org/mozilla-central/search?q=has%28Resource%7CTarget%29WatcherSupport&path=&case=true&regexp=true

They both rely on the availability of a WatcherFront and then check traits on this watcher front.

But hasTargetWatcherSupport is sometimes used to check traits which are not related at all to a target type: eg https://searchfox.org/mozilla-central/rev/185ab5e4f4e01341e009cd4633d1275ffe4d4c8b/devtools/shared/commands/target-configuration/target-configuration-command.js#38-40

    return this._commands.targetCommand.hasTargetWatcherSupport(
      "target-configuration"
    );

We could replace both APIs with a single API with a clear signature:

/**
 * Check if the watcher is supported and additionally check for specific support of a
 * resourceType, targetType or custom trait.
 *
 * @param {Object} options
 * @param {String} options.resourceType
 * @param {String} options.targetType
 * @param {String} options.trait
 * @return {Boolean} true if the watcher is supported 
 */
hasWatcherSupport({ resourceType, targetType, trait }) { /* ... */ }

I am also slightly modifying the APIs and call sites in Bug 1709269

Depends on: 1709269
You need to log in before you can comment on or make changes to this bug.