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

Javascript binding integration #17

Closed
nmoinvaz opened this issue May 17, 2019 · 4 comments
Closed

Javascript binding integration #17

nmoinvaz opened this issue May 17, 2019 · 4 comments
Labels
feature request feature request

Comments

@nmoinvaz
Copy link

nmoinvaz commented May 17, 2019

This might already be in the works, but I think there should be a deeper way to integrate with the javascript engine. I realize that you already have the postMessage functionality and the ability to insert a javascript snippet before the document loads.

  • CEF allows for javascript integration with the v8 javascript engine using the CefRegisterExtension function.

  • Apple WebKit allows for modifying the script environment using the windowScriptObject.

  • In IE/Trident it is possible through IDispatchEx after the document is done loading.

  • WebKitGTK allows for manipulation of the javascript context and ability to call from javascript functions to native code through the use of extensions for version 2 and a signal in earlier versions pre-multi-process.

@nmoinvaz nmoinvaz changed the title Javascript Binding Integration Javascript binding integration May 17, 2019
@david-risney
Copy link
Contributor

Thanks yes this is on our list for the future. Can you describe how you intend to use it? Of the various native-object-injection-like features you've listed above or tried out, does any aspects of those features jump out as particularly good or bad?

@david-risney david-risney added the feature request feature request label May 17, 2019
@nmoinvaz
Copy link
Author

nmoinvaz commented May 17, 2019

There are complexities with each one of them mainly around the fact that the browser engines use multiple processes.

WebKitGTK was a bit more complicated because it required the use of a separate extension "DLL", but we were able to overcome that by making the executable also export the functions for the extension. Some earlier versions of WebKitGTK didn't require this so we have two ways. Preferably we don't want to have to implement a separate extension DLL. JavascriptCoreGTK is a really simple library to use when implementing with it.

I don't think the method we used by IWebBrowser2 was particularly good because it required us to wait for the document to complete loading before registering the invoker. Although it did allow us to only register it on certain pages, but we aren't loading anything we don't control.

Apple WebKit I believe was simplified due to features (selectors, etc) of the Objective C language.

Probably the best solution is to continue to use IDispatchEx in some form or another since you are already using COM interfaces but perhaps don't require us to register it after the page is complete.

@afshinjafari
Copy link

+1
We use CefSharp and the javascript object binding was very useful for us and is critical if we decide to switch to Edge. the way it is used in our solution is to nominate a proxy object using browser.RegisterJsObject method. the proxy class runs a script in the browser (ExecuteScriptAsync) which are basically listeners for the web application events (the web application is an in house solution we needed to embed in winform for some reason).
those event listeners then can call proxy methods to handle winform actions.

@liminzhu
Copy link
Member

liminzhu commented Oct 28, 2019

Hey all. Happy to report that we just shipped native object injection support in 0.8.314. Closing the issue for now and feel free to re-open the issue and let us know if you have additional feedback.

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

4 participants