void (@NotNull Function<? super JBCefClient, Void> setProperty) { CountDownLatch latchBefore = new CountDownLatch(1); CountDownLatch latchAfter = new CountDownLatch(1); JBCefBrowser browser = new JBCefBrowser("chrome:version"); setProperty.apply(browser.getJBCefClient()); JBCefJSQuery jsQuery_before = JBCefJSQuery.create((JBCefBrowserBase)browser); jsQuery_before.addHandler(result -> { System.out.println("JBCefJSQuery [before] result: " + result); latchBefore.countDown(); return null; }); invokeAndWaitForLoad(browser, () -> { JFrame frame = new JFrame(JBCefLoadHtmlTest.class.getName()); frame.setSize(640, 480); frame.setLocationRelativeTo(null); frame.add(browser.getComponent(), BorderLayout.CENTER); frame.setVisible(true); }); JBCefJSQuery jsQuery_after = JBCefJSQuery.create((JBCefBrowserBase)browser); jsQuery_after.addHandler(result -> { System.out.println("JBCefJSQuery [after] result: " + result); latchAfter.countDown(); return null; }); invokeAndWaitForLatch(latchBefore, () -> { browser.getCefBrowser().executeJavaScript(jsQuery_before.inject("'query_before'"), "about:blank", 0); }); invokeAndWaitForLatch(latchAfter, () -> { browser.getCefBrowser().executeJavaScript(jsQuery_after.inject("'query_after'"), "about:blank", 0); }); }