Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Page.executionContextForID #1009

Merged
merged 4 commits into from
Aug 23, 2023
Merged

Add Page.executionContextForID #1009

merged 4 commits into from
Aug 23, 2023

Conversation

ka3de
Copy link
Collaborator

@ka3de ka3de commented Aug 23, 2023

What?

Adds support to retrieve the associated execution context from within all page frames for a given ID.

Why?

This is required to associate CDP runtime events for a given page, which include the associated execution context ID (e.g.: see onConsoleAPICalled), with the execution context itself among the page frames and their sessions.

Checklist

  • I have performed a self-review of my code

Related PR(s)/Issue(s)

Related #1006 .

@ka3de ka3de self-assigned this Aug 23, 2023
@ka3de ka3de requested review from ankur22 and inancgumus August 23, 2023 06:54
inancgumus
inancgumus previously approved these changes Aug 23, 2023
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I wish we had some tests to validate that this really works without deadlocks and data races. I'm saying this because execution contexts and frame sessions have been the most challenging parts of the module to debug, and they used to fail a lot. It'd nice to have nolint for the current linter warnings and then we can lift them in the other console.log PR.

@ka3de
Copy link
Collaborator Author

ka3de commented Aug 23, 2023

LGTM, but I wish we had some tests to validate that this really works without deadlocks and data races. I'm saying this because execution contexts and frame sessions have been the most challenging parts of the module to debug, and they used to fail a lot. It'd nice to have nolint for the current linter warnings and then we can lift them in the other console.log PR.

Just added the nolint instructions for the unused methods until we complete #1006. See 9318ba9.

In regards of tests, I thought about it, but a unit test was providing pretty much no value, and it would be fairly difficult to try to force a data race or a deadlock for frame attach events only in an integration test (as in this PR these new methods are not even called). Isn't this better suited for e2e tests once we also process events and have a better "platform" for them?

@inancgumus inancgumus self-requested a review August 23, 2023 07:58
inancgumus
inancgumus previously approved these changes Aug 23, 2023
@ka3de ka3de force-pushed the feat/exectx-for-id branch from 9318ba9 to cf32d1a Compare August 23, 2023 10:43
common/frame_session.go Outdated Show resolved Hide resolved
ankur22
ankur22 previously approved these changes Aug 23, 2023
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Just one minor comment about ranging over the map instead of accessing with the key.

ka3de added 4 commits August 23, 2023 14:58
Use a RWMutex as frameSessions could have concurrent accesses from
attachFrameSession and also async event processing for the page.
Allows to look for an specific execution context in a given frame
session. This is necessary in order to associate frame events (e.g.:
consoleAPICalled) with their associated execution context.
Allows to look for an specific execution context in all frames for a
given page. This is necessary in order to associate events (e.g.:
consoleAPICalled) with their execution context.
This is added temporarily until these methods are used in a related PR
(see #1006).
@ka3de ka3de dismissed stale reviews from ankur22 and inancgumus via 783e843 August 23, 2023 12:59
@ka3de ka3de force-pushed the feat/exectx-for-id branch from cf32d1a to 783e843 Compare August 23, 2023 12:59
@inancgumus inancgumus self-requested a review August 23, 2023 13:01
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙂

@ka3de ka3de merged commit f8f9bfb into main Aug 23, 2023
@ka3de ka3de deleted the feat/exectx-for-id branch August 23, 2023 13:28
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.

3 participants