void () { JBCefBrowser browser = new JBCefBrowser("chrome:version"); JBCefJSQuery jsQuery = JBCefJSQuery.create(browser); jsQuery.addHandler(result -> { CALLBACL_COUNT.incrementAndGet(); String str = "JBCefJSQuery result: " + result; System.out.println(str); browser.loadHTML("<html><body>" + str + "</body></html>"); 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); }); invokeAndWaitForLoad(browser, () -> browser.getCefBrowser().executeJavaScript(jsQuery.inject("'hello'"), "about:blank", 0)); assertEquals("JS callback has been erroneously called on page reload", 1, CALLBACL_COUNT.get()); }