async getAddonsActor()

in src/firefox/remote.js [67:107]


  async getAddonsActor() {
    try {
      // getRoot should work since Firefox 55 (bug 1352157).
      const response = await this.client.request('getRoot');
      if (response.addonsActor == null) {
        return Promise.reject(
          new RemoteTempInstallNotSupported(
            'This version of Firefox does not provide an add-ons actor for ' +
              'remote installation.',
          ),
        );
      }
      return response.addonsActor;
    } catch (err) {
      // Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).
      log.debug('Falling back to listTabs because getRoot failed', err);
    }

    try {
      const response = await this.client.request('listTabs');
      // addonsActor was added to listTabs in Firefox 49 (bug 1273183).
      if (response.addonsActor == null) {
        log.debug(
          'listTabs returned a falsey addonsActor: ' +
            `${JSON.stringify(response)}`,
        );
        return Promise.reject(
          new RemoteTempInstallNotSupported(
            'This is an older version of Firefox that does not provide an ' +
              'add-ons actor for remote installation. Try Firefox 49 or ' +
              'higher.',
          ),
        );
      }
      return response.addonsActor;
    } catch (err) {
      log.debug('listTabs error', err);
      const message = requestErrorToMessage(err);
      throw new WebExtError(`Remote Firefox: listTabs() error: ${message}`);
    }
  }