 alert.init(
      tag,
      content.image_url
        ? Services.urlFormatter.formatURL(content.image_url)
        : content.image_url,
      title,
      body,
      true /* aTextClickable */,
      content.data,
      null /* aDir */,
      null /* aLang */,
      null /* aData */,
      systemPrincipal,
      null /* aInPrivateBrowsing */,
      content.requireInteraction
    );

    if (content.actions) {
      let actions = Cu.cloneInto(content.actions, {});
      for (let action of actions) {
        if (action.title) {
          action.title = await lazy.RemoteL10n.formatLocalizableText(
            action.title
          );
        }
        if (action.launch_action) {
          action.opaqueRelaunchData = JSON.stringify(action.launch_action);
          delete action.launch_action;
        }
      }
      alert.actions = actions;
    }

    // Populate `opaqueRelaunchData`, prefering `launch_action` if given,
    // falling back to `launch_url` if given.
    let relaunchAction = content.launch_action;
    if (!relaunchAction && content.launch_url) {
      relaunchAction = {
        type: "OPEN_URL",
        data: {
          args: content.launch_url,
          where: "tab",
        },
      };
    }
    if (relaunchAction) {
      alert.opaqueRelaunchData = JSON.stringify(relaunchAction);
    }

    let shownPromise = Promise.withResolvers();
    let obs = (subject, topic) => {
      if (topic === "alertshow") {
        shownPromise.resolve();
      }
    };

    this.AlertsService.showAlert(alert, obs);

    await shownPromise;

    return true;
  },
};
PK