demo-multiplayer.js•3.38 kB
#!/usr/bin/env node
// Demo: Testing multiplayer functionality with isolated sessions
// This script shows how to use the multi-tab Firefox MCP server for multiplayer testing
console.log("🌌 Multi-Tab Firefox MCP Server Demo");
console.log("=====================================");
console.log("This demo shows how to test multiplayer scenarios with isolated sessions.\n");
const demoSteps = [
{
step: 1,
description: "Launch Firefox with multi-tab support",
mcp_call: `launch_firefox_multi({ headless: false })`
},
{
step: 2,
description: "Create tab for Host player (isolated session)",
mcp_call: `create_tab({ tabId: "host", url: "http://localhost:4000/stellar-bonds" })`
},
{
step: 3,
description: "Create tab for Player 1 (separate cookies/session)",
mcp_call: `create_tab({ tabId: "player1", url: "http://localhost:4000/stellar-bonds" })`
},
{
step: 4,
description: "Create tab for Player 2 (another separate session)",
mcp_call: `create_tab({ tabId: "player2", url: "http://localhost:4000/stellar-bonds" })`
},
{
step: 5,
description: "List all active tabs",
mcp_call: `list_tabs()`
},
{
step: 6,
description: "Host creates game",
mcp_call: `click({ tabId: "host", selector: "button.create-game" })`
},
{
step: 7,
description: "Get game code from host",
mcp_call: `get_page_text({ tabId: "host", selector: ".game-code" })`
},
{
step: 8,
description: "Player 1 joins game (in their isolated session)",
mcp_call: `click({ tabId: "player1", selector: "button.join-game" })
type_text({ tabId: "player1", selector: "input.game-code", text: gameCode })`
},
{
step: 9,
description: "Player 2 joins game (in their isolated session)",
mcp_call: `click({ tabId: "player2", selector: "button.join-game" })
type_text({ tabId: "player2", selector: "input.game-code", text: gameCode })`
},
{
step: 10,
description: "Verify all players see each other (bug detection)",
mcp_call: `get_page_text({ tabId: "host", selector: ".player-list" })
get_page_text({ tabId: "player1", selector: ".player-list" })
get_page_text({ tabId: "player2", selector: ".player-list" })`
},
{
step: 11,
description: "Take screenshots of all tabs for comparison",
mcp_call: `screenshot({ tabId: "host", path: "host_lobby.png" })
screenshot({ tabId: "player1", path: "player1_lobby.png" })
screenshot({ tabId: "player2", path: "player2_lobby.png" })`
},
{
step: 12,
description: "Close browser and cleanup",
mcp_call: `close_browser()`
}
];
demoSteps.forEach(({ step, description, mcp_call }) => {
console.log(`\n${step}. ${description}`);
console.log(` MCP: ${mcp_call}`);
});
console.log("\n🔑 Key Benefits:");
console.log("✅ Each tab has separate cookies - true user isolation");
console.log("✅ Test real multiplayer scenarios without manual setup");
console.log("✅ Detect bugs like 'only one player shows up' easily");
console.log("✅ Compare behavior across all tabs simultaneously");
console.log("✅ All controlled from within Cline - no manual browser management");
console.log("\n🎯 Perfect for testing:");
console.log("- Multiplayer lobby synchronization");
console.log("- Real-time player updates");
console.log("- Session isolation bugs");
console.log("- Cross-user state management");