Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

3.8 KB
Raw Blame
import { describe, expect, test } from 'vitest';
import { browserOf, launch, locateBrowsers, sourceFor, storeSteps, storeUrl } from './browsers';

describe('where each browser gets the extension', () => {
  test('every Chromium browser from the Chrome Web Store, Edge included, Firefox the signed add-on', () => {
    expect([sourceFor('chrome'), sourceFor('brave'), sourceFor('edge'), sourceFor('firefox')]).toEqual([
      'chrome-web-store',
      'chrome-web-store',
      'chrome-web-store',
      'firefox',
    ]);
    expect(storeUrl('edge', '0.8.0')).toBe('https://chromewebstore.google.com/detail/browsentic/npmocgldfflonjjmdadmdefpnfagnjmp');
    expect(storeUrl('firefox', '0.8.0')).toBe(
      'https://github.com/imshaikot/browsentic/releases/download/v0.8.0/browsentic-0.8.0-firefox.xpi',
    );
  });

  test('Opera is told to add its helper first, Edge to allow other stores, and the rest the button they show', () => {
    expect([storeSteps('opera')[0], storeSteps('edge')[0], storeSteps('brave')[0]]).toEqual([
      expect.stringContaining('Install Chrome Extensions'),
      expect.stringMatching(/^Press “Allow extensions from other stores”.*“Add to Chrome”\.$/),
      'Press “Add to Brave”.',
    ]);
  });
});

describe('browserOf', () => {
  test('reads the brand the extension reported', () => {
    expect(['Google Chrome', 'Microsoft Edge', 'Brave', 'Opera', 'Chromium', 'Firefox', 'Something Else', undefined].map(browserOf)).toEqual([
      'chrome',
      'edge',
      'brave',
      'opera',
      'chromium',
      'firefox',
      undefined,
      undefined,
    ]);
  });
});

describe('locateBrowsers', () => {
  const present = (...paths: string[]) => (path: string) => paths.includes(path);

  test('on a Mac, by the app in /Applications or ~/Applications', () => {
    const found = locateBrowsers({
      platform: 'darwin',
      home: '/Users/me',
      exists: present('/Applications/Google Chrome.app', '/Users/me/Applications/Arc.app'),
    });
    expect(found).toEqual([
      { id: 'chrome', path: '/Applications/Google Chrome.app' },
      { id: 'arc', path: '/Users/me/Applications/Arc.app' },
    ]);
  });

  test('on Windows, by App Paths first and the usual install folders after', () => {
    const found = locateBrowsers({
      platform: 'win32',
      env: { ProgramFiles: 'C:\\Program Files', LOCALAPPDATA: 'C:\\Users\\me\\AppData\\Local' },
      registered: (program) => (program === 'msedge.exe' ? 'C:\\Edge\\msedge.exe' : undefined),
      exists: present('C:\\Edge\\msedge.exe', 'C:\\Users\\me\\AppData\\Local\\BraveSoftware\\Brave-Browser\\Application\\brave.exe'),
    });
    expect(found).toEqual([
      { id: 'edge', path: 'C:\\Edge\\msedge.exe' },
      { id: 'brave', path: 'C:\\Users\\me\\AppData\\Local\\BraveSoftware\\Brave-Browser\\Application\\brave.exe' },
    ]);
  });

  test('on Linux, by a program on PATH', () => {
    const found = locateBrowsers({ platform: 'linux', env: { PATH: '/usr/bin:/snap/bin' }, exists: present('/snap/bin/firefox', '/usr/bin/google-chrome-stable') });
    expect(found).toEqual([
      { id: 'chrome', path: '/usr/bin/google-chrome-stable' },
      { id: 'firefox', path: '/snap/bin/firefox' },
    ]);
  });
});

describe('launch', () => {
  const url = 'https://chromewebstore.google.com/detail/browsentic/npmocgldfflonjjmdadmdefpnfagnjmp';

  test('opens the page in the browser that was found, or the default one', () => {
    expect([
      launch(url, { id: 'brave', path: '/Applications/Brave Browser.app' }, 'darwin'),
      launch(url, { id: 'edge', path: 'C:\\Edge\\msedge.exe' }, 'win32'),
      launch(url, undefined, 'win32'),
      launch(url, undefined, 'linux'),
    ]).toEqual([
      ['open', ['-a', '/Applications/Brave Browser.app', url]],
      ['C:\\Edge\\msedge.exe', [url]],
      ['explorer.exe', [url]],
      ['xdg-open', [url]],
    ]);
  });
});