jcef.md: update "Debugging"

This commit is contained in:
Yann Cébron 2020-03-25 12:04:43 +01:00
parent 80a08c0307
commit 6d640ac7f8

View File

@ -17,12 +17,31 @@ Using JCEF requires using a dedicated JetBrains Runtime, please follow these [in
Enable `ide.browser.jcef.enabled` in Registry dialog (invoke **Help \| Find Action** and type "Registry") and restart the IDE for changes to take effect.
## Debugging
When the IDE is running in [internal mode](/reference_guide/internal_actions/enabling_internal.md), the JCEF process is started in debug mode (with the [`--inspect` flag](https://nodejs.org/en/docs/guides/debugging-getting-started/)).
The [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools/), embedded into JCEF, can be used as a debugging and profiling tool. Its active by default, so that a Chrome DevTools client can attach to it via the default port number - `9222`.
The port number can be configured with the following registry key:
JavaScript debugger in IntelliJ IDEA Ultimate can thus be used to debug JavaScript code running in it.
Use the _Attach to Node.js/Chrome_ configurations with the default port `9229`.
```
ide.browser.jcef.debug.port=9222
```
Alternatively, Chrome's DevTools can be used by invoking [internal action](/reference_guide/internal_actions/enabling_internal.md) _Show Web Browser_ and then choose **Tools \| Dev Tools \| Show Dev Tools** in browser frame menu.
JavaScript debugger in IntelliJ IDEA Ultimate can thus be used to debug JavaScript code running in the IDE via the Chrome DevTools. Use the _Attach to Node.js/Chrome_ configurations with a proper port number.
Also, JCEF provides a default Chrome DevTools front-end (similar to the one in the Chrome browser) that can be opened from the JCEFs browser component context menu via **Open DevTools** (the menu item is available in [internal mode](/reference_guide/internal_actions/enabling_internal.md) only).
To access the Chrome DevTools in plugin code, use the following API:
```java
JBCefBrowser myBrowser = new JBCefBrowser(myUrl);
CefBrowser myDevTools = myBrowser.getCefBrowser().getDevTools();
JBCefBrowser myDevToolsBrowser = new JBCefBrowser(myDevTools, myBrowser.getJBCefClient());
```
Or in order to just open it in a separate window:
```java
JBCefBrowser myBrowser = new JBCefBrowser(myUrl);
myBrowser.openDevTools();
```
## API