Skip to content

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

refactor: delete GetElementCenterJS, its facade wrapper and its test — four cards deferred this deletion to each other and a boundary-census exemption now reads 'dead pending deletion' with nothing pending it (PIN-241)

Luigi Agosti42057d8b2153
diff --git a/internal/bridge/cdp_geometry_test.go b/internal/bridge/cdp_geometry_test.go
index 8a9ae926..03bef928 100644
--- a/internal/bridge/cdp_geometry_test.go
+++ b/internal/bridge/cdp_geometry_test.go
@@ -9,18 +9,6 @@ import (
"testing"
)
-// TestGetElementCenterJS_ContextCancelled verifies that getElementCenterJS
-// returns an error when the context is already cancelled (no browser panic).
-func TestGetElementCenterJS_ContextCancelled(t *testing.T) {
- ctx, cancel := context.WithCancel(context.Background())
- cancel()
-
- _, _, err := getElementCenterJS(ctx, 1)
- if err == nil {
- t.Error("expected error for cancelled context, got nil")
- }
-}
-
func TestPointerPointForNode_ContextCancelled(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
diff --git a/internal/bridge/cdpops/geometry.go b/internal/bridge/cdpops/geometry.go
index a7e8ecac..89357a11 100644
--- a/internal/bridge/cdpops/geometry.go
+++ b/internal/bridge/cdpops/geometry.go
@@ -2,66 +2,11 @@ package cdpops
import (
"context"
- "encoding/json"
"fmt"
"github.com/chromedp/chromedp"
)
-// GetElementCenterJS resolves the DOM node and evaluates getBoundingClientRect().
-func GetElementCenterJS(ctx context.Context, backendNodeID int64) (float64, float64, error) {
- var resolveResult json.RawMessage
- if err := chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
- return chromedp.FromContext(ctx).Target.Execute(ctx, "DOM.resolveNode", map[string]any{
- "backendNodeId": backendNodeID,
- }, &resolveResult)
- })); err != nil {
- return 0, 0, fmt.Errorf("DOM.resolveNode: %w", err)
- }
-
- var resolved struct {
- Object struct {
- ObjectID string `json:"objectId"`
- } `json:"object"`
- }
- if err := json.Unmarshal(resolveResult, &resolved); err != nil {
- return 0, 0, err
- }
- if resolved.Object.ObjectID == "" {
- return 0, 0, fmt.Errorf("element not found in DOM (backendNodeId=%d)", backendNodeID)
- }
-
- const rectFn = `function() {
- var r = this.getBoundingClientRect();
- return { x: r.left + r.width / 2, y: r.top + r.height / 2 };
- }`
-
- var callResult json.RawMessage
- if err := chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
- return chromedp.FromContext(ctx).Target.Execute(ctx, "Runtime.callFunctionOn", map[string]any{
- "functionDeclaration": rectFn,
- "objectId": resolved.Object.ObjectID,
- "returnByValue": true,
- }, &callResult)
- })); err != nil {
- return 0, 0, fmt.Errorf("getBoundingClientRect: %w", err)
- }
-
- var callRes struct {
- Result struct {
- Value struct {
- X float64 `json:"x"`
- Y float64 `json:"y"`
- } `json:"value"`
- } `json:"result"`
- }
- if err := json.Unmarshal(callResult, &callRes); err != nil {
- return 0, 0, err
- }
-
- return callRes.Result.Value.X, callRes.Result.Value.Y, nil
-}
-
func ScrollIntoViewIfNeeded(ctx context.Context, nodeID int64) error {
if err := chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
return chromedp.FromContext(ctx).Target.Execute(ctx, "DOM.scrollIntoViewIfNeeded", map[string]any{"backendNodeId": nodeID}, nil)
diff --git a/internal/bridge/cdpops_facade.go b/internal/bridge/cdpops_facade.go
index 6269eb90..5b1593db 100644
--- a/internal/bridge/cdpops_facade.go
+++ b/internal/bridge/cdpops_facade.go
@@ -45,10 +45,6 @@ func SetResourceBlocking(ctx context.Context, patterns []string) error {
return bridgecdpops.SetResourceBlocking(ctx, patterns)
}
-func getElementCenterJS(ctx context.Context, backendNodeID int64) (float64, float64, error) {
- return bridgecdpops.GetElementCenterJS(ctx, backendNodeID)
-}
-
// ScrollIntoViewAndGetBox scrolls the element into view and reports the box it
// ended up at, in the same top-level viewport space /box and /capture report.
func ScrollIntoViewAndGetBox(ctx context.Context, nodeID int64) (map[string]any, error) {
diff --git a/internal/bridge/isolated_world_test.go b/internal/bridge/isolated_world_test.go
index e9a778ad..3988abd2 100644
--- a/internal/bridge/isolated_world_test.go
+++ b/internal/bridge/isolated_world_test.go
@@ -188,7 +188,6 @@ var mainWorldResolvers = map[string]string{
"internal/bridge/cdpops/element_ops.go": "element ops act on an already-chosen node",
"internal/bridge/cdpops/frame_dom.go": "callFunctionOn helper for an already-chosen node",
"internal/bridge/cdpops/pointer.go": "pointer actions act on an already-chosen node",
- "internal/bridge/cdpops/geometry.go": "dead pending deletion: GetElementCenterJS reaches production through no caller — only the unexported facade wrapper and its cancellation test; the live click-point path is PointerPointForNode, which is isolated",
}
// resolveNodeSpellings pairs each way of issuing DOM.resolveNode with the token