High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: GET /visible reads inline style only, so a fixed-position element styled by a stylesheet reports not visible (PIN-195)
Luigi Agosti1a2cdb29a5c3
diff --git a/internal/handlers/visible.go b/internal/handlers/visible.goindex 8bdbd1c5..4280b3ba 100644--- a/internal/handlers/visible.go+++ b/internal/handlers/visible.go@@ -31,12 +31,6 @@ func (h *Handlers) HandleTabGetVisible(w http.ResponseWriter, r *http.Request) {h.withPathTabID(w, r, h.HandleGetVisible)}-// elementVisibleJS asks whether CSS renders an element. The position comes from the-// computed style, not el.style: el.style is the inline attribute alone, and offsetParent is-// null for every fixed element by design — so the branch that exists to rescue that case-// only fired when the author happened to write position in a style= attribute, and a modal,-// banner or toolbar positioned by a class or stylesheet rule was reported not visible while-// sitting on screen with real geometry.const elementVisibleJS = `function() {var el = this;var style = window.getComputedStyle(el);@@ -46,7 +40,6 @@ const elementVisibleJS = `function() {return rect.width > 0 && rect.height > 0;}`-// getElementVisible resolves a unified selector to a DOM node and checks whether it is visible.func (h *Handlers) getElementVisible(ctx context.Context, tabID, sel string) (bool, error) {return callOnResolvedElement[bool](h, ctx, tabID, sel, elementVisibleJS, nil)}diff --git a/internal/handlers/visible_test.go b/internal/handlers/visible_test.goindex 2b4d273e..b33ac069 100644--- a/internal/handlers/visible_test.go+++ b/internal/handlers/visible_test.go@@ -155,9 +155,6 @@ func (m *visibleMockBridge) GetRefCache(tabID string) *bridge.RefCache {return m.refCache}-// visibleFixtureHTML pairs each positioned case with an identically-styled twin that differs-// only in WHERE the CSS was written, since that is the only input the defect turned on, and-// adds the hidden cases as negative controls so a guard loosened too far is caught.const visibleFixtureHTML = `<style>#fixedByStylesheet { position: fixed; top:10px; left:10px; width:120px; height:40px }#stickyByStylesheet { position: sticky; top:0; width:120px; height:40px }@@ -174,8 +171,6 @@ const visibleFixtureHTML = `<style><div id="opacityZero" style="opacity:0; width:120px; height:40px">opacity zero</div><div id="zeroSize" style="width:0; height:0">zero size</div>`-// runElementVisibleJS drives the production predicate against a real element, because the-// defect lived entirely inside the browser: the endpoint's own plumbing was never wrong.func runElementVisibleJS(t *testing.T, ctx context.Context, selector string) bool {t.Helper()@@ -207,10 +202,6 @@ func runElementVisibleJS(t *testing.T, ctx context.Context, selector string) booreturn visible}-// offsetParent is null for every fixed element, so the branch that rescues that case decided-// the answer on its own — and while it read the inline style attribute it only rescued an-// element whose author wrote position in a style= attribute. A modal, cookie banner or-// toolbar positioned by a stylesheet rule reported not visible with real on-screen geometry.func TestTheVisibleEndpointReadsThePositionCSSComputed(t *testing.T) {chromePath := testbrowser.Path(t)@@ -256,9 +247,7 @@ func TestTheVisibleEndpointReadsThePositionCSSComputed(t *testing.T) {}}-// The browser-backed table above does not run where no browser is installed, and this is the-// invariant it exists to protect: the position must come from the computed style, and from-// the one call the predicate already makes rather than a second one.+// The browser-backed table above does not run where no browser is installed.func TestTheVisiblePredicateNeverReadsTheInlineStyleAttribute(t *testing.T) {if strings.Contains(elementVisibleJS, "el.style.") {t.Errorf("the visible predicate reads the inline style attribute:\n%s", elementVisibleJS)