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

[Feature]: flat mode in CoreWebView2.CallDevToolsProtocolMethodAsync #4665

Open
trebahl opened this issue Jul 5, 2024 · 1 comment
Open
Labels
feature request feature request

Comments

@trebahl
Copy link

trebahl commented Jul 5, 2024

Describe the feature/enhancement you need

DevTools has a so called flat mode where you specify a sessionId to apply commands to. I would like to specify a session id in CoreWebView2.CallDevToolsProtocolMethodAsync.

The scenario/use case where you would use this feature

I am using webview to display a pdf. I would like to programatically jump to a specific page, when certain events happen within my application. There is no visible api for that. However, using the inspector, I found that calling window.viewer.currentController_.goToPage should do the trick, provided I can inject javascript code into the context of the pdf viewer, which is hidden inside an embed, seemingly not accessible from the context of the main page.

If I call Target.getTargets I can find a target that seems to correspond to the insides of the embed. So I need to call Runtime.evaluate on the session id of this target.

How important is this request to you?

Critical. My app's basic functions wouldn't work without it.

Suggested implementation

According to https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md, in order to use flat mode, you just need to add the session id as the first member in the toplevel object :
await SEND(ws, { sessionId, id: 1, // Note that IDs are independent between sessions. method: 'Page.navigate', params: { url: 'https://pptr.dev', }, });

I suppose it wouldn't be difficult to have an overload of CallDevToolsProtocolMethodAsync accepting a session id argument.

What does your app do? Is there a pending deadline for this request?

My app is displaying a pdf manual, and jumping to the relevant part of it based on what the user is doing. So far I was using an older pdf viewer control (foxit), but I want to upgrade from .net framework to .net, and there does not appear to be a .net version of the foxit display library (it seems to be retired; they are now only selling libraries to read and write pdfs). I can't upgrade to .net until I find a replacement viewer.

@trebahl trebahl added the feature request feature request label Jul 5, 2024
@trebahl
Copy link
Author

trebahl commented Jul 9, 2024

Sorry, I have just discovered that it is already possible with CoreWebView2.CallDevToolsProtocolMethodForSessionAsync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request
Projects
None yet
Development

No branches or pull requests

1 participant