Skip to content

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

feat: make background-tab capture activation configurable via instanceDefaults.captureAllowActivation

Luigi Agosti48b42003bef1
diff --git a/docs/reference/config.md b/docs/reference/config.md
index 29fc19bf..6b8c7bc9 100644
--- a/docs/reference/config.md
+++ b/docs/reference/config.md
@@ -211,6 +211,7 @@ Current nested file-config shape:
"maxParallelTabs": 0,
"userAgent": "",
"noAnimations": false,
+ "captureAllowActivation": true,
"humanize": false,
"stealthLevel": "light",
"tabEvictionPolicy": "close_lru",
diff --git a/internal/bridge/screenshot.go b/internal/bridge/screenshot.go
index 85e09d15..c04a4985 100644
--- a/internal/bridge/screenshot.go
+++ b/internal/bridge/screenshot.go
@@ -122,6 +122,13 @@ type ScreenshotOpts struct {
// observe.FetchLayout (or similar) before invoking CaptureScreenshot.
ViewportWidth float64
ViewportHeight float64
+
+ // AllowActivation permits Page.bringToFront to wake a backgrounded tab's
+ // compositor before capturing (security.instanceDefaults.captureAllowActivation,
+ // default true). When false, capture relies solely on focus emulation and
+ // never raises the tab in the operator's browser, accepting that a
+ // background tab's capture may then block until the caller's deadline.
+ AllowActivation bool
}
func scaledScreenshotClip(opts ScreenshotOpts, viewportWidth, viewportHeight, documentWidth, documentHeight float64) *page.Viewport {
@@ -170,11 +177,16 @@ func captureFromSurface(beyondViewport bool, clip *page.Viewport) bool {
return clip != nil && clip.Scale != 0 && clip.Scale != 1
}
-// captureScreenshotWithoutActivation wakes a background renderer without
-// activating its tab in the operator's browser. Chromium supports focus
-// emulation on attached targets; providers that reject it retain the historical
-// BringToFront fallback so capture availability does not regress.
-func captureScreenshotWithoutActivation(ctx context.Context, shot *page.CaptureScreenshotParams) ([]byte, error) {
+// captureScreenshotWithoutActivation wakes a background renderer before
+// capturing it. Focus emulation alone does not resume a backgrounded tab's
+// compositor — that requires Page.bringToFront — so when allowActivation is
+// true (the default) it always runs as well; focus emulation is layered on
+// top only so document.hasFocus()/`:focus` reflect the capture as
+// best-effort. When allowActivation is false, the tab is never raised in the
+// operator's browser, accepting that its capture may then block until the
+// caller's deadline (Chromium never resumes a backgrounded compositor
+// without either activation or being brought into view).
+func captureScreenshotWithoutActivation(ctx context.Context, shot *page.CaptureScreenshotParams, allowActivation bool) ([]byte, error) {
executor := cdp.ExecutorFromContext(ctx)
focusEmulated := emulation.SetFocusEmulationEnabled(true).Do(ctx) == nil
if focusEmulated {
@@ -184,7 +196,8 @@ func captureScreenshotWithoutActivation(ctx context.Context, shot *page.CaptureS
restoreCtx = cdp.WithExecutor(restoreCtx, executor)
_ = emulation.SetFocusEmulationEnabled(false).Do(restoreCtx)
}()
- } else {
+ }
+ if allowActivation {
_ = page.BringToFront().Do(ctx)
}
return shot.Do(ctx)
@@ -232,7 +245,7 @@ func CaptureScreenshot(ctx context.Context, opts ScreenshotOpts) ([]byte, error)
shot = shot.WithQuality(int64(opts.Quality))
}
var inner error
- buf, inner = captureScreenshotWithoutActivation(ctx, shot)
+ buf, inner = captureScreenshotWithoutActivation(ctx, shot, opts.AllowActivation)
return inner
}))
return buf, err
@@ -337,8 +350,7 @@ func ScreenshotClipForNode(ctx context.Context, nodeID int64) (*ScreenshotClip,
// CaptureScreenshot is the provider-aware entry point used across the BridgeAPI
// (screencast polling, recorder, annotated capture). It delegates to the shared
// package-level CaptureScreenshot engine so every provider gets the same
-// rendering path, including non-activating focus emulation and
-// WithFromSurface(false), so headed browsers can paint without stealing focus.
+// rendering path, gated by b.Config.CaptureAllowActivation (default true).
func (b *Bridge) CaptureScreenshot(ctx context.Context, format string, quality int, clip *cdptk.ScreenshotClip) ([]byte, error) {
cdpFormat := page.CaptureScreenshotFormatJpeg
if format == "png" {
@@ -354,10 +366,12 @@ func (b *Bridge) CaptureScreenshot(ctx context.Context, format string, quality i
Scale: clip.Scale,
}
}
+ allowActivation := b.Config == nil || b.Config.CaptureAllowActivation
buf, err := CaptureScreenshot(ctx, ScreenshotOpts{
- Format: cdpFormat,
- Quality: quality,
- Clip: vp,
+ Format: cdpFormat,
+ Quality: quality,
+ Clip: vp,
+ AllowActivation: allowActivation,
})
if err != nil {
return nil, fmt.Errorf("screenshot: %w", err)
diff --git a/internal/bridge/screenshot_test.go b/internal/bridge/screenshot_test.go
index f4493c7c..00d5e7b3 100644
--- a/internal/bridge/screenshot_test.go
+++ b/internal/bridge/screenshot_test.go
@@ -35,7 +35,7 @@ func (e *screenshotExecutor) Execute(_ context.Context, method string, params, r
func TestCaptureScreenshotWithoutActivationRestoresFocusEmulation(t *testing.T) {
exec := &screenshotExecutor{}
ctx := cdp.WithExecutor(context.Background(), exec)
- got, err := captureScreenshotWithoutActivation(ctx, page.CaptureScreenshot())
+ got, err := captureScreenshotWithoutActivation(ctx, page.CaptureScreenshot(), true)
if err != nil {
t.Fatalf("capture: %v", err)
}
@@ -44,6 +44,7 @@ func TestCaptureScreenshotWithoutActivationRestoresFocusEmulation(t *testing.T)
}
wantMethods := []string{
emulation.CommandSetFocusEmulationEnabled,
+ page.CommandBringToFront,
page.CommandCaptureScreenshot,
emulation.CommandSetFocusEmulationEnabled,
}
@@ -58,7 +59,7 @@ func TestCaptureScreenshotWithoutActivationRestoresFocusEmulation(t *testing.T)
func TestCaptureScreenshotWithoutActivationRestoresAfterCaptureError(t *testing.T) {
exec := &screenshotExecutor{captureErr: errors.New("capture failed")}
ctx := cdp.WithExecutor(context.Background(), exec)
- if _, err := captureScreenshotWithoutActivation(ctx, page.CaptureScreenshot()); err == nil {
+ if _, err := captureScreenshotWithoutActivation(ctx, page.CaptureScreenshot(), true); err == nil {
t.Fatal("expected capture error")
}
if !reflect.DeepEqual(exec.focusFlags, []bool{true, false}) {
@@ -66,6 +67,19 @@ func TestCaptureScreenshotWithoutActivationRestoresAfterCaptureError(t *testing.
}
}
+func TestCaptureScreenshotWithoutActivationSkipsBringToFrontWhenDisallowed(t *testing.T) {
+ exec := &screenshotExecutor{}
+ ctx := cdp.WithExecutor(context.Background(), exec)
+ if _, err := captureScreenshotWithoutActivation(ctx, page.CaptureScreenshot(), false); err != nil {
+ t.Fatalf("capture: %v", err)
+ }
+ for _, m := range exec.methods {
+ if m == page.CommandBringToFront {
+ t.Fatalf("CDP methods = %v, want no %s", exec.methods, page.CommandBringToFront)
+ }
+ }
+}
+
func TestClampScale(t *testing.T) {
cases := []struct {
in, want float64
diff --git a/internal/config/config_file_json.go b/internal/config/config_file_json.go
index 8e78059f..1417f9e1 100644
--- a/internal/config/config_file_json.go
+++ b/internal/config/config_file_json.go
@@ -56,20 +56,21 @@ type cloakBrowserConfigJSON struct {
}
type instanceDefaultsConfigJSON struct {
- Mode string `json:"mode"`
- NoRestore *bool `json:"noRestore"`
- Timezone string `json:"timezone"`
- BlockImages *bool `json:"blockImages"`
- BlockMedia *bool `json:"blockMedia"`
- BlockAds *bool `json:"blockAds"`
- MaxTabs *int `json:"maxTabs"`
- MaxParallelTabs *int `json:"maxParallelTabs"`
- UserAgent string `json:"userAgent"`
- NoAnimations *bool `json:"noAnimations"`
- Humanize *bool `json:"humanize"`
- StealthLevel string `json:"stealthLevel"`
- TabEvictionPolicy string `json:"tabEvictionPolicy"`
- TabPolicy *TabPolicyDefaults `json:"tabPolicy,omitempty"`
+ Mode string `json:"mode"`
+ NoRestore *bool `json:"noRestore"`
+ Timezone string `json:"timezone"`
+ BlockImages *bool `json:"blockImages"`
+ BlockMedia *bool `json:"blockMedia"`
+ BlockAds *bool `json:"blockAds"`
+ MaxTabs *int `json:"maxTabs"`
+ MaxParallelTabs *int `json:"maxParallelTabs"`
+ UserAgent string `json:"userAgent"`
+ NoAnimations *bool `json:"noAnimations"`
+ CaptureAllowActivation *bool `json:"captureAllowActivation"`
+ Humanize *bool `json:"humanize"`
+ StealthLevel string `json:"stealthLevel"`
+ TabEvictionPolicy string `json:"tabEvictionPolicy"`
+ TabPolicy *TabPolicyDefaults `json:"tabPolicy,omitempty"`
}
type profilesConfigJSON struct {
diff --git a/internal/config/config_file_marshal.go b/internal/config/config_file_marshal.go
index a8b6bcda..ad38de40 100644
--- a/internal/config/config_file_marshal.go
+++ b/internal/config/config_file_marshal.go
@@ -189,20 +189,21 @@ func (fc FileConfig) MarshalJSON() ([]byte, error) {
Targets: fc.Browser.Targets,
},
InstanceDefaults: instanceDefaultsConfigJSON{
- Mode: fc.InstanceDefaults.Mode,
- NoRestore: fc.InstanceDefaults.NoRestore,
- Timezone: fc.InstanceDefaults.Timezone,
- BlockImages: fc.InstanceDefaults.BlockImages,
- BlockMedia: fc.InstanceDefaults.BlockMedia,
- BlockAds: fc.InstanceDefaults.BlockAds,
- MaxTabs: fc.InstanceDefaults.MaxTabs,
- MaxParallelTabs: fc.InstanceDefaults.MaxParallelTabs,
- UserAgent: fc.InstanceDefaults.UserAgent,
- NoAnimations: fc.InstanceDefaults.NoAnimations,
- Humanize: fc.InstanceDefaults.Humanize,
- StealthLevel: fc.InstanceDefaults.StealthLevel,
- TabEvictionPolicy: fc.InstanceDefaults.TabEvictionPolicy,
- TabPolicy: fc.InstanceDefaults.TabPolicy,
+ Mode: fc.InstanceDefaults.Mode,
+ NoRestore: fc.InstanceDefaults.NoRestore,
+ Timezone: fc.InstanceDefaults.Timezone,
+ BlockImages: fc.InstanceDefaults.BlockImages,
+ BlockMedia: fc.InstanceDefaults.BlockMedia,
+ BlockAds: fc.InstanceDefaults.BlockAds,
+ MaxTabs: fc.InstanceDefaults.MaxTabs,
+ MaxParallelTabs: fc.InstanceDefaults.MaxParallelTabs,
+ UserAgent: fc.InstanceDefaults.UserAgent,
+ NoAnimations: fc.InstanceDefaults.NoAnimations,
+ CaptureAllowActivation: fc.InstanceDefaults.CaptureAllowActivation,
+ Humanize: fc.InstanceDefaults.Humanize,
+ StealthLevel: fc.InstanceDefaults.StealthLevel,
+ TabEvictionPolicy: fc.InstanceDefaults.TabEvictionPolicy,
+ TabPolicy: fc.InstanceDefaults.TabPolicy,
},
Security: securityConfigJSON{
AllowEvaluate: fc.Security.AllowEvaluate,
@@ -362,6 +363,7 @@ func FileConfigFromRuntime(cfg *RuntimeConfig) FileConfig {
maxTabs := cfg.MaxTabs
maxParallelTabs := cfg.MaxParallelTabs
noAnimations := cfg.NoAnimations
+ captureAllowActivation := cfg.CaptureAllowActivation
humanize := cfg.Humanize
allowEvaluate := cfg.AllowEvaluate
allowMacro := cfg.AllowMacro
@@ -469,20 +471,21 @@ func FileConfigFromRuntime(cfg *RuntimeConfig) FileConfig {
Targets: cloneBrowserTargetsConfig(cfg.Targets),
},
InstanceDefaults: InstanceDefaultsConfig{
- Mode: mode,
- NoRestore: &noRestore,
- Timezone: cfg.Timezone,
- BlockImages: &blockImages,
- BlockMedia: &blockMedia,
- BlockAds: &blockAds,
- MaxTabs: &maxTabs,
- MaxParallelTabs: &maxParallelTabs,
- UserAgent: cfg.UserAgent,
- NoAnimations: &noAnimations,
- Humanize: &humanize,
- StealthLevel: cfg.StealthLevel,
- TabEvictionPolicy: cfg.TabEvictionPolicy,
- TabPolicy: tabPolicyDefaultsFromRuntime(cfg),
+ Mode: mode,
+ NoRestore: &noRestore,
+ Timezone: cfg.Timezone,
+ BlockImages: &blockImages,
+ BlockMedia: &blockMedia,
+ BlockAds: &blockAds,
+ MaxTabs: &maxTabs,
+ MaxParallelTabs: &maxParallelTabs,
+ UserAgent: cfg.UserAgent,
+ NoAnimations: &noAnimations,
+ CaptureAllowActivation: &captureAllowActivation,
+ Humanize: &humanize,
+ StealthLevel: cfg.StealthLevel,
+ TabEvictionPolicy: cfg.TabEvictionPolicy,
+ TabPolicy: tabPolicyDefaultsFromRuntime(cfg),
},
Security: SecurityConfig{
AllowEvaluate: &allowEvaluate,
diff --git a/internal/config/config_load.go b/internal/config/config_load.go
index 40a11956..67f7c5cc 100644
--- a/internal/config/config_load.go
+++ b/internal/config/config_load.go
@@ -172,31 +172,32 @@ func LoadConfig() (*RuntimeConfig, []LoadDiagnostic, error) {
UploadMaxTotalBytes: DefaultUploadMaxTotalBytes,
MaxRedirects: -1, // Unlimited by default; set to N to limit redirect hops
- Headless: true,
- NoRestore: false,
- ProfileDir: "",
- ProfilesBaseDir: "",
- DefaultProfile: "default",
- BrowserVersion: "144.0.7559.133",
- Timezone: "",
- BlockImages: false,
- BlockMedia: false,
- BlockAds: false,
- MaxTabs: 20,
- MaxParallelTabs: 0,
- DefaultBrowser: DefaultBrowserForSystem(),
- BrowserBinary: "", // Set via config.json only
- BrowserExtraFlags: "",
- Cloak: CloakBrowserRuntimeConfig{DisableDefaultStealthArgs: true},
- ExtensionPaths: []string{defaultExtensionsDir(userConfigDir())},
- UserAgent: "",
- NoAnimations: false,
- Humanize: false,
- StealthLevel: "light",
- TabEvictionPolicy: "close_lru",
- TabLifecyclePolicy: "keep",
- TabCloseDelay: 5 * time.Minute,
- TabRestore: false,
+ Headless: true,
+ NoRestore: false,
+ ProfileDir: "",
+ ProfilesBaseDir: "",
+ DefaultProfile: "default",
+ BrowserVersion: "144.0.7559.133",
+ Timezone: "",
+ BlockImages: false,
+ BlockMedia: false,
+ BlockAds: false,
+ MaxTabs: 20,
+ MaxParallelTabs: 0,
+ DefaultBrowser: DefaultBrowserForSystem(),
+ BrowserBinary: "", // Set via config.json only
+ BrowserExtraFlags: "",
+ Cloak: CloakBrowserRuntimeConfig{DisableDefaultStealthArgs: true},
+ ExtensionPaths: []string{defaultExtensionsDir(userConfigDir())},
+ UserAgent: "",
+ NoAnimations: false,
+ CaptureAllowActivation: true,
+ Humanize: false,
+ StealthLevel: "light",
+ TabEvictionPolicy: "close_lru",
+ TabLifecyclePolicy: "keep",
+ TabCloseDelay: 5 * time.Minute,
+ TabRestore: false,
ActionTimeout: 30 * time.Second,
NavigateTimeout: 60 * time.Second,
@@ -621,6 +622,9 @@ func applyFileConfig(cfg *RuntimeConfig, fc *FileConfig) {
if fc.InstanceDefaults.NoAnimations != nil {
cfg.NoAnimations = *fc.InstanceDefaults.NoAnimations
}
+ if fc.InstanceDefaults.CaptureAllowActivation != nil {
+ cfg.CaptureAllowActivation = *fc.InstanceDefaults.CaptureAllowActivation
+ }
if fc.InstanceDefaults.Humanize != nil {
cfg.Humanize = *fc.InstanceDefaults.Humanize
}
diff --git a/internal/config/config_types.go b/internal/config/config_types.go
index 3dbdcd3b..b4f6aeb9 100644
--- a/internal/config/config_types.go
+++ b/internal/config/config_types.go
@@ -84,12 +84,20 @@ type RuntimeConfig struct {
ExtensionPaths []string
UserAgent string
NoAnimations bool
- Humanize bool // when true, mouse moves and clicks use a humanized bezier path with per-step jitter and pre-press delays; default false (raw, fast input)
- StealthLevel string
- TabEvictionPolicy string // "close_lru" (default), "reject", "close_oldest" — fires on MaxTabs pressure
- TabLifecyclePolicy string // "keep" (default), "close_idle" — fires on idle after read/action
- TabCloseDelay time.Duration // applies when TabLifecyclePolicy == "close_idle" (default 5m when enabled)
- TabRestore bool // restore previously open tabs from sessions.json on startup (default false)
+ // CaptureAllowActivation controls whether GET /capture and GET/POST /screenshot
+ // may call Page.bringToFront to wake a backgrounded tab's compositor before
+ // capturing. Default true: capture is reliable but a background-tab capture
+ // visibly raises that tab in the operator's browser. Set false to keep
+ // background tabs from ever being activated during capture, accepting that
+ // a background tab's capture may then block until ActionTimeout — Chromium's
+ // focus emulation alone does not resume a backgrounded compositor.
+ CaptureAllowActivation bool
+ Humanize bool // when true, mouse moves and clicks use a humanized bezier path with per-step jitter and pre-press delays; default false (raw, fast input)
+ StealthLevel string
+ TabEvictionPolicy string // "close_lru" (default), "reject", "close_oldest" — fires on MaxTabs pressure
+ TabLifecyclePolicy string // "keep" (default), "close_idle" — fires on idle after read/action
+ TabCloseDelay time.Duration // applies when TabLifecyclePolicy == "close_idle" (default 5m when enabled)
+ TabRestore bool // restore previously open tabs from sessions.json on startup (default false)
ActionTimeout time.Duration
NavigateTimeout time.Duration
@@ -371,22 +379,23 @@ type BrowserItemConfig struct {
}
type InstanceDefaultsConfig struct {
- Mode string `json:"mode,omitempty"`
- Headless *bool `json:"headless,omitempty"`
- NoRestore *bool `json:"noRestore,omitempty"`
- Timezone string `json:"timezone,omitempty"`
- BlockImages *bool `json:"blockImages,omitempty"`
- BlockMedia *bool `json:"blockMedia,omitempty"`
- BlockAds *bool `json:"blockAds,omitempty"`
- MaxTabs *int `json:"maxTabs,omitempty"`
- MaxParallelTabs *int `json:"maxParallelTabs,omitempty"`
- UserAgent string `json:"userAgent,omitempty"`
- NoAnimations *bool `json:"noAnimations,omitempty"`
- Humanize *bool `json:"humanize,omitempty"`
- StealthLevel string `json:"stealthLevel,omitempty"`
- TabEvictionPolicy string `json:"tabEvictionPolicy,omitempty"` // Deprecated: use TabPolicy.Eviction
- TabPolicy *TabPolicyDefaults `json:"tabPolicy,omitempty"`
- DialogAutoAccept *bool `json:"dialogAutoAccept,omitempty"`
+ Mode string `json:"mode,omitempty"`
+ Headless *bool `json:"headless,omitempty"`
+ NoRestore *bool `json:"noRestore,omitempty"`
+ Timezone string `json:"timezone,omitempty"`
+ BlockImages *bool `json:"blockImages,omitempty"`
+ BlockMedia *bool `json:"blockMedia,omitempty"`
+ BlockAds *bool `json:"blockAds,omitempty"`
+ MaxTabs *int `json:"maxTabs,omitempty"`
+ MaxParallelTabs *int `json:"maxParallelTabs,omitempty"`
+ UserAgent string `json:"userAgent,omitempty"`
+ NoAnimations *bool `json:"noAnimations,omitempty"`
+ CaptureAllowActivation *bool `json:"captureAllowActivation,omitempty"`
+ Humanize *bool `json:"humanize,omitempty"`
+ StealthLevel string `json:"stealthLevel,omitempty"`
+ TabEvictionPolicy string `json:"tabEvictionPolicy,omitempty"` // Deprecated: use TabPolicy.Eviction
+ TabPolicy *TabPolicyDefaults `json:"tabPolicy,omitempty"`
+ DialogAutoAccept *bool `json:"dialogAutoAccept,omitempty"`
}
// TabPolicyDefaults groups eviction (cap pressure) and lifecycle (idle) policies
diff --git a/internal/config/editor_get.go b/internal/config/editor_get.go
index c552f3a0..f46196ed 100644
--- a/internal/config/editor_get.go
+++ b/internal/config/editor_get.go
@@ -280,6 +280,8 @@ func getInstanceDefaultsField(c *InstanceDefaultsConfig, field string) (string,
return c.UserAgent, nil
case "noAnimations":
return formatBoolPtr(c.NoAnimations), nil
+ case "captureAllowActivation":
+ return formatBoolPtr(c.CaptureAllowActivation), nil
case "humanize":
return formatBoolPtr(c.Humanize), nil
case "stealthLevel":
diff --git a/internal/config/editor_set.go b/internal/config/editor_set.go
index 6ab6db51..e5606b1a 100644
--- a/internal/config/editor_set.go
+++ b/internal/config/editor_set.go
@@ -399,6 +399,12 @@ func setInstanceDefaultsField(c *InstanceDefaultsConfig, field, value string) er
return fmt.Errorf("instanceDefaults.noAnimations: %w", err)
}
c.NoAnimations = &b
+ case "captureAllowActivation":
+ b, err := parseBool(value)
+ if err != nil {
+ return fmt.Errorf("instanceDefaults.captureAllowActivation: %w", err)
+ }
+ c.CaptureAllowActivation = &b
case "humanize":
b, err := parseBool(value)
if err != nil {
diff --git a/internal/handlers/capture.go b/internal/handlers/capture.go
index 92c91292..bf6ef83f 100644
--- a/internal/handlers/capture.go
+++ b/internal/handlers/capture.go
@@ -118,10 +118,11 @@ func (h *Handlers) HandleCapture(w http.ResponseWriter, r *http.Request) {
opts := bridge.CaptureOpts{
Image: bridge.ScreenshotOpts{
- Format: format,
- Quality: quality,
- BeyondViewport: beyondViewport,
- Scale: scale,
+ Format: format,
+ Quality: quality,
+ BeyondViewport: beyondViewport,
+ Scale: scale,
+ AllowActivation: h.Config.CaptureAllowActivation,
},
Filter: filter,
MaxDepth: depth,
diff --git a/internal/handlers/screenshot.go b/internal/handlers/screenshot.go
index 6abe015c..5392332c 100644
--- a/internal/handlers/screenshot.go
+++ b/internal/handlers/screenshot.go
@@ -96,20 +96,20 @@ func (h *Handlers) HandleScreenshot(w http.ResponseWriter, r *http.Request) {
}
// Route through the shared bridge.CaptureScreenshot engine: it carries the
- // scale/beyondViewport clip synthesis and the provider-runtime fixes
- // (non-activating focus emulation + WithFromSurface(false)) so capture works
- // without switching the operator's active tab; tCtx already targets the
- // active provider's CDP session.
+ // scale/beyondViewport clip synthesis and, when CaptureAllowActivation is
+ // enabled (the default), wakes a backgrounded tab's compositor before
+ // capturing; tCtx already targets the active provider's CDP session.
cdpFormat := bridge.ScreenshotFormatJpeg
if req.format == "png" {
cdpFormat = bridge.ScreenshotFormatPng
}
buf, captureErr := bridge.CaptureScreenshot(tCtx, bridge.ScreenshotOpts{
- Format: cdpFormat,
- Quality: req.quality,
- Clip: clip,
- BeyondViewport: req.beyondViewport,
- Scale: req.scale,
+ Format: cdpFormat,
+ Quality: req.quality,
+ Clip: clip,
+ BeyondViewport: req.beyondViewport,
+ Scale: req.scale,
+ AllowActivation: h.Config.CaptureAllowActivation,
})
if captureErr != nil {
httpx.Error(w, 500, fmt.Errorf("screenshot: %w", captureErr))
diff --git a/internal/schema/config.json b/internal/schema/config.json
index 3e2b3a3b..f4781348 100644
--- a/internal/schema/config.json
+++ b/internal/schema/config.json
@@ -359,6 +359,9 @@
"noAnimations": {
"$ref": "#/definitions/nullableBoolean"
},
+ "captureAllowActivation": {
+ "$ref": "#/definitions/nullableBoolean"
+ },
"humanize": {
"$ref": "#/definitions/nullableBoolean"
},