Skip to content

Commit f2a7e90

Browse files
committed
fix: handle race conditions accessing elements in DOM
Fixed the browser to not appear to be 'ready' to set the body before the text to be set has been processed. Otherwise, because the content is set asynchronously in a browser after the call to browser.setText, it can be that the first call to document.readyState is done before the browser has processed the request to modify the page, and therefore document.readyState returns true even if the page has no content. To fix this, we check that the document has at least one element before asking for document.readyState.
1 parent 234f8b0 commit f2a7e90

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/hover/FocusableBrowserInformationControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void updateBrowserSize(final Browser browser) {
102102
Point hint = computeSizeHint();
103103
setSize(hint.x, hint.y);
104104

105-
if (!"complete".equals(safeEvaluate(browser, "return document.readyState"))) { //$NON-NLS-1$ //$NON-NLS-2$
105+
if (!"complete".equals(safeEvaluate(browser, "return document.documentElement ? document.readyState : 'no content';"))) { //$NON-NLS-1$ //$NON-NLS-2$
106106
UI.getDisplay().timerExec(200, () -> updateBrowserSize(browser));
107107
return;
108108
}

0 commit comments

Comments
 (0)