Open gimenete opened 7 years ago
Thanks for implementing that!
Actually I don't really want to support both WebKit interfaces... I started out using WKWebView, but then realized that it's not possible to add custom JavaScript objects into the JSContext because WebKit2 runs the browser in a separate process.
(In other words, - (void)webView:didCreateJavaScriptContext:forFrame:
only exists for the old WebKit1 WebView.)
I'm still hoping that we might be able to use WKWebView without crippling the Electron browser-side API. Some of those APIs could just be loaded as plain JavaScript, as they don't really require a native implementation (e.g. "process"). For ones that do need to call back to the native side, WebKit2 provides an async message-passing interface (window.webkit.messageHandlers
) which could be enough of a building block. I'll need to research this further.
I was trying to implement the
window.webContents.openDevTools()
method. It's not trivial programmatically but can be open manually if thedeveloperExtrasEnabled
flag is set toTRUE
.Now you can right click on the page and inspect an element :)
This requires
USE_WKWEBVIEW
to be set to 1 and I had to modify this code:Because
mainFrame
doesn't exist onWKWebView
.Btw, why do you want to support both
WKWebView
andWebView
?