Skip to content

Conversation

@rgarcia
Copy link
Contributor

@rgarcia rgarcia commented Jan 21, 2026

Summary

  • Add E2E tests for CDP connection stability after Chromium restarts
  • Add E2E test for MV3 extension service worker registration and messaging
  • Fix chromium-launcher to properly kill existing processes before restart

Details

CDP Connection Tests (e2e_combined_flow_test.go)

TestExtensionViewportThenCDPConnection - Reproduces the scenario where profile loading fails to connect to CDP after back-to-back restarts:

  1. Upload extension (triggers Chromium restart)
  2. Change viewport (triggers another Chromium restart)
  3. Immediately attempt CDP WebSocket connection
  4. Verify Browser.getVersion command succeeds

TestMultipleCDPConnectionsAfterRestart - Tests connection stability:

  1. Upload extension to trigger restart
  2. Rapidly attempt 5 consecutive CDP connections
  3. Verify all connections succeed

MV3 Service Worker Tests (e2e_mv3_service_worker_test.go)

TestMV3ServiceWorkerRegistration - Verifies MV3 extensions work correctly:

  1. Upload test extension with service worker via /chromium/upload-extensions-and-restart
  2. Navigate to chrome://extensions and enable developer mode
  3. Verify extension is loaded with active service worker (not "(Inactive)")
  4. Navigate to extension popup and click "Ping Service Worker"
  5. Verify service worker responds with success message

Includes a test extension (server/e2e/test-extension/) with:

  • MV3 manifest with service worker background script
  • Popup that sends ping messages to service worker
  • Service worker that responds to verify it's alive

Chromium Launcher Fix

Added killExistingChromium() function that:

  • Kills any existing chromium processes before starting new one
  • Waits up to 2 seconds for processes to fully terminate
  • Fixes race condition where old process holds IPv4 port during restart

Test plan

  • TestExtensionViewportThenCDPConnection passes
  • TestMultipleCDPConnectionsAfterRestart passes
  • TestMV3ServiceWorkerRegistration passes
cd server/e2e
go test -v -run "TestExtensionViewport|TestMultipleCDP|TestMV3"

🤖 Generated with Claude Code


Note

Adds robust E2E coverage for browser restarts, CDP connectivity, and MV3 service workers, plus a launcher hardening to ensure clean Chromium restarts.

  • New Go tests: TestExtensionViewportThenCDPConnection and TestMultipleCDPConnectionsAfterRestart validate CDP stability after extension upload and viewport-change restarts and multiple rapid connects
  • New MV3 test (e2e_mv3_service_worker_test.go) with Playwright command verify-mv3-service-worker to inspect chrome://extensions, confirm active service worker, and verify popup -> SW messaging
  • Adds test extension assets under server/e2e/test-extension/ and expands Playwright index.ts with the verification flow; updates tsconfig.json libs to include DOM
  • Chromium launcher (server/cmd/chromium-launcher/main.go) now calls killExistingChromium() to pkill -9 -x chromium and wait up to 2s before relaunch, preventing IPv4/IPv6 bind conflicts

Written by Cursor Bugbot for commit 2babbd1. This will update automatically on new commits. Configure here.

Add comprehensive E2E tests for critical browser functionality:

**CDP Connection Tests (e2e_combined_flow_test.go)**
- TestExtensionViewportThenCDPConnection: Tests CDP connections work correctly
  after back-to-back Chromium restarts (extension upload → viewport change → CDP)
- TestMultipleCDPConnectionsAfterRestart: Tests rapid successive CDP connections
  after a Chromium restart

**MV3 Service Worker Tests (e2e_mv3_service_worker_test.go)**
- TestMV3ServiceWorkerRegistration: Verifies MV3 extensions with service workers
  are properly loaded and responsive
- Includes test extension with service worker that responds to ping messages
- Playwright script pierces chrome://extensions shadow DOM to verify status

**Chromium Launcher Fix**
- Add killExistingChromium() to ensure clean restarts
- Fixes race condition where old process holds IPv4 port during restart

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

The killExistingChromium function was using `pkill -f chromium` which matches
any process with "chromium" in its command line. This included chromium-launcher
itself, causing it to SIGKILL itself immediately on startup.

Changed to `pkill -x chromium` which uses exact process name matching, so it
only kills the actual chromium browser process without matching chromium-launcher.

This fixes all CI tests failing with exit status 137 (SIGKILL).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rgarcia rgarcia merged commit 28ba1ac into main Jan 22, 2026
5 checks passed
@rgarcia rgarcia deleted the rgarcia/e2e-cdp-and-mv3-tests branch January 22, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants