mattsse / chromiumoxide

Chrome Devtools Protocol rust API
Apache License 2.0
712 stars 69 forks source link

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

Closed jvatic closed 8 months ago

jvatic commented 8 months ago

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 ;)