Skip to content

Delegate OpenTelemetryTab.targetInfo to the wrapped tab#72

Merged
nathanfallet merged 1 commit into
mainfrom
fix/otel-targetinfo-delegation
May 23, 2026
Merged

Delegate OpenTelemetryTab.targetInfo to the wrapped tab#72
nathanfallet merged 1 commit into
mainfrom
fix/otel-targetinfo-delegation

Conversation

@nathanfallet
Copy link
Copy Markdown
Member

Summary

OpenTelemetryTab.targetInfo was declared as override var targetInfo = tab.targetInfo — a stored property initialized once at construction. So a traced tab kept reporting stale target info after navigation (the wrapped tab's targetInfo updates via events / updateTarget() were never reflected), and writes to the wrapper never reached the underlying tab.

This affected every targetId/url/type read on a traced tab — activate, getWindow, saveScreenshot filename, getAllUrls, and screenshotB64's wait()updateTarget() (which updated the wrong object).

Fix

Delegate get/set onto the wrapped tab, matching the existing lastMouseX/lastMouseY pattern:

override var targetInfo: Target.TargetInfo?
    get() = tab.targetInfo
    set(value) { tab.targetInfo = value }

Verification (red → green)

Added OpenTelemetryTabTargetInfoTest (mockk Tab with a mutable backing targetInfo, no browser):

  • getter test: mutate the underlying value after wrapping → wrapper must reflect it (not a snapshot).
  • setter test: write through the wrapper → must propagate to the wrapped tab.

Both fail on the snapshot implementation and pass after the fix. Full :opentelemetry:jvmTest passes.

Test plan

  • ./gradlew :opentelemetry:jvmTest --tests "*.OpenTelemetryTabTargetInfoTest" — red on unfixed code, green after fix
  • ./gradlew :opentelemetry:jvmTest — all pass

targetInfo was declared as `override var targetInfo = tab.targetInfo`, a stored
property initialized once at construction. A traced tab therefore reported stale
target info after navigation (the wrapped tab's targetInfo updates via events /
updateTarget were never reflected), and writes to the wrapper never reached the
underlying tab. Every targetId/url/type read on a traced tab (activate,
getWindow, saveScreenshot filename, getAllUrls, screenshotB64's wait/updateTarget)
could be wrong.

Delegate get/set onto the wrapped tab, matching the existing lastMouseX/lastMouseY
pattern.

Verified red->green with OpenTelemetryTabTargetInfoTest (mockk Tab with a mutable
backing targetInfo): the getter test mutates the underlying value after wrapping
and asserts the wrapper reflects it; the setter test asserts a write propagates to
the wrapped tab. Both fail on the snapshot impl, pass after the fix. Full
:opentelemetry:jvmTest passes.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@nathanfallet nathanfallet merged commit c3fe6f5 into main May 23, 2026
5 checks passed
@nathanfallet nathanfallet deleted the fix/otel-targetinfo-delegation branch May 23, 2026 09:11
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.

1 participant