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

expose frame execution context, url, name, and parent #185

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

jvatic
Copy link
Contributor

@jvatic jvatic commented Nov 2, 2023

This exposes access to any frame's url, name, parent id, and both primary and secondary execution context ids stored in Target via Page and the TargetMessage channel.

Currently this is only possible by accessing handler.targets() directly (with the exception of Frame.parent_frame which isn't exposed at all outside of CDP methods), e.g.:

  // ...
  tokio::spawn(async move {
      loop {
          tokio::select! {
              res = handler.next() => {
                  res.unwrap();
              },
              req = some_channel.recv() => {
                  // get data from `handler.targets()`
              },
          }
      }
  });
  // ...

(^ this feels a bit hacky for my liking.)

While I've included a few minor breaking changes (TargetMessage::Url, and PageInner.execution_context_for_world), these don't appear to be usable outside of the crate, so the external API should remain stable.

Please let me know if there are any changes you'd like me to make before merging, or if there's a simpler way of getting this information ;)

Copy link
Owner

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

nice, ty

@mattsse mattsse merged commit 1b9d619 into mattsse:main Nov 6, 2023
7 checks passed
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.

2 participants