Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

test: drop flaky negative background-capture assertion, keep the positive regression test

Luigi Agosti25623a53933c
diff --git a/internal/bridge/capture_background_tab_test.go b/internal/bridge/capture_background_tab_test.go
index eab66cea..5a0c61f1 100644
--- a/internal/bridge/capture_background_tab_test.go
+++ b/internal/bridge/capture_background_tab_test.go
@@ -85,68 +85,3 @@ func TestCaptureScreenshotOfBackgroundTabCompletesQuickly(t *testing.T) {
t.Fatal("capture returned no image bytes")
}
}
-
-// TestCaptureScreenshotOfBackgroundTabBlocksWhenActivationDisabled documents
-// the accepted trade-off of DisableActivation: without Page.bringToFront, a
-// genuinely backgrounded tab's compositor never resumes, so the capture
-// blocks until the context deadline instead of completing. This is the same
-// hang TestCaptureScreenshotOfBackgroundTabCompletesQuickly proves is fixed
-// by default — this test guards that the opt-out still reproduces it
-// deliberately, rather than the fix accidentally covering both cases.
-func TestCaptureScreenshotOfBackgroundTabBlocksWhenActivationDisabled(t *testing.T) {
- chromePath, err := exec.LookPath("chromium")
- if err != nil {
- t.Skip("chromium not installed")
- }
- profile, err := os.MkdirTemp("", "pinchtab-bg-capture-noactivate-")
- if err != nil {
- t.Fatal(err)
- }
- t.Cleanup(func() { _ = os.RemoveAll(profile) })
-
- alloc, cancelAlloc := chromedp.NewExecAllocator(context.Background(), append(
- chromedp.DefaultExecAllocatorOptions[:],
- chromedp.ExecPath(chromePath),
- chromedp.UserDataDir(profile),
- chromedp.Flag("headless", true),
- chromedp.Flag("no-sandbox", true),
- )...)
- defer cancelAlloc()
-
- browserCtx, cancelBrowser := chromedp.NewContext(alloc)
- defer cancelBrowser()
- if err := chromedp.Run(browserCtx); err != nil {
- t.Fatalf("start browser: %v", err)
- }
-
- html := `<h1>background tab</h1>`
- dataURL := "data:text/html;base64," + base64.StdEncoding.EncodeToString([]byte(html))
-
- var bgTarget target.ID
- if err := chromedp.Run(browserCtx, chromedp.ActionFunc(func(ctx context.Context) error {
- id, err := target.CreateTarget(dataURL).WithBackground(true).Do(ctx)
- bgTarget = id
- return err
- })); err != nil {
- t.Fatalf("create background target: %v", err)
- }
-
- bgCtx, cancelBg := chromedp.NewContext(browserCtx, chromedp.WithTargetID(bgTarget))
- defer cancelBg()
-
- // Short deadline: we expect this to time out, not succeed.
- captureCtx, cancelCapture := context.WithTimeout(bgCtx, 3*time.Second)
- defer cancelCapture()
-
- if err := chromedp.Run(captureCtx); err != nil {
- t.Fatalf("attach to background target: %v", err)
- }
-
- _, err = CaptureScreenshot(captureCtx, ScreenshotOpts{
- Format: page.CaptureScreenshotFormatPng,
- DisableActivation: true,
- })
- if err == nil {
- t.Fatal("capture with activation disabled succeeded on a background tab, want it to block until the deadline")
- }
-}