async TabOpen({
    url,
    active = true,
    container,
    insert = true,
    pinned,
  }, src = {}) {
    const isRemoved = src._removed;
    // src.tab may be absent when invoked from popup (e.g. edit/create buttons)
    const srcTab = !isRemoved && src.tab
      || await getActiveTab(isRemoved && src.tab[kWindowId])
      || {};
    // src.url may be absent when invoked directly as commands.TabOpen
    const srcUrl = src.url;
    const isInternal = !srcUrl || srcUrl.startsWith(extensionRoot);
    // only incognito storeId may be specified when opening in an incognito window
    const { incognito } = srcTab;
    const canOpenIncognito = !incognito || IS_FIREFOX || !/^(chrome[-\w]*):/.test(url);
    const tabOpts = {
      // normalizing as boolean because the API requires strict types
      active: !!active,
      pinned: !!pinned,
    };
    let windowId = srcTab[kWindowId];
    let newTab;
    // Chrome can't open chrome-xxx: URLs in incognito windows
    // TODO: for src._removed maybe create a new window if cookieStoreId of active tab is different
    let storeId = srcTab.cookieStoreId;
    if (storeId && !incognito) {
      if (!cookieStorePrefix) {
        cookieStorePrefix = (await browser.cookies.getAllCookieStores())[0].id.split('-')[0];
      }
      if (isInternal || container === 0) {
        storeId = cookieStorePrefix + '-default';
      } else if (container > 0) {
        storeId = `${cookieStorePrefix}-container-${container}`;
      }
    }
    if (storeId) storeId = { cookieStoreId: storeId };
    // URL needs to be expanded for `canOpenIncognito` below
    if (!/^[-\w]+:/.test(url)) {
      url = isInternal
        ? browser.runtime.getURL(url)
        : vetUrl(url, srcUrl);
    }
    if (isInternal
        && url.startsWith(EDITOR_ROUTE)
        && browserWindows
        && getOption('editorWindow')
        /* cookieStoreId in windows.create() is supported since FF64 https://bugzil.la/1393570
         * and a workaround is too convoluted to add it for such an ancient version */
        && (!storeId || FIREFOX >= 64)) {
      const wndOpts = {
        url,
        incognito: canOpenIncognito && incognito,
        ...getOption('editorWindowSimple') && { type: 'popup' },
        ...!IS_FIREFOX && { focused: !!active }, // FF doesn't support this
        ...storeId,
      };
      const pos = getOption('editorWindowPos');
      const hasPos = pos && 'top' in pos;
      const wnd = await browserWindows.create({ ...wndOpts, ...pos }).catch(hasPos && noop)
        || hasPos && await browserWindows.create(wndOpts);
      newTab = wnd.tabs[0];
    } else if (isInternal && canOpenIncognito && NEWTAB_URL_RE.test(getTabUrl(srcTab))) {
      // Replacing the currently focused start tab page for internal commands
      newTab = await browser.tabs.update(srcTab.id, { url, ...tabOpts }).catch(noop);
    }
    for (let retry = 0; !newTab && retry < 2; retry++) try {
      newTab = await browser.tabs.create({
        url,
        ...tabOpts,
        ...storeId,
        ...canOpenIncognito && {
          [kWindowId]: windowId,
          ...insert && srcTab.index != null && { index: srcTab.index + 1 },
          ...openerTabIdSupported && { openerTabId: srcTab.id },
        },
      });
    } catch (err) {
      const m = err.message;
      if (m.startsWith('Illegal to set private')) storeId = null;
      else if (m.startsWith('No tab')) srcTab.id = null;
      else if (m.startsWith('No window')) windowId = null;
      else if (m.startsWith('Tabs cannot be edited')) await makePause(100);
      else throw err; // TODO: put in storage and show in UI
    }
    if (active && newTab[kWindowId] !== windowId) {
      await browserWindows?.update(newTab[kWindowId], { focused: true });
    }
    if (!isInternal && srcTab.id != null) {
      openers[newTab.id] = srcTab.id;
    }
    return isInternal ? newTab : { id: newTab.id };
  }
@return {Promise<{ id: number } | chrome.tabs.Tab>} new tab is returned for internal calls