JCEF webview JavaScript callbacks not working in IntelliJ 2022.3 version

Answered

Hello,

I'm working on simple webview plugin and implemented few JavaScript callbacks. While I'm running my plugin in test mode (launching plugin in sandbox ide) all works perfect. But after I build plugin and install it to my IntelliJ 2022.3 (not sandbox) via zip file JavaScript callbacks not working. I tried to check are they exists using Dev Tools and don't see any.

 

Maybe someone know how to fix it?

Thanks!

0
5 comments

Hi!

How do you try to catch javascript callbacks?

Is it similar to that problem https://intellij-support.jetbrains.com/hc/en-us/requests/4018866 ?

0

Alexandr Danchenko, could you please create youtrack issue with detailed description and with simple reproducer.

0

What I discovered for now. For example, this code working fine in 2022.1. But If I try to run it in 2022.3 it doesn't work anymore.

By "not working" I mean Webview can't find this JS function (for example, "window.isInIntellijCallback")

 

JBCefJSQuery jsQuery  = JBCefJSQuery.create((JBCefBrowserBase) browser);

jsQuery.addHandler((result) -> {
System.out.println(result);
return new JBCefJSQuery.Response("IntelliJ Ide");
});

String injectedJavaScript = "window.isInIntellijCallback = function(param) {"
+ "try {"
+ jsQuery.inject("param")
+ ";"
+ "return true;"
+ "} catch(ex) {alert(ex)}"
+ "}";

browser.getCefBrowser().executeJavaScript(injectedJavaScript, browser.getCefBrowser().getURL(), 0);
0

A Vorobev

 

Unfortunately this link - https://intellij-support.jetbrains.com/hc/en-us/requests/4018866 not working for me. Could you please share more details?


Thanks

0

Sorry, I had a problem with handling Javascript queries via CefMessageRouterHandler, but from your implementation it looks like they are different issues...

0

Please sign in to leave a comment.