Source:
public void testIntroUrlLink() throws Exception { Hover hoverResponse = new Hover( Collections.singletonList(Either.forLeft( "[My intro URL link](<LINK_0>")), new Range(new Position(0, 0), new Position(0, 10))); MockLanguageSever.INSTANCE.setHover(hoverResponse); IFile file = TestUtils.createUniqueTestFile(project, "HoverRange Other Text"); ITextViewer viewer = TestUtils.openTextViewer(file); String hoverContent = hover.getHoverInfo(viewer, new Region(0, 10)); LSBasedHover hoverManager = new LSBasedHover(); Display display = PlatformUI.getWorkbench().getDisplay(); final Shell shell = new Shell(display); final RowLayout layout = new RowLayout(SWT.VERTICAL); layout.fill = true; shell.setLayout(layout); shell.setSize(320, 200); shell.open(); BrowserInformationControl wrapperControl = (BrowserInformationControl) hoverManager.getHoverControlCreator() .createInformationControl(shell); BrowserInformationControl control = (BrowserInformationControl) wrapperControl .getInformationPresenterControlCreator().createInformationControl(shell); Field f = BrowserInformationControl.class.getDeclaredField("fBrowser"); f.setAccessible(true); Browser browser = (Browser) f.get(control); new CompletableFuture<Void>() { }; AtomicBoolean completed = new AtomicBoolean(false); browser.addProgressListener(new ProgressAdapter() { @Override public void completed(ProgressEvent event) { browser.removeProgressListener(this); browser.execute("document.getElementsByTagName('a')[0].click()"); while (display.readAndDispatch()) { } completed.set(true); } }); browser.setText(hoverContent); while (display.readAndDispatch()) { } for (long time = 0; !completed.get() && time < 10000; time += 1000) { Thread.sleep(1000); } assertNull("Editor should be closed", viewer.getTextWidget()); }

Target:
public void testIntroUrlLink() throws Exception { Hover hoverResponse = new Hover( Collections.singletonList(Either.forLeft( "[My intro URL link](<LINK_0>")), new Range(new Position(0, 0), new Position(0, 10))); MockLanguageSever.INSTANCE.setHover(hoverResponse); IFile file = TestUtils.createUniqueTestFile(project, "HoverRange Other Text"); ITextViewer viewer = TestUtils.openTextViewer(file); String hoverContent = hover.getHoverInfo(viewer, new Region(0, 10)); LSBasedHover hoverManager = new LSBasedHover(); Display display = PlatformUI.getWorkbench().getDisplay(); final Shell shell = new Shell(display); final RowLayout layout = new RowLayout(SWT.VERTICAL); layout.fill = true; shell.setLayout(layout); shell.setSize(320, 200); shell.open(); BrowserInformationControl wrapperControl = (BrowserInformationControl) hoverManager.getHoverControlCreator() .createInformationControl(shell); BrowserInformationControl control = (BrowserInformationControl) wrapperControl .getInformationPresenterControlCreator().createInformationControl(shell); Field f = BrowserInformationControl.class.getDeclaredField("fBrowser"); f.setAccessible(true); Browser browser = (Browser) f.get(control); AtomicBoolean completed = new AtomicBoolean(false); browser.addProgressListener(new ProgressAdapter() { @Override public void completed(ProgressEvent event) { browser.removeProgressListener(this); browser.execute("document.getElementsByTagName('a')[0].click()"); while (display.readAndDispatch()) { } completed.set(true); } }); assertNotNull("Editor should be opened", viewer.getTextWidget()); browser.setText(hoverContent); long maxTimestamp = System.currentTimeMillis() + 10000; while (!completed.get() && System.currentTimeMillis() < maxTimestamp) { display.readAndDispatch(); } assertNull("Editor should be closed", viewer.getTextWidget()); }