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

Show development tools #7

Open
gimenete opened this issue May 8, 2017 · 1 comment
Open

Show development tools #7

gimenete opened this issue May 8, 2017 · 1 comment

Comments

@gimenete
Copy link

gimenete commented May 8, 2017

I was trying to implement the window.webContents.openDevTools() method. It's not trivial programmatically but can be open manually if the developerExtrasEnabled flag is set to TRUE.

    WKWebView *webView = [[WKWebView alloc] initWithFrame:window.contentView.bounds configuration:wkConf];
    [webView.configuration.preferences setValue:@(TRUE) forKey:@"developerExtrasEnabled"];

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:

- (void)webView:(WebView *)webView didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
{
#if !USE_WKWEBVIEW
    if (frame == self.webView.mainFrame) {
        self.window.title = title;
    }
#endif
}

Because mainFrame doesn't exist on WKWebView.

Btw, why do you want to support both WKWebView and WebView?

@pojala
Copy link
Owner

pojala commented May 22, 2017

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.

davidenke pushed a commit to davidenke/electrino that referenced this issue Feb 7, 2018
Add require and os modules to the Render API
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

No branches or pull requests

2 participants