Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:DevExpress Testcafe BrowserConnectionGateway

From Leeroopedia
Knowledge Sources
Domains Browser_Communication, HTTP_Server
Last Updated 2026-02-12 12:00 GMT

Overview

Concrete tool for managing browser-to-server HTTP communication provided by the TestCafe framework.

Description

The BrowserConnectionGateway class is the HTTP server component that registers routes on the hammerhead proxy to handle all browser-to-server communication. It manages connection establishment, heartbeats, status polling, init scripts, window management, idle page serving, and native automation event dispatch. It acts as the central communication hub between TestCafe's server and all connected browser instances.

Usage

This class is instantiated internally by TestCafe during server initialization. It is not imported directly by test authors but is a core infrastructure component that enables the browser-server protocol.

Code Reference

Source Location

Signature

export interface BrowserConnectionGatewayOptions {
    retryTestPages: boolean;
}

export default class BrowserConnectionGateway extends EventEmitter {
    private _connections: Dictionary<BrowserConnection>;
    private _remotesQueue: RemotesQueue;
    public connectUrl: string;
    public readonly proxy: Proxy;

    public constructor (proxy: Proxy, options: BrowserConnectionGatewayOptions);
    public initialize (options: TestCafeStartOptions): void;
    public dispose (): void;
    public startServingConnection (connection: BrowserConnection): void;
    public stopServingConnection (connection: BrowserConnection): void;
    public getConnections (): Dictionary<BrowserConnection>;
    public close (): void;
}

Import

import BrowserConnectionGateway from './browser/connection/gateway';

I/O Contract

Inputs

Name Type Required Description
proxy Proxy (testcafe-hammerhead) Yes The hammerhead proxy instance to register routes on
options BrowserConnectionGatewayOptions Yes Configuration including retryTestPages flag

Outputs

Name Type Description
connectUrl string The URL remote browsers use to connect
connections Dictionary<BrowserConnection> Active browser connections keyed by ID
events ready, initialized Emitted lifecycle events

Usage Examples

// Internal usage during TestCafe server initialization
import { Proxy } from 'testcafe-hammerhead';
import BrowserConnectionGateway from './browser/connection/gateway';

// 1. Create gateway with proxy
const proxy = new Proxy('localhost', 1337, 1338);
const gateway = new BrowserConnectionGateway(proxy, { retryTestPages: false });

// 2. Initialize with server options
gateway.initialize({ hostname: 'localhost', port1: 1337, port2: 1338 });

// 3. Register a browser connection
gateway.startServingConnection(browserConnection);

// 4. Dispose when shutting down
gateway.close();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment