Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import test from "node:test";
import assert from "node:assert/strict";
import {
acquireGeminiBrowser,
releaseGeminiBrowser,
resetGeminiBrowserLeaseForTests,
type GeminiBrowser,
} from "../../open-sse/executors/gemini-web/browserLease.ts";
function fakeBrowser(): GeminiBrowser {
return {
close: async () => undefined,
newContext: async () => ({}),
isConnected: () => true,
};
}
test("#13382 one Chromium launch serves two requests", async () => {
await resetGeminiBrowserLeaseForTests();
let launches = 0;
const browser = fakeBrowser();
const launch = async () => {
launches += 1;
return browser;
};
const first = await acquireGeminiBrowser(launch);
const second = await acquireGeminiBrowser(launch);
assert.equal(launches, 1);
assert.equal(first, second);
await releaseGeminiBrowser(first);
await releaseGeminiBrowser(second);
await resetGeminiBrowserLeaseForTests();
});
test("#13382 a replaced launch function does not reuse the previous browser", async () => {
await resetGeminiBrowserLeaseForTests();
let launches = 0;
const launchA = async () => {
launches += 1;
return fakeBrowser();
};
const launchB = async () => {
launches += 1;
return fakeBrowser();
};
const first = await acquireGeminiBrowser(launchA);
await releaseGeminiBrowser(first);
await acquireGeminiBrowser(launchB);
assert.equal(launches, 2);
await resetGeminiBrowserLeaseForTests();
});